CMake项目中的组建目标

Jan*_*aap 3 cmake

我只是使用add_custom_target()命令将doxygen生成包括在我的项目中。现在,我不包括全部,因为我不希望此构建为默认构建。

现在,我有以下情形。

项目/ subproj1 / doc项目/ subproj2 / doc

在每个子项目中,都有一个CMakeLists.txt文件,其中包含: add_custom_target(gen_doc_subproj1 ...) add_custom_target(gen_doc_subproj2 ...)

我想要实现的是生成生成文件后,我可以输入:

制作文档 ,它将建立所有文档目标。

CMake中是否有一些构造,例如: if_not_exist_target_group(doc) create_target_group(doc) endif add_to_target_group(gen_doc_subproj1, doc)

任何指针都会被应用。

arr*_*owd 6

如果我没听错,那很简单

if(NOT TARGET doc)
  add_custom_target(doc)
  add_dependencies(doc gen_doc_subproj1 gen_doc_subproj2 ...)
endif()
Run Code Online (Sandbox Code Playgroud)