Skip to content

Commit

Permalink
Generate cnats-config-version.cmake (#813)
Browse files Browse the repository at this point in the history
* provide cnats-config-version.cmake to be able to define required version in find_package

* change from requiring same major version to same minor version

---------

Co-authored-by: Rolf Lussi <[email protected]>
  • Loading branch information
rolflussi and Rolf Lussi authored Oct 11, 2024
1 parent 3c1c949 commit 7b5d3d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.13)
project(cnats)
include(CTest)
include(FindPackageHandleStandardArgs)
include(CMakePackageConfigHelpers)

# Uncomment to have the build process verbose
# set(CMAKE_VERBOSE_MAKEFILE TRUE)
Expand Down Expand Up @@ -258,6 +259,11 @@ set(NATS_VERSION_SUFFIX "-beta")

set(NATS_VERSION_REQUIRED_NUMBER 0x030900)

write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/cnats-config-version.cmake"
COMPATIBILITY SameMinorVersion
VERSION ${NATS_VERSION_MAJOR}.${NATS_VERSION_MINOR}.${NATS_VERSION_PATCH}${NATS_VERSION_SUFFIX})

if(NATS_UPDATE_VERSION OR NATS_UPDATE_DOC)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ if(NATS_BUILD_LIB_SHARED)
NAMESPACE cnats::
FILE cnats-config.cmake
DESTINATION ${NATS_LIBDIR}/cmake/cnats)
install(FILES "${PROJECT_BINARY_DIR}/cnats-config-version.cmake"
DESTINATION ${NATS_LIBDIR}/cmake/cnats)
endif(NATS_BUILD_LIB_SHARED)

if(NATS_BUILD_LIB_STATIC)
Expand All @@ -79,6 +81,8 @@ if(NATS_BUILD_LIB_STATIC)
NAMESPACE cnats::
FILE cnats-config.cmake
DESTINATION ${NATS_LIBDIR}/cmake/cnats)
install(FILES "${PROJECT_BINARY_DIR}/cnats-config-version.cmake"
DESTINATION ${NATS_LIBDIR}/cmake/cnats)
endif(NATS_BUILD_LIB_STATIC)

install(FILES deprnats.h DESTINATION ${NATS_INCLUDE_DIR} RENAME nats.h)
Expand Down

0 comments on commit 7b5d3d7

Please sign in to comment.