英文:
cmake - cpack component install deb is empty
问题
我想获取特定组件的deb软件包。当我使用特定的工具链文件IMX6
或IMX8
时,会设置变量。在使用IMX6
时的输出:
运行CPack打包工具...
CPack: 使用DEB创建软件包
CPack: 安装项目
CPack: - 为主项目运行preinstall目标
CPack: - 安装项目:主项目 []
CPack: - 安装组件:PRIMARY_DISPLAY
CPack: - 安装组件:SECONDARY_DISPLAY
CPack: 创建软件包
-- 未设置CPACK_DEBIAN_PACKAGE_DEPENDS,软件包将没有依赖项。
-- 未设置CPACK_DEBIAN_PACKAGE_DEPENDS,软件包将没有依赖项。
CPack: - 软件包:/home/anzipex/Downloads/add_target_package_secondary_47154/debs_47154/unca_23/cmake-build-release-imx6/unca-1.0.1-Linux-PRIMARY_DISPLAY.deb 已生成。
CPack: - 软件包:/home/anzipex/Downloads/add_target_package_secondary_47154/debs_47154/unca_23/cmake-build-release-imx6/unca-1.0.1-Linux-SECONDARY_DISPLAY.deb 已生成。
问题在于创建的deb软件包内部是空的。在目录_CPack_Packages
中,deb软件包包含data.tar.gz
,其中只包含空的usr
目录。但是如果我设置这个变量:
set(CPACK_MONOLITHIC_INSTALL 1)
,主要的deb软件包中包含所有数据。出了什么问题?
我的主要CMakeLists.txt
看起来像这样:
cmake_minimum_required(VERSION 3.0.0)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Company")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_DEB_COMPONENT_INSTALL ON)
if(NOT CMAKE_CROSSCOMPILING)
set(CPACK_COMPONENTS_ALL DESKTOP)
set(CPACK_DEBIAN_DESKTOP_PACKAGE_ARCHITECTURE "amd64")
add_subdirectory(desktop)
elseif(IMX6)
set(CPACK_COMPONENTS_ALL PRIMARY_DISPLAY SECONDARY_DISPLAY)
set(CPACK_DEBIAN_PRIMARY_DISPLAY_PACKAGE_ARCHITECTURE "armhf")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_ARCHITECTURE "armhf")
add_subdirectory(primary_display)
add_subdirectory(secondary_display)
elseif(IMX8)
set(CPACK_COMPONENTS_ALL PRIMARY_DISPLAY SECONDARY_DISPLAY)
set(CPACK_DEBIAN_PRIMARY_DISPLAY_PACKAGE_ARCHITECTURE "arm64")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_ARCHITECTURE "arm64")
add_subdirectory(primary_display)
add_subdirectory(secondary_display)
endif()
include(CPack)
secondary_display/CMakeLists.txt
的示例:
cmake_minimum_required(VERSION 3.0.0)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/apps/secondary_display/resources DESTINATION /opt/unca COMPONENT secondary_display)
install(TARGETS secondary_display DESTINATION /opt/unca COMPONENT secondary_display)
install(TARGETS ahrs DESTINATION /opt/unca COMPONENT secondary_display)
install(TARGETS sns DESTINATION /opt/unca COMPONENT secondary_display)
install(DIRECTORY DESTINATION /var/opt/unca COMPONENT secondary_display
DIRECTORY_PERMISSIONS
OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_WRITE GROUP_READ GROUP_EXECUTE
WORLD_WRITE WORLD_READ WORLD_EXECUTE
)
install(FILES ${PROJECT_SOURCE_DIR}/resources/configs/net.xml DESTINATION /var/opt/unca COMPONENT secondary_display)
install(FILES services/unca-secondary-display.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)
install(FILES services/unca-ahrs.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)
install(FILES services/unca-sns.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)
set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_NAME "unca-secondary-display")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_FILE_NAME "unca-secondary-display-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_DESKTOP_PACKAGE_ARCHITECTURE}.deb")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_DESCRIPTION "UNCA SECONDARY DISPLAY")
string(CONCAT CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_SOURCE_DIR}/debian/prerm;"
"${CMAKE_CURRENT_SOURCE_DIR}/debian/preinst;"
"${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst"
)
英文:
I want to get deb packages of specific components. When I'm using specific toolchain file IMX6
or IMX8
variables are set. Output when using IMX6
:
Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: main_project
CPack: - Install project: main_project []
CPack: - Install component: PRIMARY_DISPLAY
CPack: - Install component: SECONDARY_DISPLAY
CPack: Create package
-- CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.
-- CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.
CPack: - package: /home/anzipex/Downloads/add_target_package_secondary_47154/debs_47154/unca_23/cmake-build-release-imx6/unca-1.0.1-Linux-PRIMARY_DISPLAY.deb generated.
CPack: - package: /home/anzipex/Downloads/add_target_package_secondary_47154/debs_47154/unca_23/cmake-build-release-imx6/unca-1.0.1-Linux-SECONDARY_DISPLAY.deb generated.
The problem is that created deb packages are empty inside. In directory _CPack_Packages
deb packages have data.tar.gz
and contains only empty usr
directory. However if i set this variable:
set(CPACK_MONOLITHIC_INSTALL 1)
main deb package has all data. What's wrong with that?
My main CMakeLists.txt
looks like this:
cmake_minimum_required(VERSION 3.0.0)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Company")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_DEB_COMPONENT_INSTALL ON)
if(NOT CMAKE_CROSSCOMPILING)
set(CPACK_COMPONENTS_ALL DESKTOP)
set(CPACK_DEBIAN_DESKTOP_PACKAGE_ARCHITECTURE "amd64")
add_subdirectory(desktop)
elseif(IMX6)
set(CPACK_COMPONENTS_ALL PRIMARY_DISPLAY SECONDARY_DISPLAY)
set(CPACK_DEBIAN_PRIMARY_DISPLAY_PACKAGE_ARCHITECTURE "armhf")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_ARCHITECTURE "armhf")
add_subdirectory(primary_display)
add_subdirectory(secondary_display)
elseif(IMX8)
set(CPACK_COMPONENTS_ALL PRIMARY_DISPLAY SECONDARY_DISPLAY)
set(CPACK_DEBIAN_PRIMARY_DISPLAY_PACKAGE_ARCHITECTURE "arm64")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_ARCHITECTURE "arm64")
add_subdirectory(primary_display)
add_subdirectory(secondary_display)
endif()
include(CPack)
Example of secondary_display/CMakeLists.txt
:
cmake_minimum_required(VERSION 3.0.0)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/apps/secondary_display/resources DESTINATION /opt/unca COMPONENT secondary_display)
install(TARGETS secondary_display DESTINATION /opt/unca COMPONENT secondary_display)
install(TARGETS ahrs DESTINATION /opt/unca COMPONENT secondary_display)
install(TARGETS sns DESTINATION /opt/unca COMPONENT secondary_display)
install(DIRECTORY DESTINATION /var/opt/unca COMPONENT secondary_display
DIRECTORY_PERMISSIONS
OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_WRITE GROUP_READ GROUP_EXECUTE
WORLD_WRITE WORLD_READ WORLD_EXECUTE
)
install(FILES ${PROJECT_SOURCE_DIR}/resources/configs/net.xml DESTINATION /var/opt/unca COMPONENT secondary_display)
install(FILES services/unca-secondary-display.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)
install(FILES services/unca-ahrs.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)
install(FILES services/unca-sns.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)
set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_NAME "unca-secondary-display")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_FILE_NAME "unca-secondary-display-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_DESKTOP_PACKAGE_ARCHITECTURE}.deb")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_DESCRIPTION "UNCA SECONDARY DISPLAY")
string(CONCAT CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_SOURCE_DIR}/debian/prerm;"
"${CMAKE_CURRENT_SOURCE_DIR}/debian/preinst;"
"${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst"
)
答案1
得分: 0
Lines with CPACK_COMPONENTS_ALL
should be deleted from if in main CMakeLists.txt
.
英文:
Lines with CPACK_COMPONENTS_ALL
should be deleted from if in main CMakeLists.txt
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论