Comments (10)
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()
from msgpack-c.
that depends on how you install msgpack-cxx, if you clone this project and use cmake to install it, then using find_package
should work, similarly for Conan.
from msgpack-c.
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.
from msgpack-c.
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 msgpackc-cxx
. In you CMake script, you can do something like
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 msgpack-cxx
regardless of the version.
from msgpack-c.
Many thanks :)
Maybe this should be documented in the README because older versions will be around for a while.
from msgpack-c.
I’ll create a PR when i have time
from msgpack-c.
@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 ?
from msgpack-c.
looks fine for me
from msgpack-c.
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()
from msgpack-c.
I added the document about that in Wiki.
https://github.com/msgpack/msgpack-c/wiki/Q%26A#how-to-support-both-msgpack-c-c-version-5x-and-6x-
User can find the information using search box like this:
https://github.com/search?q=repo%3Amsgpack%2Fmsgpack-c+cmake&type=wikis
from msgpack-c.
Related Issues (20)
- The dynamic library generated has wrong version HOT 1
- A new release HOT 2
- missing sysdep.h, pack_template.h, predef.h and predef folder in msgpck-c HOT 2
- Unable to unpack extension with `UINT32_MAX` bytes of data HOT 4
- Unpacking float32 does not preserve signaling NaN, unlike float64 HOT 10
- Cannot convert vector<int> to variant HOT 1
- Deploy `msgpack-cxx` package to platform-independent package repository
- How to compile msgpack-c on linux to use with mingw to cross compile apps for windows
- Memory cleaned up multiple times
- URGENT: Wiki security issue HOT 3
- Unpack example from quickstart segfaults HOT 3
- Question, when packing, are the values already supposed to be in big endian HOT 2
- JSON-like API? HOT 1
- msgpack incorrectly deserializes a std::map to std::multimap HOT 2
- [Question/Discussion] msgpack is much slower than Boost.JSON HOT 7
- find_package Ignoring Boost_ROOT Due to Unset CMP0074 Policy
- Cannot serialize small floats in msgpack float format HOT 1
- someting about msgpack::object.convert() HOT 1
- Where can i find `msgpack` library?? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msgpack-c.