Code Monkey home page Code Monkey logo

Comments (10)

uyha avatar uyha commented on June 2, 2024 1

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.

uyha avatar uyha commented on June 2, 2024

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.

aberaud avatar aberaud commented on June 2, 2024

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.

uyha avatar uyha commented on June 2, 2024

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.

aberaud avatar aberaud commented on June 2, 2024

Many thanks :)

Maybe this should be documented in the README because older versions will be around for a while.

from msgpack-c.

uyha avatar uyha commented on June 2, 2024

I’ll create a PR when i have time

from msgpack-c.

aberaud avatar aberaud commented on June 2, 2024

@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.

uyha avatar uyha commented on June 2, 2024

looks fine for me

from msgpack-c.

aberaud avatar aberaud commented on June 2, 2024

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.

redboltz avatar redboltz commented on June 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.