From 72e61e508a74058fe74279b062e7abf637ba52b8 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Wed, 30 Sep 2015 15:58:48 -0400 Subject: [PATCH 1/3] Enable static library building --- CMakeLists.txt | 9 +++++++++ urdf_parser/CMakeLists.txt | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9596b145..2ea4b1d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,15 @@ if (HAS_VISIBILITY) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") endif() +# Using dynamic linking by default +option(BUILD_SHARED_LIBS "Build shared libraries" ON) + +# If building static libraries, set URDFDOM_STATIC definition for symbol +# visibility settings. +if (NOT BUILD_SHARED_LIBS) + add_definitions(-DURDFDOM_STATIC) +endif() + # This shouldn't be necessary, but there has been trouble # with MSVC being set off, but MSVCXX ON. if(MSVC OR MSVC90 OR MSVC10) diff --git a/urdf_parser/CMakeLists.txt b/urdf_parser/CMakeLists.txt index 1058d220..a20a0c0a 100644 --- a/urdf_parser/CMakeLists.txt +++ b/urdf_parser/CMakeLists.txt @@ -1,18 +1,18 @@ include_directories(include) -add_library(urdfdom_world SHARED src/pose.cpp src/model.cpp src/link.cpp src/joint.cpp src/world.cpp) +add_library(urdfdom_world src/pose.cpp src/model.cpp src/link.cpp src/joint.cpp src/world.cpp) target_link_libraries(urdfdom_world ${tinyxml_libraries} ${console_bridge_LIBRARIES} ${Boost_LIBRARIES}) set_target_properties(urdfdom_world PROPERTIES SOVERSION 0.3) -add_library(urdfdom_model SHARED src/pose.cpp src/model.cpp src/link.cpp src/joint.cpp) +add_library(urdfdom_model src/pose.cpp src/model.cpp src/link.cpp src/joint.cpp) target_link_libraries(urdfdom_model ${tinyxml_libraries} ${console_bridge_LIBRARIES} ${Boost_LIBRARIES}) set_target_properties(urdfdom_model PROPERTIES SOVERSION 0.3) -add_library(urdfdom_sensor SHARED src/urdf_sensor.cpp) +add_library(urdfdom_sensor src/urdf_sensor.cpp) target_link_libraries(urdfdom_sensor urdfdom_model ${tinyxml_libraries} ${console_bridge_LIBRARIES} ${Boost_LIBRARIES}) set_target_properties(urdfdom_sensor PROPERTIES SOVERSION 0.3) -add_library(urdfdom_model_state SHARED src/urdf_model_state.cpp src/twist.cpp) +add_library(urdfdom_model_state src/urdf_model_state.cpp src/twist.cpp) target_link_libraries(urdfdom_model_state ${tinyxml_libraries} ${console_bridge_LIBRARIES} ${Boost_LIBRARIES}) set_target_properties(urdfdom_model_state PROPERTIES SOVERSION 0.3) From e40bcd84c2cd9e7ff9a400e90096506c4a843478 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Thu, 1 Oct 2015 01:08:49 -0400 Subject: [PATCH 2/3] Add config.h to pass URDFDOM_STATIC definition to client libraries --- CMakeLists.txt | 15 ++++++++++++++- urdf_parser/CMakeLists.txt | 2 +- urdf_parser/include/urdf_parser/config.h.in | 14 ++++++++++++++ urdf_parser/include/urdf_parser/exportdecl.h | 2 ++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 urdf_parser/include/urdf_parser/config.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ea4b1d4..fef47776 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,9 @@ option(BUILD_SHARED_LIBS "Build shared libraries" ON) # If building static libraries, set URDFDOM_STATIC definition for symbol # visibility settings. if (NOT BUILD_SHARED_LIBS) - add_definitions(-DURDFDOM_STATIC) + set(URDFDOM_STATIC TRUE) +else() + set(URDFDOM_STATIC FALSE) endif() # This shouldn't be necessary, but there has been trouble @@ -43,6 +45,8 @@ endif (MSVC OR MSVC90 OR MSVC10) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include_directories("${CMAKE_CURRENT_BINARY_DIR}/urdf_parser/include/urdf_parser") + include(SearchForTinyXML) include_directories(${tinyxml_include_dirs}) link_directories(${tinyxml_library_dirs}) @@ -82,6 +86,15 @@ if (NOT MSVC) DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/ COMPONENT pkgconfig) endif() +set(config_file "urdf_parser/include/urdf_parser/config.h") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${config_file}.in" "${CMAKE_CURRENT_BINARY_DIR}/${config_file}" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${config_file}" + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/urdf_parser/ COMPONENT headers) + +message(STATUS "CMAKE_INSTALL_INCLUDEDIR: ${CMAKE_INSTALL_INCLUDEDIR}") +message(STATUS "CMAKE_INSTALL_DATAROOTDIR: ${CMAKE_INSTALL_DATAROOTDIR}") +message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") + add_subdirectory(urdf_parser_py) message(STATUS "Configuration successful. Type make to compile urdfdom") diff --git a/urdf_parser/CMakeLists.txt b/urdf_parser/CMakeLists.txt index a20a0c0a..66cecb7d 100644 --- a/urdf_parser/CMakeLists.txt +++ b/urdf_parser/CMakeLists.txt @@ -39,4 +39,4 @@ INSTALL(TARGETS check_urdf urdf_to_graphiz urdf_mem_test DESTINATION ${CMAKE_INSTALL_BINDIR}) INSTALL(TARGETS urdfdom_sensor DESTINATION ${CMAKE_INSTALL_LIBDIR}) INSTALL(TARGETS urdfdom_model_state DESTINATION ${CMAKE_INSTALL_LIBDIR}) -INSTALL(DIRECTORY include/urdf_parser DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +INSTALL(DIRECTORY include/urdf_parser DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h") diff --git a/urdf_parser/include/urdf_parser/config.h.in b/urdf_parser/include/urdf_parser/config.h.in new file mode 100644 index 00000000..c4513405 --- /dev/null +++ b/urdf_parser/include/urdf_parser/config.h.in @@ -0,0 +1,14 @@ +/* config.h. Generated by CMake for @PROJECT_NAME@. */ +#ifndef URDF_PARSER_CONFIG_H +#define URDF_PARSER_CONFIG_H + +/* Version number */ +#define URDF_MAJOR_VERSION @URDF_MAJOR_VERSION@ +#define URDF_MINOR_VERSION @URDF_MINOR_VERSION@ +#define URDF_PATCH_VERSION @URDF_PATCH_VERSION@ +#define URDF_VERSION "@URDF_VERSION@" + +#cmakedefine URDFDOM_STATIC 1 + +#endif // #ifndef URDF_PARSER_CONFIG_H + diff --git a/urdf_parser/include/urdf_parser/exportdecl.h b/urdf_parser/include/urdf_parser/exportdecl.h index af8a23be..6d0b9e71 100644 --- a/urdf_parser/include/urdf_parser/exportdecl.h +++ b/urdf_parser/include/urdf_parser/exportdecl.h @@ -37,6 +37,8 @@ #ifndef URDFDOM_EXPORTDECL_H # define URDFDOM_EXPORTDECL_H +#include "config.h" + // Handle portable symbol export. // Defining manually which symbol should be exported is required // under Windows whether MinGW or MSVC is used. From 25d4010f995e8487fc4722e0fcc5baa075696728 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Thu, 1 Oct 2015 01:11:24 -0400 Subject: [PATCH 3/3] Remove unintended lines in CMakeLists.txt and modify logic of setting URDFDOM_STATIC definition --- CMakeLists.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fef47776..8f7b71f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,10 +31,10 @@ option(BUILD_SHARED_LIBS "Build shared libraries" ON) # If building static libraries, set URDFDOM_STATIC definition for symbol # visibility settings. -if (NOT BUILD_SHARED_LIBS) - set(URDFDOM_STATIC TRUE) -else() +if (BUILD_SHARED_LIBS) set(URDFDOM_STATIC FALSE) +else() + set(URDFDOM_STATIC TRUE) endif() # This shouldn't be necessary, but there has been trouble @@ -91,10 +91,6 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${config_file}.in" "${CMAKE_CURRENT_ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${config_file}" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/urdf_parser/ COMPONENT headers) -message(STATUS "CMAKE_INSTALL_INCLUDEDIR: ${CMAKE_INSTALL_INCLUDEDIR}") -message(STATUS "CMAKE_INSTALL_DATAROOTDIR: ${CMAKE_INSTALL_DATAROOTDIR}") -message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") - add_subdirectory(urdf_parser_py) message(STATUS "Configuration successful. Type make to compile urdfdom")