Skip to content

Conversation

@rolflussi
Copy link
Contributor

Implementation of #812

Allows other cmake projects to use this library with a specific version:

find_package(cnats 3.9 REQUIRED)   # requires a version >= 3.9 and < 4.0

The cnats-config-version.cmake will make sure that the correct major version and at least the defined minor version is available.

CMakeLists.txt Outdated

write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/cnats-config-version.cmake"
COMPATIBILITY SameMajorVersion
Copy link
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
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
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
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.

Copy link
Collaborator

@levb levb left a comment

Choose a reason for hiding this comment

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

LGTM

@levb levb merged commit 7b5d3d7 into nats-io:main Oct 11, 2024
levb pushed a commit to levb/nats.c that referenced this pull request Dec 9, 2024
* 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]>
@levb levb removed the cherry-pick label Dec 9, 2024
@levb
Copy link
Collaborator

levb commented Dec 9, 2024

Cherry-picked into v3.9.2

@levb levb mentioned this pull request Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants