From 22c5dde7b48b0037e106e7901b0611ccd506ae5e Mon Sep 17 00:00:00 2001 From: Konstantinos Chatzilygeroudis Date: Wed, 26 Jul 2023 00:04:05 +0300 Subject: [PATCH] Do not export symbols when building static libs Closes #101 --- src/RBDyn/CMakeLists.txt | 6 +++++- src/parsers/CMakeLists.txt | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/RBDyn/CMakeLists.txt b/src/RBDyn/CMakeLists.txt index 07553998..3dde7d36 100644 --- a/src/RBDyn/CMakeLists.txt +++ b/src/RBDyn/CMakeLists.txt @@ -53,7 +53,11 @@ target_include_directories( $ $) target_link_libraries(RBDyn PUBLIC SpaceVecAlg::SpaceVecAlg) -set_target_properties(RBDyn PROPERTIES COMPILE_FLAGS "-Drbdyn_EXPORTS") +if(BUILD_SHARED_LIBS) + set_target_properties(RBDyn PROPERTIES COMPILE_FLAGS "-Drbdyn_EXPORTS") +else() + target_compile_definitions(RBDyn PUBLIC "-DRBDYN_STATIC") +endif() set_target_properties(RBDyn PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} VERSION ${PROJECT_VERSION}) set_target_properties(RBDyn PROPERTIES CXX_STANDARD 11) diff --git a/src/parsers/CMakeLists.txt b/src/parsers/CMakeLists.txt index 58bc457b..e2103a91 100644 --- a/src/parsers/CMakeLists.txt +++ b/src/parsers/CMakeLists.txt @@ -15,8 +15,12 @@ target_include_directories( $) target_link_libraries(RBDynParsers PUBLIC RBDyn tinyxml2::tinyxml2 yaml-cpp Boost::boost) -set_target_properties(RBDynParsers PROPERTIES COMPILE_FLAGS - "-DRBDYN_PARSERS_EXPORTS") +if(BUILD_SHARED_LIBS) + set_target_properties(RBDynParsers PROPERTIES COMPILE_FLAGS + "-DRBDYN_PARSERS_EXPORTS") +else() + target_compile_definitions(RBDynParsers PUBLIC "-DRBDYN_PARSERS_STATIC") +endif() set_target_properties(RBDynParsers PROPERTIES CXX_STANDARD 11) set_target_properties(RBDynParsers PROPERTIES EXPORT_NAME Parsers) set_target_properties(RBDynParsers PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}