CMake依赖于“所有”目标从自定义目标 [英] CMake depend on "all" target from custom target
问题描述
我正在制作一个需要以高级方式打包的图书馆,作为其中的一部分,我有一个包含这些行的脚本:
I'm making a library that needs to be packaged in a fancy way, and as part of that, I have a script that contains these lines:
#only install the lib component, nd put in the a special directory
ADD_CUSTOM_TARGET(o_destdir_install
COMMAND DESTDIR=${CMAKE_BINARY_DIR}/o_package ${CMAKE_COMMAND} -DCOMPONENT=lib -P cmake_install.cmake
DEPENDS ${CMAKE_BINARY_DIR}/cmake_install.cmake
COMMENT "Building o_package directory with DESTDIR"
)
ADD_DEPENDENCIES(o_destdir_install all preinstall)
我从旧的UseDebian.cmake dpkg生成器中找到了这个代码,但它不会生成所有和预安装,安装。使我的目标取决于一个非内置的目标似乎工作,但我不能依赖任何内置的目标,它似乎。我如何让这个工作?
I've found this code from the old UseDebian.cmake dpkg builder, however it does NOT build all and preinstall before it runs the install. Making my target depend on a non-built-in target seems to work, but I can't depend on any built-in targets it seems. How can I get this to work?
此外,如果我可以依赖单个组件安装,最好没有黑客调用cmake,但是我可以很好。
Also it would be nice if I could depend on a single component install preferably without the hacking calling of cmake, but I'm fine either way
推荐答案
代替合并自己的安装目标,你应该使用 install(CODE)
表单:
Instead of hacking together your own install target, you should just piggy-back on the existing one using the install(CODE)
form:
install(CODE "execute_process(COMMAND DESTDIR=${CMAKE_BINARY_DIR}/o_package ${CMAKE_COMMAND} -DCOMPONENT=lib -P cmake_install.cmake")
这篇关于CMake依赖于“所有”目标从自定义目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!