msgpack / msgpack-c

MessagePack implementation for C and C++ / msgpack.org[C/C++]
Other
3.01k stars 875 forks source link

Specify boost components in find_package #978

Closed ysc3839 closed 3 years ago

ysc3839 commented 3 years ago

When using vcpkg to install boost, it install all boost components, including components that require building. If we specify boost components in find_package, we can prevent building boost components.

redboltz commented 3 years ago

It seems that it is not a msgpack-c issue.

ysc3839 commented 3 years ago

Yes, it's vcpkg's issue because it doesn't have a "all boost headers" package. If we know what components are used, we can install only used components.

redboltz commented 3 years ago

msgpack-c is a header only library. And it uses only header-only part of the Boost Libraries. So you don't need to install any Boost library file e.g. .a .so .lib .dll The Boost.Test is used only for testing.

redboltz commented 3 years ago

Here are boost types that is supported by msgpack-c https://github.com/msgpack/msgpack-c/tree/cpp_master/include/msgpack/adaptor/boost

ysc3839 commented 3 years ago

I know msgpack-c uses only header-only part of boost. The problem is, when using vcpkg install boost to install boost, all boost components will be installed, including those not used by msgpack-c. If you specify what boost components are used in find_package, for example: FIND_PACKAGE (Boost REQUIRED COMPONENTS preprocessor), then you can use vcpkg install boost-preprocessor to install only this component.

redboltz commented 3 years ago

Thanks. I personally don't use vcpkg. But you can send a pull request. It is welcome :)

redboltz commented 3 years ago

I've checked cmake source code: https://github.com/Kitware/CMake/blob/master/Modules/FindBoost.cmake#L1013-L1372

There is no header only library name. e.g.) preprosessor. So I can't add FIND_PACKAGE (Boost REQUIRED COMPONENTS preprocessor) as you mentioned. It causes cmake error.

redboltz commented 3 years ago

I think that you can git clone or download boost and then add include directory to your include path. See https://www.boost.org/doc/libs/1_77_0/more/getting_started/windows.html#header-only-libraries

Also I recommend that creating an issue for vcpkg.

redboltz commented 3 years ago

header files

component link
assert https://github.com/boostorg/assert
numeric_conversion https://github.com/boostorg/numeric_conversion
variant https://github.com/boostorg/variant
utility (string_ref, string_view) https://github.com/boostorg/utility
fusion https://github.com/boostorg/fusion
optional https://github.com/boostorg/optional
predef https://github.com/boostorg/predef
preprosessor https://github.com/boostorg/preprocessor

MSGPACK_USE_X3_PARSE is defined

component link
spirit(x3) https://github.com/boostorg/spirit

library files (only for tests)

MSGPACK_BUILD_TESTS is defined

component link
test https://github.com/boostorg/test

This is specified as follows:

FIND_PACKAGE (Boost REQUIRED COMPONENTS unit_test_framework system)
redboltz commented 3 years ago

I've just checked https://vcpkg.io/en/packages.html. Maybe now you can use vcpkg as follows:

vcpkg install boost-assert boost-numeric-conversion boost-variant boost-utility boost-fusion boost-optional boost-predef boost-preprosessor

Be careful numeric_conversion's vcpkg is numeric-conversion.

I misunderstood that cmake find package and vcpkg are related. But it seems that it is completely different.

ysc3839 commented 3 years ago

Sorry, I didn't test carefully before. It's not cmake reporting error, actually it's a compiler error. cmake can find boost correctly without specifying boost components in find_package. Just install other missing packages resolve the issue. Sorry again for my mistake, and thank you for helping resolve the issue!