Orphis / boost-cmake

Easy Boost integration in CMake projects
Other
398 stars 150 forks source link

Add option to support building boost dynamic library #83

Open Char-Aznable opened 5 years ago

Char-Aznable commented 5 years ago

I have a usage case where I need to link my app against Boost::unit_test_framework dynamic library with BOOST_TEST_DYN_LINK defined. It seems boost-cmake only builds boost static libraries which causes the error in my use case:

ld: CMakeFiles/mytest.dir/test.cpp.o: in function `main':
test.cpp:(.text+0xad3): undefined reference to `boost::unit_test::unit_test_main(bool (*)(), int, char**)'

I suggest boost-cmake should have an option to allow the users to use either dynamic or static boost libraries

Char-Aznable commented 5 years ago

Here's the documentation of boost.Test dynamic library usage: https://www.boost.org/doc/libs/1_70_0/libs/test/doc/html/boost_test/adv_scenarios/shared_lib_customizations.html

Orphis commented 5 years ago

Dynamic libraries can cause a lot of issues. Why isn't it acceptable for you to link against the static version?

Char-Aznable commented 5 years ago

Huge project, complicated dependency, not an option

Orphis commented 5 years ago

It shouldn't be complicated to fix it to accept static libraries there though if you really want to use those build scripts.

But if you insist on going with the dynamic libraries route, it's very unlikely to be ever supported here and you should probably use the official Boost distribution instead and maybe try their own new CMake build files.

Char-Aznable commented 5 years ago

No, it's rather labor intensive. The Boost.Test entry point is different for dynamic vs static lib, which means that I have manually change thousands of lines of code written by different people with tons of macros all over the place.

Just curious, what is the trouble for supported dynamic lib?

Orphis commented 5 years ago

It can be automated with CMake and some other tooling too. Supporting dynamic builds means I'd have to double the test coverage and add it for each library.

In general, there are issues with using shared libraries on all platforms, so it's always safer to use static builds.