Merge pull request #4589 from sifmelcara/fix/dynamic-link-boost-test

Fix shared boost test library build by customizing main
This commit is contained in:
Alex Beregszaszi 2018-08-08 13:53:00 +01:00 committed by GitHub
commit fbc8443174
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -24,4 +24,8 @@ add_executable(soltest ${sources} ${headers}
)
target_link_libraries(soltest PRIVATE libsolc solidity lll evmasm devcore ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
if (NOT Boost_USE_STATIC_LIBS)
target_compile_definitions(soltest PUBLIC -DBOOST_TEST_DYN_LINK)
endif()
add_subdirectory(tools)

View File

@ -160,3 +160,18 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
return 0;
}
// BOOST_TEST_DYN_LINK should be defined if user want to link against shared boost test library
#ifdef BOOST_TEST_DYN_LINK
// Because we want to have customized initialization function and support shared boost libraries at the same time,
// we are forced to customize the entry point.
// see: https://www.boost.org/doc/libs/1_67_0/libs/test/doc/html/boost_test/adv_scenarios/shared_lib_customizations/init_func.html
int main(int argc, char* argv[])
{
auto init_unit_test = []() -> bool { init_unit_test_suite(0, nullptr); return true; };
return boost::unit_test::unit_test_main(init_unit_test, argc, argv);
}
#endif