tags:

views:

24

answers:

1

The idea is to define 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
+1  A: 

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.

Gaspard Bucher