gpt4 book ai didi

c++ - CPack 具有自己依赖项的多个包

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:49:32 27 4
gpt4 key购买 nike

我在使用 CPack 和 CMake 创建两个 debian 软件包时遇到了问题。我已经完成了 here 中的示例我确实设法创建了两个不同的 debian 包,但我希望它们每个都有自己的依赖项。生成的 CMakeLists.txt 如下:

cmake_minimum_required(VERSION 2.8.0)project(MyLib)add_library(mylib mylib.cpp)add_executable(mylibapp mylibapp.cpp)target_link_libraries(mylibapp mylib)install(TARGETS mylib   ARCHIVE  DESTINATION ~/Downloads/ComponentExampleStart/lib  COMPONENT libraries)install(TARGETS mylibapp  RUNTIME  DESTINATION ~/Downloads/ComponentExampleStart/bin  COMPONENT applications)install(FILES mylib.h  DESTINATION ~/Downloads/ComponentExampleStart/include  COMPONENT headers)file(WRITE dummy_main1.c "int main(int argc, char** argv){return 0;}")add_executable(dummy_main1 dummy_main1.c)INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/dummy_main1 DESTINATION /tmp COMPONENT headers OPTIONAL PERMISSIONS OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)file(WRITE dummy_main2.c "int main(int argc, char** argv){return 0;}")add_executable(dummy_main2 dummy_main2.c)INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/dummy_main2 DESTINATION /tmp COMPONENT mylibapp OPTIONAL PERMISSIONS OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE )SET (CPACK_GENERATOR "DEB")SET (CPACK_SOURCE_GENERATOR TGZ)SET (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)SET (CPACK_SET_DESTDIR "on")set(CPACK_DEB_COMPONENT_INSTALL ON)set(CPACK_PACKAGE_NAME "MyLib")set(CPACK_PACKAGE_VENDOR "CMake.org")set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyLib - CPack Component Installation Example")set(CPACK_PACKAGE_VERSION "1.0.0")set(CPACK_PACKAGE_VERSION_MAJOR "1")set(CPACK_PACKAGE_VERSION_MINOR "0")set(CPACK_PACKAGE_VERSION_PATCH "0")set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")set(CPACK_COMPONENTS_ALL applications libraries headers)set(CPACK_COMPONENT_APPLICATIONS_GROUP "Runtime")set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")set(CPACK_COMPONENT_HEADERS_GROUP "Development")set(CPACK_COMPONENT_LIBRARIES_DEPENDS "libxml2")set(CPACK_COMPONENT_HEADERS_DEPENDS "libxml2")set(CPACK_DEBIAN_PACKAGE_DEPENDS "libusb-1.0-0")SET (CPACK_PACKAGE_CONTACT "Example ")SET (CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")include(CPack)

(NOTE dummy_main1 and dummy_main2 make shlibdeps work, because it needs at least one executable for each package).

My objective is to create 2 different debian packages with different dependencies, say for example:

MyLib_1.0.0_amd64-Developers.deb --- depends on ---> libxml2
MyLib_1.0.0_amd64-Runtime.deb --- depends on ---> lubusb-1.0-0

但我找不到 CPACK 宏来执行此操作。我已经阅读了很多论坛和文档,但我测试过的都没有对我有用。 CPACK_DEBIAN_PACKAGE_DEPENDS 宏工作正常,但它为两个包设置了相同的依赖关系。有什么办法可以实现我的目标吗?我正在使用 CMake 2.8 来执行此操作。

谢谢!

最佳答案

好吧,我终于成功地隔离了依赖关系。问题是我使用的 CMake 版本 (2.8)。这可以在最新版本(当前使用 3.3)中使用 CPack 宏完成:CPACK_DEBIAN__PACKAGE_DEPENDS

关于c++ - CPack 具有自己依赖项的多个包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33240683/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com