我有一个由多个目标组成的 cmake 项目。
MyProject/
/target1
/Some stuff
/CMakeLists.txt // here add_executable(target1 main.c)
/target2
/target3
...
CMakeLists.txt // root CMakeLists.txt file
/build // folder for build files
我只想构建 target1 并将其放入我的项目内的/build 文件夹
我可以构建所有目标
[MyProject/build]$ cmake ..
[MyProject/build]$ make
如何只构建target1?
我猜应该是这样的?
[MyProject/build]$ cmake ..
[MyProject/build]$ cmake --build . --target target1 -- -j 12
最佳答案
假设您在 CMakeLists.txt 中设置了一个可执行文件
add_executable( my_exe ${my_exe_sources} )
然后你可以调用make my_exe -j 2
关于c - 如何在 CMake 中按名称构建目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55418257/