Reputation: 55
I want the cpack to take only certain components. But he takes both run and deb components. I looked at a lot of sources. including this cpack component level install . but I did not understand what I was doing wrong. Tell me please, what did I do wrong? My 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)
my steps to get an artifact
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.
and testProj-0.1.1-Linux.tar.gz contains
someFolder
-temp.h
-Alpha0.400000.txt
Upvotes: 4
Views: 3550
Reputation: 66
Simply add the following to your CMakeLists.txt
set(CPACK_ARCHIVE_COMPONENT_INSTALL 1)
I ran into exactly the same problem and had to dive into the source to find the answer. The following function gives the answer:
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");
}
For compatibility reasons any archive packaging, i.e. ZIP and TGZ doesn't use component installations.
Upvotes: 5
Reputation: 1478
In this scenario, I think you should call make on the package
target created by Cmake and not call cpack directly, i.e. call make package
instead of cpack .
.
Alternatively, if you do call cpack directly you can pass the component(s) you want to package as a command line argument. e.g. cpack -D CPACK_COMPONENTS_ALL="deb"
(separated by ';' for multiple components)
(Note the proper variable is CPACK_COMPONENTS_ALL
not CPACK_COMPONENT_ALL
)
Upvotes: 1