Skip to content

Commit

Permalink
fix: package version for releases (#753)
Browse files Browse the repository at this point in the history
* fix: debian_version for official releases

otherwise they would be undefined

* fix: align cpack version with zenoh-c

* chore: review comments

move cpack version closer to where it's used
  • Loading branch information
diogomatsubara authored Oct 21, 2024
1 parent 45fcb32 commit 9872197
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@ configure_file(
@ONLY
)

set(project_version "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
if(NOT DEFINED PROJECT_VERSION_TWEAK)
set(project_version "${project_version}")
elseif(PROJECT_VERSION_TWEAK EQUAL 0)
set(debian_version "${project_version}~dev-1")
set(project_version "${project_version}-dev")
elseif(PROJECT_VERSION_TWEAK GREATER 1)
set(debian_version "${project_version}~pre.${PROJECT_VERSION_TWEAK}-1")
set(project_version "${project_version}-pre.${PROJECT_VERSION_TWEAK}")
endif()
status_print(project_version)


include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

Expand Down Expand Up @@ -506,6 +493,7 @@ endif()

# For packaging
if(PACKAGING)

set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/packages")

set(CPACK_COMPONENTS_ALL Runtime Headers Dev)
Expand All @@ -518,9 +506,17 @@ if(PACKAGING)

set(CPACK_PACKAGE_CHECKSUM MD5)
set(CPACK_PACKAGE_VENDOR "The Eclipse Foundation")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
if(NOT CPACK_PACKAGE_VERSION)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(SEM_VER "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
if(NOT DEFINED PROJECT_VERSION_TWEAK)
set(CPACK_PACKAGE_VERSION ${SEM_VER})
elseif(PROJECT_VERSION_TWEAK EQUAL 0)
set(CPACK_PACKAGE_VERSION "${SEM_VER}~dev-1")
elseif(PROJECT_VERSION_TWEAK GREATER 0)
set(CPACK_PACKAGE_VERSION "${SEM_VER}~pre.${PROJECT_VERSION_TWEAK}-1")
endif()
endif()
set(CPACK_COMPONENT_RUNTIME_DESCRIPTION "The C client library for Eclipse zenoh targeting pico devices")
set(CPACK_COMPONENT_HEADERS_DESCRIPTION "${CPACK_COMPONENT_LIB_DESCRIPTION} - headers")
set(CPACK_COMPONENT_DEV_DESCRIPTION "${CPACK_COMPONENT_LIB_DESCRIPTION} - config files")
Expand Down Expand Up @@ -555,7 +551,7 @@ if(PACKAGING)
set(CPACK_DEBIAN_LIB_PACKAGE_NAME "lib${PROJECT_NAME}")
set(CPACK_DEBIAN_LIB_PACKAGE_DEPENDS "libc6 (>=2.12)")
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "lib${PROJECT_NAME}-dev")
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "${CPACK_DEBIAN_LIB_PACKAGE_NAME} (=${debian_version})")
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "${CPACK_DEBIAN_LIB_PACKAGE_NAME} (=${CPACK_PACKAGE_VERSION})")
endif()

if(PACKAGING MATCHES "RPM")
Expand All @@ -576,7 +572,7 @@ if(PACKAGING)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
set(CPACK_RPM_LIB_PACKAGE_NAME ${PROJECT_NAME}) # avoid "-lib" suffix for "lib" package
set(CPACK_RPM_DEV_PACKAGE_REQUIRES "${CPACK_RPM_LIB_PACKAGE_NAME} = ${PROJECT_VERSION}")
set(CPACK_RPM_DEV_PACKAGE_REQUIRES "${CPACK_RPM_LIB_PACKAGE_NAME} = ${CPACK_PACKAGE_VERSION}")
endif()

include(CPack)
Expand Down

0 comments on commit 9872197

Please sign in to comment.