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

Honor BUILD_SHARED_LIBS #91

Merged
Merged
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
26 changes: 25 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

cmake_minimum_required(VERSION 3.1.3)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(PROJECT_NAME RBDyn)
Expand All @@ -15,16 +16,39 @@ set(PROJECT_USE_CMAKE_EXPORT TRUE)

option(BUILD_RBDYN_PARSERS "Build URDF and YAML parsers" ON)

if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif()

include(cmake/base.cmake)
include(cmake/cython/cython.cmake)
include(cmake/msvc-specific.cmake)

project(RBDyn CXX)
project(RBDyn LANGUAGES C CXX VERSION "${PROJECT_VERSION}")

option(BENCHMARKS "Generate benchmarks." OFF)

add_project_dependency(SpaceVecAlg REQUIRED NO_MODULE)

if(BUILD_RBDYN_PARSERS)
add_project_dependency(yaml-cpp 0.5.0 REQUIRED NO_MODULE)

find_package(tinyxml2 QUIET NO_MODULE)
if(NOT ${tinyxml2_FOUND})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/CMakeModules")
find_package(RBDyn_TinyXML2 REQUIRED)
install(FILES "${PROJECT_SOURCE_DIR}/CMakeModules/FindRBDyn_TinyXML2.cmake"
DESTINATION "${CONFIG_INSTALL_DIR}")
set(PACKAGE_EXTRA_MACROS "include(\${CMAKE_CURRENT_LIST_DIR}/FindRBDyn_TinyXML2.cmake)" CACHE INTERNAL "")
else()
add_project_dependency(tinyxml2 REQUIRED NO_MODULE)
endif()

# Note: technically we don't need system but it is likely to be here and
# CMake <= 3.5.0 needs at least one component to define Boost::boost
add_project_dependency(Boost REQUIRED COMPONENTS system)
endif()

# For MSVC, set local environment variable to enable finding the built dll
# of the main library when launching ctest with RUN_TESTS
if(MSVC)
Expand Down
7 changes: 6 additions & 1 deletion binding/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
set(RBDYN_BINDINGS_MODULES rbdyn.rbdyn)
set(RBDYN_BINDINGS_EXPORT_SOURCES rbdyn/c_rbdyn.pxd rbdyn/rbdyn.pxd rbdyn/__init__.py)
set(RBDYN_BINDINGS_PRIVATE_SOURCES include/rbdyn_wrapper.hpp rbdyn/rbdyn.pyx rbdyn/c_rbdyn_private.pxd tests/test_rbdyn_pickle.py)
set(RBDYN_BINDINGS_TARGETS RBDyn)

if(${BUILD_RBDYN_PARSERS})
list(APPEND RBDYN_BINDINGS_MODULES rbdyn.parsers.parsers)
list(APPEND RBDYN_BINDINGS_EXPORT_SOURCES rbdyn/parsers/c_parsers.pxd rbdyn/parsers/parsers.pxd rbdyn/parsers/__init__.py)
list(APPEND RBDYN_BINDINGS_PRIVATE_SOURCES include/rbdyn_parsers_wrapper.hpp rbdyn/parsers/parsers.pyx rbdyn/parsers/c_parsers_private.pxd tests/test_rbdyn_parsers.py)
list(APPEND RBDYN_BINDINGS_TARGETS RBDyn::Parsers)
if(NOT BUILD_SHARED_LIBS)
list(APPEND RBDYN_BINDINGS_TARGETS yaml-cpp tinyxml2::tinyxml2)
endif()
endif()

ADD_CYTHON_BINDINGS(rbdyn
TARGETS RBDyn RBDyn::Parsers
TARGETS ${RBDYN_BINDINGS_TARGETS}
MODULES ${RBDYN_BINDINGS_MODULES}
EXPORT_SOURCES ${RBDYN_BINDINGS_EXPORT_SOURCES}
PRIVATE_SOURCES ${RBDYN_BINDINGS_PRIVATE_SOURCES}
Expand Down
6 changes: 3 additions & 3 deletions debian/librbdyn-dev.install
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
usr/include/*
usr/lib/libRBDyn.so
usr/lib/libRBDynParsers.so
usr/lib/*/libRBDyn.so
usr/lib/*/libRBDynParsers.so
usr/lib/*/pkgconfig/*
usr/lib/cmake/*
usr/lib/*/cmake/*
4 changes: 2 additions & 2 deletions debian/librbdyn1.install
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
usr/lib/libRBDyn.so.1*
usr/lib/libRBDynParsers.so.1*
usr/lib/*/libRBDyn.so.1*
usr/lib/*/libRBDynParsers.so.1*
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#

add_subdirectory(RBDyn)
if(${BUILD_RBDYN_PARSERS})
if(BUILD_RBDYN_PARSERS)
add_subdirectory(parsers)
endif()
8 changes: 4 additions & 4 deletions src/RBDyn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(HEADERS RBDyn/Body.h RBDyn/Joint.h RBDyn/MultiBodyGraph.h RBDyn/MultiBody.h
RBDyn/FK.h RBDyn/FV.h RBDyn/FA.h RBDyn/Jacobian.h RBDyn/ID.h RBDyn/IK.h RBDyn/IS.h RBDyn/FD.h RBDyn/EulerIntegration.h RBDyn/CoM.h
RBDyn/Momentum.h RBDyn/ZMP.h RBDyn/IDIM.h RBDyn/VisServo.h RBDyn/util.hh RBDyn/util.hxx RBDyn/Coriolis.h)

add_library(RBDyn SHARED ${SOURCES} ${HEADERS})
add_library(RBDyn ${SOURCES} ${HEADERS})
target_include_directories(RBDyn PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include> $<INSTALL_INTERFACE:include>)
target_link_libraries(RBDyn PUBLIC SpaceVecAlg::SpaceVecAlg)
set_target_properties(RBDyn PROPERTIES COMPILE_FLAGS "-Drbdyn_EXPORTS")
Expand All @@ -19,8 +19,8 @@ set_target_properties(RBDyn PROPERTIES CXX_STANDARD 11)
install(
TARGETS RBDyn
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib"
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
install(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DESTINATION})
31 changes: 7 additions & 24 deletions src/parsers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,10 @@
# Copyright 2012-2019 CNRS-UM LIRMM, CNRS-AIST JRL
#

add_project_dependency(yaml-cpp 0.5.0 REQUIRED NO_MODULE)

find_package(tinyxml2 QUIET NO_MODULE)
if(NOT ${tinyxml2_FOUND})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/CMakeModules")
find_package(RBDyn_TinyXML2 REQUIRED)
install(FILES "${PROJECT_SOURCE_DIR}/CMakeModules/FindRBDyn_TinyXML2.cmake"
DESTINATION "${CONFIG_INSTALL_DIR}")
set(PACKAGE_EXTRA_MACROS "include(\${CMAKE_CURRENT_LIST_DIR}/FindRBDyn_TinyXML2.cmake)" CACHE INTERNAL "")
else()
add_project_dependency(tinyxml2 REQUIRED NO_MODULE)
endif()

# Note: technically we don't need system but it is likely to be here and
# CMake <= 3.5.0 needs at least one component to define Boost::boost
add_project_dependency(Boost REQUIRED COMPONENTS system)

set(SOURCES common.cpp urdf.cpp to_urdf.cpp yaml.cpp to_yaml.cpp)
set(HEADERS RBDyn/parsers/api.h RBDyn/parsers/common.h RBDyn/parsers/urdf.h RBDyn/parsers/yaml.h)

add_library(RBDynParsers SHARED ${SOURCES} ${HEADERS})
add_library(RBDynParsers ${SOURCES} ${HEADERS})
add_library(RBDyn::Parsers ALIAS RBDynParsers)
target_include_directories(RBDynParsers PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include> $<INSTALL_INTERFACE:include>)
target_link_libraries(RBDynParsers PUBLIC RBDyn tinyxml2::tinyxml2 yaml-cpp Boost::boost)
Expand All @@ -34,9 +17,9 @@ set_target_properties(RBDynParsers PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}
install(
TARGETS RBDynParsers
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib"
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
install(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DESTINATION}/parsers)

Expand All @@ -46,7 +29,7 @@ target_link_libraries(urdf_yaml_converter PUBLIC RBDyn::Parsers)

install(
TARGETS urdf_yaml_converter
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib"
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)