Domen Vrankar wrote
> I'm a bit confused. Is there something missing in the patch?
> Attached patch only adds per component version override - it doesn't even
> touch the multiple calls to `include(CPack)` and naming of different
> packages (not their components but different package names).
> 
> Could you please provide a simple example of the intended use for
> packaging
> of multiple packages with multiple sub-packages?

I have a macro that each sub-project calls. See package macro below.

Each sub project calls CMake install for it's various pieces (.so, .conf,
init.d, etc.) then:
    For a simple library package:
    package(${PROJECT_NAME}
        ${LIBRARY_VERSION}
        "My library description"
    )

    For a daemon package:
    package(${PROJECT_NAME}
        ${DAEMONX_VERSION}
        "My daemonx description"
        ${CMAKE_SOURCE_DIR}/daemonx/debian/DEBIAN/conffiles;
        ${CMAKE_SOURCE_DIR}/daemonx/debian/DEBIAN/postinst;
        ${CMAKE_SOURCE_DIR}/daemonx/debian/DEBIAN/postrm;
        ${CMAKE_SOURCE_DIR}/daemonx/debian/DEBIAN/prerm
    )

The last thing the top level CMakeLists.txt does is:
    string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
    if(${CMAKE_BUILD_TYPE} STREQUAL release)
        set(CPACK_STRIP_FILES TRUE)
    endif()

    string(REGEX REPLACE "([0-9]+).*$" "\\1" BUILD_MAJOR_VERSION
${BUILD_VERSION})
    string(REGEX REPLACE "[0-9]+\\.([0-9]+).*$" "\\1" BUILD_MINOR_VERSION
${BUILD_VERSION})
    string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1"
BUILD_PATCH_VERSION ${BUILD_VERSION})

    set(CPACK_GENERATOR DEB)
    set(CPACK_PACKAGE_VERSION_MAJOR ${BUILD_MAJOR_VERSION})
    set(CPACK_PACKAGE_VERSION_MINOR ${BUILD_MINOR_VERSION})
    set(CPACK_PACKAGE_VERSION_PATCH ${BUILD_PATCH_VERSION})
    set(CPACK_PACKAGE_VERSION ${BUILD_VERSION})
    set(CPACK_DEBIAN_PACKAGE_MAINTAINER "maintainer <maintai...@xyx.com>")
    set(CPACK_PACKAGE_VENDOR xyz)

    set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})

    set(CPACK_DEB_COMPONENT_INSTALL TRUE)
    set(CPACK_DEB_PACKAGE_COMPONENT TRUE)


In the macro, CPACK_DEBIAN_${TARGET}_PACKAGE_VERSION works because of the
patch.


macro(package target version description)
    string(TOUPPER ${target} TARGET)

    string(REGEX REPLACE "([0-9]+).*$" "\\1" BUILD_MAJOR_VERSION ${version})
    string(REGEX REPLACE "[0-9]+\\.([0-9]+).*$" "\\1" BUILD_MINOR_VERSION
${version})
    string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1"
BUILD_PATCH_VERSION ${version})

    set(CPACK_DEBIAN_${TARGET}_PACKAGE_NAME ${target} CACHE STRING "package
${target}")
    set(CPACK_DEBIAN_${TARGET}_PACKAGE_VERSION ${version} CACHE STRING
"package ${target}")
    set(CPACK_DEBIAN_${TARGET}_PACKAGE_SECTION main CACHE STRING "package
${target}")
    set(CPACK_DEBIAN_${TARGET}_PACKAGE_PRIORITY standard CACHE STRING
"package ${target}")
    set(CPACK_DEBIAN_${TARGET}_PACKAGE_ARCHITECTURE
${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "package ${target}")
    set(CPACK_COMPONENT_${TARGET}_DESCRIPTION ${description} CACHE STRING
"package ${target}")
    set(CPACK_DEBIAN_${TARGET}_PACKAGE_CONTROL_EXTRA ${ARGN} CACHE STRING
"package ${target}")

    set(CPACK_DEBIAN_${TARGET}_FILE_NAME
${target}_${version}_${CMAKE_PACKAGE_PLATFORM}.deb CACHE STRING "package
${target}")
endmacro()



--
Sent from: http://cmake.3232098.n2.nabble.com/
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to