diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-08-08 20:53:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-08 20:53:00 +0800 |
commit | fbc844317446adcc0c0e4772d5c20befdc9d2770 (patch) | |
tree | ed43383a884bc50440937a43d59cb3b778b4f26d /test | |
parent | 22461ca939fdd1f1bdeb879704e3c0c7628e8571 (diff) | |
parent | 9d11557dc90bd519f0c7e2c134da90d9edb315e0 (diff) | |
download | dexon-solidity-fbc844317446adcc0c0e4772d5c20befdc9d2770.tar.gz dexon-solidity-fbc844317446adcc0c0e4772d5c20befdc9d2770.tar.zst dexon-solidity-fbc844317446adcc0c0e4772d5c20befdc9d2770.zip |
Merge pull request #4589 from sifmelcara/fix/dynamic-link-boost-test
Fix shared boost test library build by customizing main
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 4 | ||||
-rw-r--r-- | test/boostTest.cpp | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 522856cc..701d53e5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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) diff --git a/test/boostTest.cpp b/test/boostTest.cpp index cef3b06f..d9e939eb 100644 --- a/test/boostTest.cpp +++ b/test/boostTest.cpp @@ -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 |