我试图在 cmake 中生成一个包含我经常使用的标准库的预编译头文件。当我运行 cmake 时没有错误,但是当我构建它时,它说它在 cmake_pch.h 中找不到头文件。
这是我的 cmake 脚本的片段,它添加了预编译头:
target_precompile_headers(fae-core PRIVATE
<algorithm>
<cstddef>
<fstream>
<string>
<sstream>
<memory>
<chrono>
)
Run Code Online (Sandbox Code Playgroud)
以下是运行 cmake 生成的 makefile 的完整输出:
Scanning dependencies of target fae-core
[ 6%] Building CXX object core/CMakeFiles/fae-core.dir/cmake_pch.hxx.gch
[ 12%] Building C object core/CMakeFiles/fae-core.dir/cmake_pch.h.gch
In file included from <command-line>:32:
/home/finn/dev/fae/build/core/CMakeFiles/fae-core.dir/cmake_pch.h:4:10: fatal error: algorithm: No such file or directory
4 | #include <algorithm>
| ^~~~~~~~~~~
compilation terminated.
make[2]: *** [core/CMakeFiles/fae-core.dir/build.make:78: core/CMakeFiles/fae-core.dir/cmake_pch.h.gch] Error 1
make[1]: *** [CMakeFiles/Makefile2:136: core/CMakeFiles/fae-core.dir/all] Error 2
make: *** [Makefile:84: all] …Run Code Online (Sandbox Code Playgroud)