如何在CMake中按名称构建目标?
我有一个由多个目标组成的cmake项目如何在CMake中按名称构建目标?,c,cmake,C,Cmake,我有一个由多个目标组成的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/
/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