Reputation: 143
I have cmake project that consist of multiple targets.
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
I wand to build only target1 and put it into /build folder inside my project
I could build all targets
[MyProject/build]$ cmake ..
[MyProject/build]$ make
How to build only target1?
I guess it must be something like this?
[MyProject/build]$ cmake ..
[MyProject/build]$ cmake --build . --target target1 -- -j 12
Upvotes: 0
Views: 2354
Reputation: 76
Your commands should work fine
cmake ..
cmake --build . --target target1 -- -j 12
will build target1
and its dependencies only.
Upvotes: 1
Reputation: 2158
Suppose you set an executable inside CMakeLists.txt
add_executable( my_exe ${my_exe_sources} )
Then you can call make my_exe -j 2
Upvotes: 3