-
Notifications
You must be signed in to change notification settings - Fork 875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect msgpack-cxx <= 6.0.0 with cmake #1079
Comments
that depends on how you install msgpack-cxx, if you clone this project and use cmake to install it, then using |
Thanks. I currently use: find_package(msgpack REQUIRED NAMES msgpack msgpack-cxx)
target_link_libraries(mylib PUBLIC msgpack-cxx) However this only works with the latest version 6.0.0. What's the recommended way to include and link msgpack that would be backward compatible with older msgpack versions ? Thanks. |
the problem is this library makes a breaking change in version v6.0.0, so for versions earlier than that, you’ll have to use if(MSGPACK_VERSION VERSION_LESS 6.0.0)
find_package(msgpack REQUIRED NAMES msgpackc msgpackc-cxx)
add_library(msgpack-cxx ALIAS msgpackc-cxx)
else()
find_package(msgpack REQUIRED NAMES msgpack msgpack-cxx)
endif() Then you can link your targets with |
or if you just want to detect the whether the library is installed and use it, the following snippet may be useful. find_package(msgpackc-cxx)
if(msgpackc-cxx_FOUND)
add_library(msgpack-cxx ALIAS msgpackc-cxx)
else()
find_package(msgpack-cxx REQUIRED)
endif() |
Many thanks :) Maybe this should be documented in the README because older versions will be around for a while. |
I’ll create a PR when i have time |
@uyha It seems that older versions of msgpack-c++ (like version 3.0 in Ubuntu 20.04 and version 3.3 in Ubuntu 22.04) use 'msgpack' instead of 'msgpack-cxx' or 'msgpackc-cxx' ? So there would be a need for a 3-level checks ? Something like: find_package(msgpackc-cxx QUIET CONFIG)
if(msgpackc-cxx_FOUND)
add_library(msgpack-cxx ALIAS msgpackc-cxx)
else()
find_package(msgpack-cxx CONFIG)
if(NOT msgpack-cxx_FOUND)
find_package(msgpack CONFIG REQUIRED)
add_library(msgpack-cxx ALIAS msgpack)
endif()
endif() Does this makes sense ? |
looks fine for me |
We ended up using: find_package(msgpackc-cxx QUIET CONFIG NAMES msgpackc-cxx msgpack)
if(msgpackc-cxx_FOUND)
add_library(msgpack-cxx ALIAS msgpackc-cxx)
else()
find_package(msgpack-cxx CONFIG REQUIRED)
endif() |
I added the document about that in Wiki. User can find the information using search box like this: |
Hi,
What is the recommended way to detect and use msgpack-cxx with CMake that would work with msgpack 6.0.0 and also be backward-compatible with older versions ?
Many thanks
The text was updated successfully, but these errors were encountered: