[CMake] Problem with CPack components

Gerhard Gappmeier gerhard.gappmeier at ascolab.com
Thu Jul 10 03:35:56 EDT 2014


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}.
${CPACK_PACKAGE_VERSION_PATCH}")
    SET(CPACK_SOURCE_PACKAGE_FILE_NAME 
"${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.
${CPACK_PACKAGE_VERSION_PATCH}")

    SET(CPACK_DEBIAN_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})

    # only pack the applications component, leave out all other 
components
    SET(CPACK_COMPONENTS_ALL applications)
    INCLUDE(CPack)

ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
###############################################
#################################
#}}}

Building the package:
  mkdir bld
  cd bld
  cmake -DCMAKE_INSTALL_PREFIX=/usr ..
  cpack

This will build the deb package.
Or alternatively use this for creating a TGZ
  cpack -G TGZ

Result:
  The created packages contain both foo.txt and bar.txt.

Expected Result:
  The package should contain only foo.txt


I don't know if this is a bug, or if something is missing here in my 
CMakeLists.txt. I hope you can help me.



-- 
mit freundlichen Grüßen / best regards

Gerhard Gappmeier
ascolab GmbH - automation systems communication laboratory
Tel.: +49 9131 691 123
Fax: +49 9131 691 128
Web: http://www.ascolab.com
GPG-KeyId: 5AAC50C4
GPG-Fingerprint: 967A 15F1 2788 164D CCA3 6C46 07CD 6F82 5AAC 50C4

--
ascolab GmbH
Geschäftsführer: Gerhard Gappmeier, Matthias Damm, Uwe Steinkrauß
Sitz der Gesellschaft: Am Weichselgarten 7 • 91058 Erlangen • Germany
Registernummer: HRB 9360
Registergericht: Amtsgericht Fürth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140710/1ebb584b/attachment-0001.html>


More information about the CMake mailing list