[CMake] Problem with CPack components
Gerhard Gappmeier
gerhard.gappmeier at ascolab.com
Thu Jul 10 08:13:29 EDT 2014
Hi all,
I debugged the generation process and found out the problems.
(using latest git master, cmake 3.0)
1.) It's named CPACK_DEB_COMPONENT_INSTALL and not
CPACK_DEBIAN_COMPONENT_INSTALL!
This is a little bit confusing, because all other Debian variables start with
CPACK_DEBIAN_*
But the wiki states CPACK_<GENNAME>_COMPONENT_INSTALL,
where GENAME is DEB and not DEBIAN.
This could be made a little bit clearer to avoid confusion.
2.) set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1) is required to create
a single package.
3.) For Archive installers TGZ, ZIP, etc. the variable
CPACK_ARCHIVE_COMPONENT_INSTALL must be used, and not
CPACK_TGZ_COMPONENT_INSTALL, or CPACK_ZIP_COMPONENT_INSTALL.
This is wrong in the wiki.
Here is a working version of my example:
project(cpacktest)
cmake_minimum_required(VERSION 2.8)
# project version info
set(MAJOR_VERSION 1)
set(MINOR_VERSION 0)
set(PATCH_VERSION 0)
# create some dummy install targets for testing components
install(FILES foo.txt DESTINATION bin COMPONENT applications)
install(FILES bar.txt DESTINATION bin COMPONENT libraries)
#{{{ Debian package generation
###############################################
#################################
IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
INCLUDE(InstallRequiredSystemLibraries)
SET(CPACK_SET_DESTDIR "on")
SET(CPACK_PACKAGING_INSTALL_PREFIX "/tmp")
SET(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_DESCRIPTION "CPack Component Test")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Testing filtering for CPack
components")
SET(CPACK_PACKAGE_VENDOR "ACME Inc.")
SET(CPACK_PACKAGE_CONTACT "info at acme.com")
SET(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
SET(CPACK_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.
${CPACK_PACKAGE_VERSION_PATCH}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.
${CPACK_PACKAGE_VERSION_PATCH}")
SET(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
SET(CPACK_DEB_COMPONENT_INSTALL ON)
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libcrack2 (>= 2.9.1),
libqt5core5a (>= 5.3.0), libqt5widgets5 (>= 5.3.0), libqt5gui5 (>= 5.3.0)")
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
SET(CPACK_DEBIAN_PACKAGE_SECTION "kde")
SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
# only pack the applications component, leave out all other
components
SET(CPACK_COMPONENTS_ALL applications)
INCLUDE(CPack)
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
###############################################
#################################
#}}}
Now, that this is correct it also works with cmake 2.8.12.
regards,
Gerhard.
PS: The best documentation is always source code. Open Source rules!
On Thursday, July 10, 2014 09:35:56 AM Gerhard Gappmeier wrote:
> Hi,
>
> I'm generating deb packages for a project using CPack.
> This project contains a lot of libraries which are used the build the final
> applications.
> Because I don't want to distribute the headers and static libraries in the
> package, but only the executable I tried to use the components to filter
> what should be included in the package. (like documented here:
> http://www.cmake.org/Wiki/CMake:Component_Install_With_CPack)
>
> However it doesn't work for me. CPack always includes all components.
>
> For reproducing this I created a every simple project with just two
dummy
> install targets (no source, no compilation necessary).
>
> To reproduce this please do the following:
> mkdir cpacktest
> cd cpacktest
> touch foo.txt
> touch bar.txt
>
> and create the following CMakeLists.txt:
> project(cpacktest)
> cmake_minimum_required(VERSION 2.8)
>
> # project version info
> set(MAJOR_VERSION 1)
> set(MINOR_VERSION 0)
> set(PATCH_VERSION 0)
>
> # create some dummy install targets for testing components
> install(FILES foo.txt DESTINATION bin COMPONENT applications)
> install(FILES bar.txt DESTINATION bin COMPONENT libraries)
>
> #{{{ Debian package generation
>
###############################################
> #################################
> IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
> INCLUDE(InstallRequiredSystemLibraries)
>
> SET(CPACK_SET_DESTDIR "on")
> SET(CPACK_PACKAGING_INSTALL_PREFIX "/tmp")
> SET(CPACK_GENERATOR "DEB")
>
> SET(CPACK_PACKAGE_DESCRIPTION "CPack Component Test")
> SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Testing filtering for
CPack
> components")
> SET(CPACK_PACKAGE_VENDOR "ACME Inc.")
> SET(CPACK_PACKAGE_CONTACT "info at acme.com")
> SET(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
> SET(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
> SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
> SET(CPACK_PACKAGE_FILE_NAME
> "${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140710/d72d375d/attachment-0001.html>
More information about the CMake
mailing list