gpt4 book ai didi

cmake - cpack 组件安装不起作用

转载 作者:行者123 更新时间:2023-12-03 06:01:30 24 4
gpt4 key购买 nike

我希望 cpack 仅采用某些组件。但他同时使用 run 和 deb 组件。我查看了很多资料来源。包括这个cpack component level install 。但我不明白我做错了什么。请告诉我,我做错了什么?我的 CMakeLists.txt

cmake_minimum_required(VERSION 3.8)
project(testProj)

set(CMAKE_CXX_STANDARD 11)

set(SOURCE_FILES main.cpp)
add_executable(testProj ${SOURCE_FILES})

set(CMAKE_INSTALL_PREFIX .)

install(FILES temp.h DESTINATION someFolder
PERMISSIONS OWNER_READ OWNER_WRITE WORLD_READ WORLD_EXECUTE COMPONENT deb
)

install(FILES Alpha0.400000.txt DESTINATION someFolder
PERMISSIONS OWNER_READ OWNER_WRITE WORLD_READ WORLD_EXECUTE COMPONENT run
)

set(CPACK_TGZ_COMPONENT_INSTALL ON)
set(CPACK_COMPONENT_ALL deb)
set(CPACK_COMPONENTS_ALL deb)

include(CPack)

我获得神器的步骤

cmake . 
make
cpack .

CPack: Create package using STGZ
CPack: Install projects
CPack: - Run preinstall target for: testProj
CPack: - Install project: testProj
CPack: Create package
CPack: - package: /home/danyal/testProj/test/testProj-0.1.1-Linux.sh generated.
CPack: Create package using TGZ
CPack: Install projects
CPack: - Run preinstall target for: testProj
CPack: - Install project: testProj
CPack: Create package
CPack: - package: /home/danyal/testProj/test/testProj-0.1.1-Linux.tar.gz generated.
CPack: Create package using TZ
CPack: Install projects
CPack: - Run preinstall target for: testProj
CPack: - Install project: testProj
CPack: Create package
CPack: - package: /home/danyal/testProj/test/testProj-0.1.1-Linux.tar.Z generated.

并且testProj-0.1.1-Linux.tar.gz包含

someFolder
-temp.h
-Alpha0.400000.txt

最佳答案

只需将以下内容添加到您的 CMakeLists.txt

set(CPACK_ARCHIVE_COMPONENT_INSTALL 1)

我遇到了完全相同的问题,必须深入研究源头才能找到答案。下面的函数给出了答案:

bool cmCPackArchiveGenerator::SupportsComponentInstallation() const
{
// The Component installation support should only
// be activated if explicitly requested by the user
// (for backward compatibility reason)
return IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL");
}

出于兼容性原因,任何存档打包(即 ZIP 和 TGZ)都不使用组件安装。

关于cmake - cpack 组件安装不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47080663/

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