Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow static library builds #64

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ 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 (BUILD_SHARED_LIBS)
set(URDFDOM_STATIC FALSE)
else()
set(URDFDOM_STATIC TRUE)
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)
Expand All @@ -34,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")

find_package(TinyXML REQUIRED)
include_directories(SYSTEM ${TinyXML_INCLUDE_DIRS})

Expand Down Expand Up @@ -83,6 +96,11 @@ 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)

add_subdirectory(urdf_parser_py)

message(STATUS "Configuration successful. Type make to compile urdfdom")
Expand Down
10 changes: 5 additions & 5 deletions urdf_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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")
14 changes: 14 additions & 0 deletions urdf_parser/include/urdf_parser/config.h.in
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions urdf_parser/include/urdf_parser/exportdecl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down