0

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

a.wise
  • 164
  • 1
  • 10
  • "While `primary_display` is 1.0.0, `secondary_display` is 1.0.0 in their own `CMakeLists.txt`." - Do you mean that corresponding `CMakeLists.txt` contains the line `project(primary_display VERSION 1.0.0)`? How exactly have you specified version for these projects? – Tsyvarev Jul 05 '23 at 09:24
  • @Tsyvarev yes, corresponding `CMakeLists.txt` contains line `project(primary_display VERSION 1.0.0)`. In `add_subdirectory(primary_display)` the `CMakeLists.txt` contains only component install targets, files. Project version for `primary_display` is in `apps/primary_display/CMakeLists.txt` it has `add_executable`, `target_sources` and etc. For `secondary_display` is the same – a.wise Jul 05 '23 at 10:17
  • 1
    From the view of CPack/CMake, `primary_display` and `secondary_display` are **components** and they are not connected with the **projects**. That is, versions of the **project** `primary_display` is not a version of a **component** with the same name. There is a [question](https://stackoverflow.com/questions/44951598/cpack-how-to-specify-different-package-versions-for-components) about specifying a version for a CPack component, but it has no answers. From my understanding, this is impossible: CPack components simply have no notion of version, the only version is the package version. – Tsyvarev Jul 05 '23 at 10:32

0 Answers0