Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 SameMajorVersion

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rolflussi I do not have much personal experience with cmake package management/discovery, but what I understood from https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#generating-a-package-version-file, I think we should be using SameMinorVersion if binary compatibility is desired. Furthermore, binary compatibility may be broken even in patch releases (thus, NATS_VERSION_REQUIRED_NUMBER check), I am not sure what the best practice on this is.

@kozlovic do you have an opinion on this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we do (or should) break compatibility in a patch release. But yes, minor release may introduce new APIs, etc.. that may cause their local header file to not be in phase with the linked library (this is why we have some API to check for compatibility between the header and the lib's version).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback. I'll change it to SameMinorVersion

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I misspoke re: patch releases; I was thinking a hypothetical emergency patch that'd break the memory layout, but we'd just release it as a X.Y+1.0 from the X.Y branch.

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