From dcf1cbdd7cebfc5532855fd41252e356c2da2c3f Mon Sep 17 00:00:00 2001 From: Akash Munagala Date: Thu, 3 Jun 2021 08:52:12 -0700 Subject: [PATCH 1/4] Add visibility control --- CMakeLists.txt | 1 + include/srdfdom/model.h | 4 +++- include/srdfdom/visibility_control.h | 35 ++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 include/srdfdom/visibility_control.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 348085e..64e8676 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ install(PROGRAMS ) set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) +target_compile_definitions(${PROJECT_NAME} PRIVATE "SRDFDOM_BUILDING_DLL") if(BUILD_TESTING) find_package(ament_cmake_gtest REQUIRED) diff --git a/include/srdfdom/model.h b/include/srdfdom/model.h index 7c1a69d..985f07e 100644 --- a/include/srdfdom/model.h +++ b/include/srdfdom/model.h @@ -45,11 +45,13 @@ #include #include +#include "visibility_control.h" + /// Main namespace namespace srdf { /** \brief Representation of semantic information about the robot */ -class Model +class SRDFDOM_PUBLIC Model { public: Model() diff --git a/include/srdfdom/visibility_control.h b/include/srdfdom/visibility_control.h new file mode 100644 index 0000000..1062995 --- /dev/null +++ b/include/srdfdom/visibility_control.h @@ -0,0 +1,35 @@ +#ifndef SRDFDOM__VISIBILITY_CONTROL_H_ +#define SRDFDOM__VISIBILITY_CONTROL_H_ + +// This logic was borrowed (then namespaced) from the examples on the gcc wiki: +// https://gcc.gnu.org/wiki/Visibility + +#if defined _WIN32 || defined __CYGWIN__ + #ifdef __GNUC__ + #define SRDFDOM_EXPORT __attribute__ ((dllexport)) + #define SRDFDOM_IMPORT __attribute__ ((dllimport)) + #else + #define SRDFDOM_EXPORT __declspec(dllexport) + #define SRDFDOM_IMPORT __declspec(dllimport) + #endif + #ifdef SRDFDOM_BUILDING_DLL + #define SRDFDOM_PUBLIC SRDFDOM_EXPORT + #else + #define SRDFDOM_PUBLIC SRDFDOM_IMPORT + #endif + #define SRDFDOM_PUBLIC_TYPE SRDFDOM_PUBLIC + #define SRDFDOM_LOCAL +#else + #define SRDFDOM_EXPORT __attribute__ ((visibility("default"))) + #define SRDFDOM_IMPORT + #if __GNUC__ >= 4 + #define SRDFDOM_PUBLIC __attribute__ ((visibility("default"))) + #define SRDFDOM_LOCAL __attribute__ ((visibility("hidden"))) + #else + #define SRDFDOM_PUBLIC + #define SRDFDOM_LOCAL + #endif + #define SRDFDOM_PUBLIC_TYPE +#endif + +#endif // SRDFDOM__VISIBILITY_CONTROL_H_ From 2e69632e3c6ac6ff4af623cdb19171f7d47409e9 Mon Sep 17 00:00:00 2001 From: Akash Munagala Date: Thu, 3 Jun 2021 08:52:28 -0700 Subject: [PATCH 2/4] Add TinyXML2 to export dependencies --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64e8676..e53dde6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,4 +91,5 @@ ament_export_libraries(${PROJECT_NAME} ${TinyXML2_LIBRARIES}) ament_export_dependencies(console_bridge) ament_export_dependencies(urdfdom_headers) ament_export_dependencies(urdf) +ament_export_dependencies(TinyXML2) ament_package() From 562972fe5e1666bc4544401bd9dc9e5fd00f6a57 Mon Sep 17 00:00:00 2001 From: JafarAbdi Date: Thu, 24 Jun 2021 01:14:33 +0300 Subject: [PATCH 3/4] Run clang-format --- include/srdfdom/visibility_control.h | 48 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/include/srdfdom/visibility_control.h b/include/srdfdom/visibility_control.h index 1062995..2c46c73 100644 --- a/include/srdfdom/visibility_control.h +++ b/include/srdfdom/visibility_control.h @@ -5,31 +5,31 @@ // https://gcc.gnu.org/wiki/Visibility #if defined _WIN32 || defined __CYGWIN__ - #ifdef __GNUC__ - #define SRDFDOM_EXPORT __attribute__ ((dllexport)) - #define SRDFDOM_IMPORT __attribute__ ((dllimport)) - #else - #define SRDFDOM_EXPORT __declspec(dllexport) - #define SRDFDOM_IMPORT __declspec(dllimport) - #endif - #ifdef SRDFDOM_BUILDING_DLL - #define SRDFDOM_PUBLIC SRDFDOM_EXPORT - #else - #define SRDFDOM_PUBLIC SRDFDOM_IMPORT - #endif - #define SRDFDOM_PUBLIC_TYPE SRDFDOM_PUBLIC - #define SRDFDOM_LOCAL +#ifdef __GNUC__ +#define SRDFDOM_EXPORT __attribute__((dllexport)) +#define SRDFDOM_IMPORT __attribute__((dllimport)) #else - #define SRDFDOM_EXPORT __attribute__ ((visibility("default"))) - #define SRDFDOM_IMPORT - #if __GNUC__ >= 4 - #define SRDFDOM_PUBLIC __attribute__ ((visibility("default"))) - #define SRDFDOM_LOCAL __attribute__ ((visibility("hidden"))) - #else - #define SRDFDOM_PUBLIC - #define SRDFDOM_LOCAL - #endif - #define SRDFDOM_PUBLIC_TYPE +#define SRDFDOM_EXPORT __declspec(dllexport) +#define SRDFDOM_IMPORT __declspec(dllimport) +#endif +#ifdef SRDFDOM_BUILDING_DLL +#define SRDFDOM_PUBLIC SRDFDOM_EXPORT +#else +#define SRDFDOM_PUBLIC SRDFDOM_IMPORT +#endif +#define SRDFDOM_PUBLIC_TYPE SRDFDOM_PUBLIC +#define SRDFDOM_LOCAL +#else +#define SRDFDOM_EXPORT __attribute__((visibility("default"))) +#define SRDFDOM_IMPORT +#if __GNUC__ >= 4 +#define SRDFDOM_PUBLIC __attribute__((visibility("default"))) +#define SRDFDOM_LOCAL __attribute__((visibility("hidden"))) +#else +#define SRDFDOM_PUBLIC +#define SRDFDOM_LOCAL +#endif +#define SRDFDOM_PUBLIC_TYPE #endif #endif // SRDFDOM__VISIBILITY_CONTROL_H_ From 1e712ba8bee881eaf1adf497a16738e1af23a5b7 Mon Sep 17 00:00:00 2001 From: Akash Munagala Date: Thu, 24 Jun 2021 01:24:11 -0500 Subject: [PATCH 4/4] Install to bin folder too --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e53dde6..5cc4d11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,9 @@ ament_target_dependencies(${PROJECT_NAME} PUBLIC install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME} - DESTINATION lib + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin ) install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION include/${PROJECT_NAME}