使cmake自定义目标依赖于`install`?

问题描述 投票:0回答:1

如何制作依赖于

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.
...
cmake
1个回答
0
投票

安装就是安装。您可以在安装过程中使用 https://cmake.org/cmake/help/latest/command/install.html#script 调用自定义代码。

© www.soinside.com 2019 - 2024. All rights reserved.