Skip to content

Commit

Permalink
Merge pull request #5 from pariterre/master
Browse files Browse the repository at this point in the history
Improved the cmake config file and made math back end selection nicer
  • Loading branch information
pariterre authored Mar 16, 2020
2 parents e5ffae2 + 85d809f commit 8f161a2
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 2 deletions.
32 changes: 30 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,28 @@ IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
ENDIF()

# Choose the math's library backend to use
set(MATH_LIBRARY_BACKEND Eigen3 CACHE STRING "Choose the backend library for the linear algebra.")
# Set the possible values of build type for cmake-gui
set_property(CACHE MATH_LIBRARY_BACKEND PROPERTY STRINGS "Eigen3" "Simple" "Casadi")

OPTION (RBDL_BUILD_STATIC "Build statically linked library (otherwise dynamiclly linked)" ${RBDL_BUILD_STATIC_DEFAULT})
OPTION (RBDL_BUILD_TESTS "Build the test executables" OFF)
OPTION (RBDL_ENABLE_LOGGING "Enable logging (warning: major impact on performance!)" OFF)
OPTION (RBDL_USE_SIMPLE_MATH "Use slow math instead of the fast Eigen3 library (faster compilation)" OFF)
OPTION (RBDL_USE_CASADI_MATH "Use automatic differentiation Casadi library" OFF)
option (RBDL_USE_EIGEN3_MATH "Use Eigen library" ON)
if(${MATH_LIBRARY_BACKEND} STREQUAL "Eigen3")
set (RBDL_USE_EIGEN3_MATH ON)
set (RBDL_USE_SIMPLE_MATH OFF)
set (RBDL_USE_CASADI_MATH OFF)
elseif(${MATH_LIBRARY_BACKEND} STREQUAL "Casadi")
set (RBDL_USE_EIGEN3_MATH OFF)
set (RBDL_USE_SIMPLE_MATH OFF)
set (RBDL_USE_CASADI_MATH ON)
elseif(${MATH_LIBRARY_BACKEND} STREQUAL "Simple")
set (RBDL_USE_EIGEN3_MATH OFF)
set (RBDL_USE_SIMPLE_MATH ON)
set (RBDL_USE_CASADI_MATH OFF)
endif()
OPTION (RBDL_STORE_VERSION "Enable storing of version information in the library (requires build from valid repository)" OFF)
OPTION (RBDL_BUILD_ADDON_URDFREADER "Build the (experimental) urdf reader" OFF)
OPTION (RBDL_BUILD_ADDON_BENCHMARK "Build the benchmarking tool" OFF)
Expand Down Expand Up @@ -232,6 +247,19 @@ INSTALL (
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)

# Prepare share
message(${CMAKE_INSTALL_INCLUDEDIR})
include(CMakePackageConfigHelpers)
configure_package_config_file(
share/RBDLConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/RBDLConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/rbdl/cmake
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/RBDLConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/rbdl/cmake
)

# Packaging
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Martin Felis <[email protected]>")
Expand Down
70 changes: 70 additions & 0 deletions share/FindRBDL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Searches for RBDL includes and library files
#
# Sets the variables
# RBDL_FOUND
# RBDL_INCLUDE_DIR
# RBDL_LIBRARIES

SET (RBDL_FOUND FALSE)

FIND_PATH (RBDL_INCLUDE_DIR rbdl.h
/usr/include
/usr/include/rbdl
/usr/local/include
/usr/local/include/rbdl
$ENV{HOME}/local/include
$ENV{HOME}/local/include/rbdl
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_INSTALL_PREFIX}/include/rbdl
$ENV{RBDL_PATH}/src
$ENV{RBDL_PATH}/include
$ENV{RBDL_PATH}/include/rbdl
$ENV{RBDL_INCLUDE_PATH}
)
FIND_LIBRARY (RBDL_LIBRARY NAMES rbdl PATHS
/usr/lib
/usr/local/lib
/usr/local/lib64
${CMAKE_INSTALL_PREFIX}
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64
$ENV{HOME}/local/lib
$ENV{HOME}/local/lib64
$ENV{RBDL_PATH}
$ENV{RBDL_LIBRARY_PATH}
)

# FIND_LIBRARY (RBDL_LUAMODEL_LIBRARY NAMES rbdl_luamodel PATHS
# /usr/lib
# /usr/local/lib
# $ENV{HOME}/local/lib
# $ENV{RBDL_PATH}
# $ENV{RBDL_LIBRARY_PATH}
# )

IF (RBDL_INCLUDE_DIR AND RBDL_LIBRARY)
SET (RBDL_FOUND TRUE)
ENDIF (RBDL_INCLUDE_DIR AND RBDL_LIBRARY)

# IF (RBDL_LIBRARY AND RBDL_LUAMODEL_LIBRARY)
# SET (RBDL_LIBRARIES ${RBDL_LIBRARY} ${RBDL_LUAMODEL_LIBRARY})
# ELSE (RBDL_LIBRARY AND RBDL_LUAMODEL_LIBRARY)
# SET (RBDL_LIBRARIES ${RBDL_LIBRARY})
# ENDIF(RBDL_LIBRARY AND RBDL_LUAMODEL_LIBRARY)

IF (RBDL_FOUND)
IF (NOT RBDL_FIND_QUIETLY)
MESSAGE(STATUS "Found RBDL: ${RBDL_LIBRARY}")
ENDIF (NOT RBDL_FIND_QUIETLY)
ELSE (RBDL_FOUND)
IF (RBDL_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find RBDL")
ENDIF (RBDL_FIND_REQUIRED)
ENDIF (RBDL_FOUND)

MARK_AS_ADVANCED (
RBDL_FOUND
RBDL_INCLUDE_DIR
RBDL_LIBRARIES
RBDL_LIBRARY_PATH
)
63 changes: 63 additions & 0 deletions share/RBDLConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
set(RBDL_VERSION @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@)

FIND_PATH (RBDL_INCLUDE_DIR rbdl.h
/usr/include
/usr/include/rbdl
/usr/local/include
/usr/local/include/rbdl
$ENV{HOME}/local/include
$ENV{HOME}/local/include/rbdl
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_INSTALL_PREFIX}/include/rbdl
$ENV{RBDL_PATH}/src
$ENV{RBDL_PATH}/include
$ENV{RBDL_PATH}/include/rbdl
$ENV{RBDL_INCLUDE_PATH}
)
FIND_LIBRARY (RBDL_LIBRARY NAMES rbdl PATHS
/usr/lib
/usr/local/lib
/usr/local/lib64
${CMAKE_INSTALL_PREFIX}
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64
$ENV{HOME}/local/lib
$ENV{HOME}/local/lib64
$ENV{RBDL_PATH}
$ENV{RBDL_LIBRARY_PATH}
)

# FIND_LIBRARY (RBDL_LUAMODEL_LIBRARY NAMES rbdl_luamodel PATHS
# /usr/lib
# /usr/local/lib
# $ENV{HOME}/local/lib
# $ENV{RBDL_PATH}
# $ENV{RBDL_LIBRARY_PATH}
# )

IF (RBDL_INCLUDE_DIR AND RBDL_LIBRARY)
SET (RBDL_FOUND TRUE)
ENDIF (RBDL_INCLUDE_DIR AND RBDL_LIBRARY)

# IF (RBDL_LIBRARY AND RBDL_LUAMODEL_LIBRARY)
# SET (RBDL_LIBRARIES ${RBDL_LIBRARY} ${RBDL_LUAMODEL_LIBRARY})
# ELSE (RBDL_LIBRARY AND RBDL_LUAMODEL_LIBRARY)
# SET (RBDL_LIBRARIES ${RBDL_LIBRARY})
# ENDIF(RBDL_LIBRARY AND RBDL_LUAMODEL_LIBRARY)

IF (RBDL_FOUND)
IF (NOT RBDL_FIND_QUIETLY)
MESSAGE(STATUS "Found RBDL: ${RBDL_LIBRARY}")
ENDIF (NOT RBDL_FIND_QUIETLY)
ELSE (RBDL_FOUND)
IF (RBDL_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find RBDL")
ENDIF (RBDL_FIND_REQUIRED)
ENDIF (RBDL_FOUND)

MARK_AS_ADVANCED (
RBDL_FOUND
RBDL_INCLUDE_DIR
RBDL_LIBRARIES
RBDL_LIBRARY_PATH
)

0 comments on commit 8f161a2

Please sign in to comment.