From 3a37dc8ad62dcefa3f36a696d97e140d6eaedabe Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 16 Dec 2021 00:31:01 -0800 Subject: [PATCH] Set USE_DEFAULT_VISIBILITY_HIDDEN to true Use new ign-cmake option to hide symbols not explicitly marked as visible. This requires adding target_sources calls to fix linking errors in unit tests that use hidden symbols. Signed-off-by: Steve Peters --- CMakeLists.txt | 1 + src/CMakeLists.txt | 48 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27c1a6c0c..760051d79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,7 @@ if (BUILD_SDF) message (STATUS "----------------------------------------\n") + set(USE_DEFAULT_VISIBILITY_HIDDEN TRUE) ign_configure_build(QUIT_IF_BUILD_ERRORS) ign_create_packages() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b7b3fe81a..cf574e0df 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,32 +48,58 @@ if (BUILD_TESTING) ) endif() - if (TARGET UNIT_XmlUtils_TEST) - target_link_libraries(UNIT_XmlUtils_TEST - TINYXML2::TINYXML2) - endif() - if (TARGET UNIT_Converter_TEST) target_link_libraries(UNIT_Converter_TEST TINYXML2::TINYXML2) + target_sources(UNIT_Converter_TEST PRIVATE + Converter.cc + EmbeddedSdf.cc + XmlUtils.cc) endif() - if (TARGET UNIT_parser_urdf_TEST) + if (TARGET UNIT_FrameSemantics_TEST) + target_sources(UNIT_FrameSemantics_TEST PRIVATE FrameSemantics.cc) + endif() + + if (TARGET UNIT_ParamPassing_TEST) if (NOT USE_INTERNAL_URDF) - target_link_libraries(UNIT_parser_urdf_TEST + target_link_libraries(UNIT_ParamPassing_TEST IgnURDFDOM::IgnURDFDOM) endif() - target_link_libraries(UNIT_parser_urdf_TEST + target_link_libraries(UNIT_ParamPassing_TEST TINYXML2::TINYXML2) + target_sources(UNIT_ParamPassing_TEST PRIVATE + Converter.cc + EmbeddedSdf.cc + FrameSemantics.cc + ParamPassing.cc + SDFExtension.cc + XmlUtils.cc + parser.cc + parser_urdf.cc) endif() - if (TARGET UNIT_ParamPassing_TEST) + if (TARGET UNIT_Utils_TEST) + target_sources(UNIT_Utils_TEST PRIVATE Utils.cc) + endif() + + if (TARGET UNIT_XmlUtils_TEST) + target_link_libraries(UNIT_XmlUtils_TEST + TINYXML2::TINYXML2) + target_sources(UNIT_XmlUtils_TEST PRIVATE XmlUtils.cc) + endif() + + if (TARGET UNIT_parser_urdf_TEST) if (NOT USE_INTERNAL_URDF) - target_link_libraries(UNIT_ParamPassing_TEST + target_link_libraries(UNIT_parser_urdf_TEST IgnURDFDOM::IgnURDFDOM) endif() - target_link_libraries(UNIT_ParamPassing_TEST + target_link_libraries(UNIT_parser_urdf_TEST TINYXML2::TINYXML2) + target_sources(UNIT_parser_urdf_TEST PRIVATE + SDFExtension.cc + XmlUtils.cc + parser_urdf.cc) endif() endif()