开发者

How to add a command in CMake but not run it?

开发者 https://www.devze.com 2022-12-16 20:53 出处:网络
The idea is to defin开发者_StackOverflow社区e a detached \"examples\" target in the CMakeLists.txt that would not get executed when running:

The idea is to defin开发者_StackOverflow社区e a detached "examples" target in the CMakeLists.txt that would not get executed when running:

make

But that would build the examples when doing

make examples


I found a solution: set EXCLUDE_FROM_ALL on the "add_executable" command.

This is what I had to write to solve my "examples" build:

add_custom_target(examples)
add_executable(hello EXCLUDE_FROM_ALL hello.cpp)
add_dependencies(examples hello)

When running "make", the hello executable is not built.
When running "make examples", hello is built.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号