Commit a2c0afd6 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

[CMake] use CMake Exports

parent c313a211
# Copyright 2010, 2019 JRL, CNRS/AIST, LAAS CNRS
# See LICENSE file.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
SET(PROJECT_ORG stack-of-tasks)
SET(PROJECT_NAME sot-core)
SET(PROJECT_DESCRIPTION "Hierarchical task solver plug-in for dynamic-graph.")
SET(PROJECT_URL "http://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
OPTION (BUILD_PYTHON_INTERFACE "Build the python binding" ON)
OPTION (INSTALL_PYTHON_INTERFACE_ONLY "Install *ONLY* the python binding" OFF)
OPTION(BUILD_PYTHON_INTERFACE "Build the python binding" ON)
OPTION(INSTALL_PYTHON_INTERFACE_ONLY "Install *ONLY* the python binding" OFF)
OPTION(SUFFIX_SO_VERSION
"Suffix shared library name by a string depending on git status of project"
ON)
IF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
# Export CMake Target
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
......@@ -37,14 +37,13 @@ IF(BUILD_PYTHON_INTERFACE)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
SET(PYTHON_INSTALL_DIR
${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/dynamic_graph/sot/core)
#ADD_PROJECT_DEPENDENCY(dynamic-graph-python 3.0.0 REQUIRED)
ADD_REQUIRED_DEPENDENCY(dynamic-graph-python 3.0.0 REQUIRED)
ADD_PROJECT_DEPENDENCY(dynamic-graph-python 3.0.0 REQUIRED PKG_CONFIG_REQUIRES "dynamic-graph-python >= 3.0.0")
ENDIF(BUILD_PYTHON_INTERFACE)
SET(BOOST_COMPONENTS
python filesystem system thread program_options unit_test_framework)
SEARCH_FOR_BOOST()
ADD_PROJECT_DEPENDENCY(Eigen3)
ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED PKG_CONFIG_REQUIRES eigen3)
SET(DOXYGEN_USE_MATHJAX YES)
......@@ -59,11 +58,11 @@ SET(PKG_CONFIG_ADDITIONAL_VARIABLES
# to avoid name collision when installing dynamic-graph in /usr.
SET(PLUGINDIR "${CMAKE_INSTALL_FULL_LIBDIR}/plugin")
IF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
# Extra macros for sot-core
install(FILES "src/sot-coreMacros.cmake"
DESTINATION "${CONFIG_INSTALL_DIR}")
ENDIF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
set(PACKAGE_EXTRA_MACROS "${PACKAGE_EXTRA_MACROS}
include(\"\${CMAKE_CURRENT_LIST_DIR}/sot-coreMacros.cmake\")")
......@@ -76,9 +75,8 @@ SET(BOOST_COMPONENTS
thread filesystem program_options
unit_test_framework system regex )
ADD_PROJECT_DEPENDENCY(dynamic-graph REQUIRED)
ADD_REQUIRED_DEPENDENCY ("pinocchio >= 2.2.1")
ADD_PROJECT_DEPENDENCY(dynamic-graph REQUIRED PKG_CONFIG_REQUIRES dynamic-graph)
ADD_PROJECT_DEPENDENCY(pinocchio 2.3.1 REQUIRED PKG_CONFIG_REQUIRES "pinocchio >= 2.3.1")
SEARCH_FOR_BOOST()
......@@ -99,20 +97,22 @@ IF(BUILD_PYTHON_INTERFACE)
TARGET_LINK_LIBRARIES(robot_utils_sot_py
${Boost_LIBRARIES}
${PYTHON_LIBRARIES} ${LIBRARY_NAME}
dynamic-graph::dynamic-graph)
PKG_CONFIG_USE_DEPENDENCY(robot_utils_sot_py pinocchio)
dynamic-graph::dynamic-graph
pinocchio::pinocchio
)
TARGET_INCLUDE_DIRECTORIES(robot_utils_sot_py PUBLIC pinocchio::pinocchio)
TARGET_LINK_BOOST_PYTHON(robot_utils_sot_py)
INSTALL(TARGETS robot_utils_sot_py DESTINATION ${PYTHON_INSTALL_DIR})
ENDIF(BUILD_PYTHON_INTERFACE)
# We do not want the project to be finalized if this is
# to install only the python interface.
IF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
SETUP_PROJECT_PACKAGE_FINALIZE()
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
list(SORT _variableNames)
foreach(_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
Subproject commit 4cbe0f40bbc995fd561687c1a67cbb944388c060
Subproject commit 4514454f5f9462047b5c29f61b6c3e0db731c416
# Copyright 2010, François Bleibel, Olivier Stasse, JRL, CNRS/AIST
# Verbosity level
IF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))
IF(NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))
ADD_DEFINITIONS(-DVP_DEBUG_MODE=${CMAKE_VERBOSITY_LEVEL} -DVP_DEBUG)
ENDIF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))
# The main include dir
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
#define DEBUG=2 if we're building in debug mode (what for?)
IF("${CMAKE_BUILD_TYPE}" STREQUAL DEBUG)
ADD_DEFINITIONS(-DDEBUG=2)
ENDIF ("${CMAKE_BUILD_TYPE}" STREQUAL DEBUG)
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL DEBUG)
IF(UNIX)
ADD_DEFINITIONS(-pthread)
......@@ -168,20 +165,13 @@ target_include_directories(${LIBRARY_NAME}
$<INSTALL_INTERFACE:include>
)
IF (${SUFFIX_SO_VERSION})
IF(SUFFIX_SO_VERSION)
SET_TARGET_PROPERTIES(${LIBRARY_NAME}
PROPERTIES
SOVERSION ${PROJECT_VERSION})
ENDIF()
target_link_libraries(${LIBRARY_NAME} dynamic-graph::dynamic-graph)
#PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} dynamic-graph)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} pinocchio)
#IF(BUILD_PYTHON_INTERFACE)
# PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} dynamic-graph-python)
#ENDIF(BUILD_PYTHON_INTERFACE)
target_link_libraries(${LIBRARY_NAME} dynamic-graph::dynamic-graph pinocchio::pinocchio ${Boost_LIBRARIES})
IF(UNIX)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${CMAKE_DL_LIBS})
......@@ -191,9 +181,7 @@ IF(UNIX AND NOT APPLE)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} pthread)
ENDIF(UNIX AND NOT APPLE)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES})
IF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
INSTALL(TARGETS ${LIBRARY_NAME}
EXPORT ${TARGETS_EXPORT_NAME}
PUBLIC_HEADER
......@@ -217,25 +205,23 @@ FOREACH(plugin ${plugins})
#remove the "lib" prefix from the plugin output name
SET_TARGET_PROPERTIES(${LIBRARY_NAME}
PROPERTIES
PREFIX "")
SET_TARGET_PROPERTIES(${LIBRARY_NAME}
PROPERTIES
PREFIX ""
INSTALL_RPATH ${PLUGINDIR}
)
IF (${SUFFIX_SO_VERSION})
IF(${SUFFIX_SO_VERSION})
SET_TARGET_PROPERTIES(${LIBRARY_NAME}
PROPERTIES
SOVERSION ${PROJECT_VERSION}
)
ENDIF()
# Link with sot-core library
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${SOTCORE_LIB_NAME})
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} dynamic-graph::dynamic-graph)
target_link_libraries(${LIBRARY_NAME}
${SOTCORE_LIB_NAME}
${Boost_LIBRARIES}
dynamic-graph::dynamic-graph
pinocchio::pinocchio)
ADD_DEPENDENCIES (${LIBRARY_NAME} ${SOTCORE_LIB_NAME})
ADD_DEPENDENCIES(${LIBRARY_NAME} ${SOTCORE_LIB_NAME})
IF(ADDITIONAL_${LIBRARY_NAME}_LIBS)
ADD_DEPENDENCIES(${LIBRARY_NAME} ${ADDITIONAL_${LIBRARY_NAME}_LIBS})
......@@ -247,9 +233,6 @@ FOREACH(plugin ${plugins})
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${CMAKE_DL_LIBS})
ENDIF(UNIX)
#PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} dynamic-graph)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} pinocchio)
# build python submodule
IF(BUILD_PYTHON_INTERFACE)
STRING(REPLACE - _ PYTHON_LIBRARY_NAME ${LIBRARY_NAME})
......@@ -268,7 +251,7 @@ FOREACH(plugin ${plugins})
LIBRARY DESTINATION ${PLUGINDIR}
)
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
ENDFOREACH(plugin)
IF(BUILD_PYTHON_INTERFACE)
......@@ -277,7 +260,7 @@ IF(BUILD_PYTHON_INTERFACE)
${NO_INSTALL_OF_INIT_PY})
# Install empty __init__.py files in intermediate directories.
INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/__init__.py
DESTINATION ${PYTHON_SITELIB}/dynamic_graph/sot
......
......@@ -79,7 +79,7 @@ SET(TEST_test_madgwick_ahrs_LIBS
#test paths and names (without .cpp extension)
SET (tests
SET(tests
dummy
control/test_control_pd
......@@ -153,7 +153,7 @@ FOREACH(test ${tests})
ADD_DEPENDENCIES (${EXECUTABLE_NAME} ${PROJECT_NAME})
IF( TEST_${EXECUTABLE_NAME}_INC )
PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} pinocchio)
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} pinocchio::pinocchio)
ENDIF(TEST_${EXECUTABLE_NAME}_INC)
IF( TEST_${EXECUTABLE_NAME}_LIBS )
......@@ -165,7 +165,7 @@ FOREACH(test ${tests})
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${TEST_${EXECUTABLE_NAME}_EXT_LIBS})
ENDIF( TEST_${EXECUTABLE_NAME}_EXT_LIBS )
IF (UNIX)
IF(UNIX)
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${CMAKE_DL_LIBS})
ENDIF(UNIX)
......@@ -179,7 +179,7 @@ FOREACH(test ${tests})
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${Boost_LIBRARIES} ${Boost_SYSTEM_LIBRARY})
ADD_TEST(${test} ${EXECUTABLE_NAME})
IF (UNIX)
IF(UNIX)
SET(EXTRA_LD_LIBRARY_PATH $ENV{LD_LIBRARY_PATH})
SET_PROPERTY(TEST ${test} PROPERTY
ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:${BOOST_ROOT}/lib:${EXTRA_LD_LIBRARY_PATH}")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment