我正在使用cmake,通过ExternalProject_add
添加一些项目,当我添加目标
ExternalProject_Add_StepTargets(SubProject doc)
ExternalProject_Add_Step(SubProject doc)
我获得了一个新目标SubProject-doc
,但是当我构建它时,doc
的目标SubProject
未被执行。
外部项目添加如下:
ExternalProject_add(subproject
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/subproject
BINARY_DIR ${subproject_DIR}
CMAKE_ARGS ${CMAKE_ARGS}
INSTALL_DIR ${CMAKE_BINARY_DIR}/install
DEPENDS subproject2
)
答案 0 :(得分:1)
ExternalProject
的步骤与其所代表的子项目的目标之间没有隐式关系。 CMake只知道如何生成一些预定义的步骤,如“下载”,“配置”,“构建”。要创建其他步骤,您需要明确地为它们指定命令:
ExternalProject_Add_Step(Subproject doc
# Equivalent to 'make doc' but in platform-independent manner
COMMAND ${CMAKE_COMMAND} --build . --target doc
# Use automatically-replaced token for refer to binary dir
WORKING_DIRECTORY <BINARY_DIR>
# When requested, step is always run.
# (It is 'make doc' behavior who should care to not generate
# documentation if it has already been generated.)
ALWAYS 1
# This step is not a part of normal build of external project.
EXCLUDE_FROM_MAIN 1
# However, this step requires some other steps to be performed
DEPENDEES configure
)
之后,您可以在主项目中创建一个目标,该目标将执行给定的步骤:
ExternalProject_Add_StepTargets(SubProject doc)
在ExternalProject
模块的What's the difference between `on` and `live` or `bind`?中查看更多内容。