SET(CPACK_COMPONENTS_ALL ...) with ExternalProject 安装附加组件
SET(CPACK_COMPONENTS_ALL ...) with ExternalProject Installing Additional Components
我将 ExtrenalProject cmake module to add 3rd party or internal dependencies to my build. I then use the CPack 模块与组件一起使用,以按以下方式仅安装当前代码库中的组件。
set(CPACK_COMPONENTS_ALL
common-lib
common-include
common-depends
)
在 CMake 中声明的这些组件之一的示例是:
install(TARGETS common
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
COMPONENT common-lib
)
但是,使用 add_subdirectory
添加的其他项目(例如 google test 或其他内部库也声明了安装目标。当我运行
make package
然后列出.deb
或.tar
生成的内容,我看到CPACK_COMPONENTS_ALL
变量中没有设置其他组件的内容。
让 CMake 和 CPack 只安装请求的组件的正确方法是什么?
您可以将参数 EXCLUDE_FROM_ALL
添加到 add_subdirectory()
调用的末尾。这实际上将禁用在添加的子目录中进行的所有 include()
调用。
我将 ExtrenalProject cmake module to add 3rd party or internal dependencies to my build. I then use the CPack 模块与组件一起使用,以按以下方式仅安装当前代码库中的组件。
set(CPACK_COMPONENTS_ALL
common-lib
common-include
common-depends
)
在 CMake 中声明的这些组件之一的示例是:
install(TARGETS common
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
COMPONENT common-lib
)
但是,使用 add_subdirectory
添加的其他项目(例如 google test 或其他内部库也声明了安装目标。当我运行
make package
然后列出.deb
或.tar
生成的内容,我看到CPACK_COMPONENTS_ALL
变量中没有设置其他组件的内容。
让 CMake 和 CPack 只安装请求的组件的正确方法是什么?
您可以将参数 EXCLUDE_FROM_ALL
添加到 add_subdirectory()
调用的末尾。这实际上将禁用在添加的子目录中进行的所有 include()
调用。