Closed leocencetti closed 2 years ago
Digging a bit into the code, it seems that the MSGPACK_NO_BOOST
symbol is not defined (the various if defined(MSGPACK_NO_BOOST)
evaluate to false): this leads to the inclusion of multiple boost
headers.
CMakeLists.txt#L79 is hit as expected.
Looking at the verbose output of cmake --build build
, it seems that all CMAKE_CXX_FLAGS
are lost somewhere (or overwritten).
Adding this after CMakeLists.txt#L113 fixes the missing definition:
TARGET_COMPILE_DEFINITIONS(msgpackc-cxx INTERFACE MSGPACK_NO_BOOST) # possibly add other flags as well
I checked CMakeLists.txt but I couldn't find the problem. All CMAKE_CXX_FLAGS preserved at all places.
TARGET_COMPILE_DEFINITIONS(msgpackc-cxx INTERFACE MSGPACK_NO_BOOST) # possibly add other flags as well
msgpack-c should depend on boost by default. So I think that this modification is not good.
I couldn't reproduce the error. Maybe https://stackoverflow.com/help/minimal-reproducible-example is helpful.
I'm not expert of cmake. If you would find the good solution, please send a pull request.
Hi @redboltz, thank you for your reply. It does not fail as long as you have libboost
installed on your system.
I've put together a small example that successfully reproduces the issue on our systems: https://github.com/leocencetti/msgpack-c-issue-1025-example
msgpack-c should depend on boost by default. So I think that this modification is not good
Indeed it wasn't meant as a solution, but rather as a way of showing that the MSGPACK_NO_BOOST
symbol is not defined as expected.
same for me
cmake -DCMAKE_CXX_FLAGS="-DMSGPACK_NO_BOOST"
could be workaround.
Essential fix is not yet.
According to the cmake document https://cmake.org/cmake/help/latest/command/add_library.html
add_library is defined as follows in up to date spec:
add_library(<name> INTERFACE [<source>...] [EXCLUDE_FROM_ALL])
I read the doucment but I didn't understand how it works.
Should the following line
TARGET_COMPILE_DEFINITIONS(msgpackc-cxx INTERFACE)
be
TARGET_COMPILE_DEFINITIONS(msgpackc-cxx MSGPACK_CXX11 MSGPACK_CXX14 MSGPACK_CXX17 ... MSGPACK_USE_BOOST ...)
?
What does parameters followed by INTERFACE mean?
[<source>...]
?
msgpack-c cmake minimum requirement is v3.1 https://github.com/msgpack/msgpack-c/blob/b4d800e6e4620df4197df4a955b1c959d0e9cb82/CMakeLists.txt#L1
v3.1add_library definition is something different https://cmake.org/cmake/help/v3.1/command/add_library.html
add_library(<name> INTERFACE [IMPORTED [GLOBAL]])
I got confused.
TARGET_COMPILE_DEFINITIONS(msgpackc-cxx MSGPACK_CXX11 MSGPACK_CXX14 MSGPACK_CXX17 ... MSGPACK_USE_BOOST ...)
This is wrong. I wrote cmake options as arguments. In @leocencetti example, it is C++ compiler option (macro definition by -D option). I got confuse more. I couldn't find corresponding document in cmake add_library manual...
Little by little, I'm understanding the essential issue.
The issue is:
How to reflect cmake sub project's compiler options to the parent cmake project.
How to reflect cmake sub project's compiler options to the parent cmake project.
I studied about that. I couldn't find a good way to do that.
In order to modify msgpack-c option, you need to define configuration macro as C++ compiler options instead of cmake options. The list of configuration macro is https://github.com/msgpack/msgpack-c/wiki/v2_0_cpp_configure (I updated)
So in this case, removing boost dependency, is cmake -DCMAKE_CXX_FLAGS="-DMSGPACK_NO_BOOST"
.
(-DCMAKE_USE_BOOST=OFF
is not requred. )
This is my current conclusion.
If there is a proper way to reflect cmake sub project's configured C++ compiler flags to the parent project, please let me know.
I asked this question to stackoverflow and got the answer. https://stackoverflow.com/questions/73229948/how-to-propagate-sub-projects-conditional-macro-definitions-to-parent-project/73240728#73240728 I just glanced the answer but I think that conditional reflection to the parent project can possible! I will try applying this approach to msgpack-c this weekend :)
Finally, I implemented #1028 Could you try this?
Fixed by #1028
Similar to #1005, there seems to be a dependency on
boost/predef/other/endian.h
when building withMSGPACK_USE_BOOST=OFF
.I have reproduced this issue on both Linux and Windows.
Minimal reproducible example: https://github.com/leocencetti/msgpack-c-issue-1025-example