cmake - cpack get different packages versions

97 Views Asked by At

I have project that contains subprojects.

The package directory contains CMakeLists.txt. Looks like this:

set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Company")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_DEB_COMPONENT_INSTALL ON)

...

if(NOT CMAKE_CROSSCOMPILING)
    set(CPACK_COMPONENTS_ALL desktop)
    set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
    add_subdirectory(desktop)
elseif(IMX6)
    set(CPACK_COMPONENTS_ALL primary_display secondary_display)
    set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf")
    add_subdirectory(primary_display)
    add_subdirectory(secondary_display)
elseif(IMX8)
    set(CPACK_COMPONENTS_ALL primary_display secondary_display)
    set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm64")
    add_subdirectory(primary_display)
    add_subdirectory(secondary_display)
endif()

...

include(CPack)

The problem is that created packages versions are the same as root CMakeLists.txt project unca 1.0.1:

unca-primary_display_1.0.1_armhf.deb
unca-secondary_display_1.0.1_armhf.deb

While primary_display is 1.0.0, secondary_display is 1.0.0 in their own CMakeLists.txt.

I don't now how to pass primary_display and secondary_display versions.

I tried to get local version using this function: https://stackoverflow.com/a/49551280/12797579 But I don't know how to pass the value on top CMakeLists.txt

0

There are 0 best solutions below