Jan Jaap
Jan Jaap

Reputation: 487

Group build targets in CMake project

I just included doxygen generation in my project using the add_custom_target() command. Now I did not include ALL as I don't want this build be default.

Now I have the following scenario.

project/subproj1/doc project/subproj2/doc

In each subproject there is a CMakeLists.txt file with: add_custom_target(gen_doc_subproj1 ...) add_custom_target(gen_doc_subproj2 ...)

What I'd like to achieve is that after generating my make files I can type:

make doc and it will build all documentation targets.

Is there some construction in CMake such as: if_not_exist_target_group(doc) create_target_group(doc) endif add_to_target_group(gen_doc_subproj1, doc)

Any pointers would be appriciated.

Upvotes: 7

Views: 6112

Answers (1)

arrowd
arrowd

Reputation: 34401

If i understood you right, it is as simple as

if(NOT TARGET doc)
  add_custom_target(doc)
  add_dependencies(doc gen_doc_subproj1 gen_doc_subproj2 ...)
endif()

Upvotes: 16

Related Questions