如何制作依赖于
all
或 install
的自定义目标?
我想在执行一些测试之前确保行为运行
install
:
# CMakeLists.txt
add_custom_target(behave
behave
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS install
)
# I also tried without `DEPENDS` above and with this:
#add_dependencies(behave install)
但是它似乎想建立一个真正的目标,叫做
install
:
$ make behave
...
make[2]: *** No rule to make target 'CMakeFiles/install.dir/all', needed by 'CMakeFiles/behave.dir/all'. Stop.
...
安装就是安装。您可以在安装过程中使用 https://cmake.org/cmake/help/latest/command/install.html#script 调用自定义代码。