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

[CMake] clean: keep minimal required instructions

parent f90d9096
# Copyright 2018, Gepetto team, LAAS-CNRS
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
set(CMAKE_CXX_STANDARD 11)
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
SET(PROJECT_NAMESPACE loco-3d)
# Project properties
SET(PROJECT_ORG loco-3d)
SET(PROJECT_NAME sot-talos-balance)
SET(PROJECT_DESCRIPTION "Collection of dynamic-graph entities aimed at implementing balance control on talos.")
SET(PROJECT_URL "https://gepgitlab.laas.fr/${PROJECT_NAMESPACE}/${PROJECT_NAME}")
SET(PROJECT_URL "https://gepgitlab.laas.fr/${PROJECT_ORG}/${PROJECT_NAME}")
# Export CMake Target
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
# Project options
OPTION(BUILD_PYTHON_INTERFACE "Build the python bindings" ON)
OPTION(INSTALL_PYTHON_INTERFACE_ONLY "Install *ONLY* the python bindings" OFF)
OPTION(SUFFIX_SO_VERSION "Suffix library name with its version" ON)
OPTION(INITIALIZE_WITH_NAN "Initialize Eigen entries with NaN" OFF)
OPTION(BUILD_ROS_PACKAGES "Build ros packages" ON)
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)
# Project configuration
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
SET(CUSTOM_HEADER_DIR "sot/talos_balance")
SET(CXX_DISABLE_WERROR TRUE)
SET(DOXYGEN_USE_MATHJAX YES)
SET(CMAKE_CXX_STANDARD 11)
# JRL-cmakemodule setup
INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/eigen.cmake)
INCLUDE(cmake/python.cmake)
INCLUDE(cmake/test.cmake)
# So that generated headers are in same place as standard ones
SET(CUSTOM_HEADER_DIR "sot/talos_balance")
SET(DOXYGEN_USE_MATHJAX YES)
# Project definition
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX C)
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)
SET(PKG_CONFIG_ADDITIONAL_VARIABLES
${PKG_CONFIG_ADDITIONAL_VARIABLES}
plugindirname
plugindir
)
CMAKE_POLICY(SET CMP0048 OLD)
PROJECT(${PROJECT_NAME} CXX)
IF(WIN32)
SET(LINK copy_if_different)
ELSE(WIN32)
SET(LINK create_symlink)
ENDIF(WIN32)
OPTION (INITIALIZE_WITH_NAN "Initialize Eigen entries with NaN" OFF)
IF(INITIALIZE_WITH_NAN)
MESSAGE(STATUS "Initialize with NaN all the Eigen entries.")
ADD_DEFINITIONS(-DEIGEN_INITIALIZE_MATRICES_BY_NAN)
ENDIF(INITIALIZE_WITH_NAN)
PKG_CONFIG_APPEND_LIBS("sot-talos-balance")
# Search for dependencies.
# Boost
# Project dependencies
SET(BOOST_COMPONENTS thread filesystem program_options unit_test_framework system regex)
OPTION (BUILD_ROS_PACKAGES "Build ros packages" ON)
OPTION (BUILD_PYTHON_INTERFACE "Build the python bindings" ON)
OPTION (INSTALL_PYTHON_INTERFACE_ONLY "Install *ONLY* the python binding" OFF)
OPTION (BUILD_TEST "Build tests" ON)
# name of the python module
IF(BUILD_PYTHON_INTERFACE)
SET(SOTTALOSBALANCE_PYNAME sot_talos_balance)
FINDPYTHON()
STRING(REGEX REPLACE "-" "_" PY_NAME ${PROJECT_NAME})
ADD_PROJECT_DEPENDENCY(dynamic-graph-python REQUIRED
PKG_CONFIG_REQUIRES dynamic-graph-python)
SET(BOOST_COMPONENTS ${BOOST_COMPONENTS} python)
ADD_PROJECT_DEPENDENCY(dynamic-graph-python REQUIRED)
SET(${LIBRARY_NAME}_PYTHON_FILES python/*.py)
SET(PYTHON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/${SOTTALOSBALANCE_PYNAME})
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR})
ENDIF(BUILD_PYTHON_INTERFACE)
#SEARCH_FOR_BOOST()
#SEARCH_FOR_EIGEN()
SEARCH_FOR_BOOST()
ADD_PROJECT_DEPENDENCY(dynamic-graph REQUIRED ) # 3.4.0
ADD_PROJECT_DEPENDENCY(sot-core REQUIRED ) #4.5.0
ADD_REQUIRED_DEPENDENCY("pinocchio >= 2.1")
ADD_PROJECT_DEPENDENCY(sot-core REQUIRED PKG_CONFIG_REQUIRES sot-core)
ADD_PROJECT_DEPENDENCY(eiquadprog REQUIRED PKG_CONFIG_REQUIRES eiquadprog)
ADD_PROJECT_DEPENDENCY(talos_data)
ADD_REQUIRED_DEPENDENCY("parametric-curves")
ADD_REQUIRED_DEPENDENCY("eigen-quadprog")
IF(BUILD_TEST)
ADD_REQUIRED_DEPENDENCY("talos_data")
ENDIF(BUILD_TEST)
SET(SOTTALOSBALANCE_LIB_NAME ${PROJECT_NAME})
SET(LIBRARY_NAME ${SOTTALOSBALANCE_LIB_NAME})
MACRO(DYNAMIC_GRAPH_CUSTOM_PYTHON_MODULE MODULENAME SUBMODULENAME LIBRARYNAME TARGETNAME)
......@@ -128,25 +98,16 @@ MACRO(DYNAMIC_GRAPH_CUSTOM_PYTHON_MODULE MODULENAME SUBMODULENAME LIBRARYNAME TA
FILE(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/src/${FULLMODULENAME})
# Link to python subfolder
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E ${LINK}
${${PROJECT_NAME}_BINARY_DIR}/src/${FULLMODULENAME}
${${PROJECT_NAME}_BINARY_DIR}/python/${FULLMODULENAME}
)
SET_TARGET_PROPERTIES(${PYTHON_MODULE}
PROPERTIES PREFIX ""
OUTPUT_NAME ${FULLMODULENAME}/wrap
)
CMAKE_POLICY(POP)
TARGET_LINK_LIBRARIES(${PYTHON_MODULE} ${PUBLIC_KEYWORD}
"-Wl,--no-as-needed")
TARGET_LINK_LIBRARIES(${PYTHON_MODULE} ${PUBLIC_KEYWORD}
${LIBRARYNAME} ${PYTHON_LIBRARY})
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES(${PYTHON_MODULE} ${PUBLIC_KEYWORD} "-Wl,--no-as-needed")
TARGET_LINK_LIBRARIES(${PYTHON_MODULE} ${PUBLIC_KEYWORD} ${LIBRARYNAME} ${PYTHON_LIBRARY})
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
TARGET_INCLUDE_DIRECTORIES(${PYTHON_MODULE} SYSTEM PRIVATE ${PYTHON_INCLUDE_DIRS})
#
# Installation
......@@ -181,16 +142,53 @@ MACRO(DYNAMIC_GRAPH_CUSTOM_PYTHON_MODULE MODULENAME SUBMODULENAME LIBRARYNAME TA
ENDMACRO(DYNAMIC_GRAPH_CUSTOM_PYTHON_MODULE)
MACRO(SOT_TALOS_BALANCE_PYTHON_MODULE SUBMODULENAME LIBRARYNAME TARGETNAME)
DYNAMIC_GRAPH_CUSTOM_PYTHON_MODULE("${SOTTALOSBALANCE_PYNAME}"
DYNAMIC_GRAPH_CUSTOM_PYTHON_MODULE("${PY_NAME}"
"${SUBMODULENAME}" "${LIBRARYNAME}" "${TARGETNAME}")
ENDMACRO(SOT_TALOS_BALANCE_PYTHON_MODULE)
# Verbosity level
IF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))
ADD_DEFINITIONS(-DVP_DEBUG_MODE=${CMAKE_VERBOSITY_LEVEL} -DVP_DEBUG)
ENDIF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))
SET(${LIBRARY_NAME}_HEADERS
include/${CUSTOM_HEADER_DIR}/utils/commands-helper.hh
include/${CUSTOM_HEADER_DIR}/utils/statistics.hh
include/${CUSTOM_HEADER_DIR}/math/fwd.hh
include/${CUSTOM_HEADER_DIR}/robot/fwd.hh
include/${CUSTOM_HEADER_DIR}/robot/robot-wrapper.hh
include/${CUSTOM_HEADER_DIR}/sdk_qualisys/Network.h
include/${CUSTOM_HEADER_DIR}/sdk_qualisys/RTPacket.h
include/${CUSTOM_HEADER_DIR}/sdk_qualisys/RTProtocol.h
include/${CUSTOM_HEADER_DIR}/sdk_qualisys/Markup.h
)
SET(${PROJECT_NAME}_SOURCES
src/utils/statistics.cpp
src/robot/robot-wrapper.cpp
src/sdk_qualisys/Network.cpp
src/sdk_qualisys/RTPacket.cpp
src/sdk_qualisys/RTProtocol.cpp
src/sdk_qualisys/Markup.cpp
)
ADD_LIBRARY(${PROJECT_NAME} SHARED
${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:include>)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_LIBRARIES}
sot-core::sot-core)
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} parametric-curves)
IF(SUFFIX_SO_VERSION)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
ENDIF(SUFFIX_SO_VERSION)
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
ADD_SUBDIRECTORY(include/${CUSTOM_HEADER_DIR})
INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib)
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
IF(BUILD_PYTHON_INTERFACE)
ADD_SUBDIRECTORY(python/${SOTTALOSBALANCE_PYNAME})
ADD_SUBDIRECTORY(python)
ENDIF(BUILD_PYTHON_INTERFACE)
ADD_SUBDIRECTORY(src)
......@@ -199,6 +197,11 @@ IF(BUILD_ROS_PACKAGES AND NOT INSTALL_PYTHON_INTERFACE_ONLY)
ADD_SUBDIRECTORY(ros)
ENDIF(BUILD_ROS_PACKAGES AND NOT INSTALL_PYTHON_INTERFACE_ONLY)
IF(BUILD_TEST)
IF(BUILD_TESTING)
ADD_SUBDIRECTORY(unittest)
ENDIF(BUILD_TEST)
ENDIF(BUILD_TESTING)
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
INSTALL(FILES package.xml DESTINATION share/${PROJECT_NAME})
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
Subproject commit 54ece258eed16da94c7f10979588fcb47b744eb8
Subproject commit 321eb1ccf1d94570eb564f3659b13ef3ef82239e
SET(${LIBRARY_NAME}_HEADERS
utils/commands-helper.hh
utils/statistics.hh
math/fwd.hh
robot/fwd.hh
robot/robot-wrapper.hh
sdk_qualisys/Network.h
sdk_qualisys/RTPacket.h
sdk_qualisys/RTProtocol.h
sdk_qualisys/Markup.h
)
INSTALL(FILES ${${LIBRARY_NAME}_HEADERS} DESTINATION include/${CUSTOM_HEADER_DIR})
......@@ -10,8 +10,7 @@ SET(${PROJECT_NAME}_PYTHON_FILES
)
FOREACH(python ${${PROJECT_NAME}_PYTHON_FILES})
PYTHON_BUILD(. ${python})
INSTALL(FILES ${python} DESTINATION ${PYTHON_SITELIB}/${SOTTALOSBALANCE_PYNAME})
PYTHON_INSTALL_ON_SITE(${PY_NAME} ${python})
ENDFOREACH(python ${${PROJECT_NAME}_PYTHON_FILES})
# utils submodule
......@@ -26,8 +25,7 @@ SET(${PROJECT_NAME}_UTILS_PYTHON_FILES
)
FOREACH(python ${${PROJECT_NAME}_UTILS_PYTHON_FILES})
PYTHON_BUILD(utils ${python})
INSTALL(FILES utils/${python} DESTINATION ${PYTHON_SITELIB}/${SOTTALOSBALANCE_PYNAME}/utils)
PYTHON_INSTALL_ON_SITE(${PY_NAME}/utils ${python})
ENDFOREACH(python ${${PROJECT_NAME}_UTILS_PYTHON_FILES})
......@@ -55,11 +53,52 @@ SET(${PROJECT_NAME}_TALOS_PYTHON_FILES
)
FOREACH(python ${${PROJECT_NAME}_TALOS_PYTHON_FILES})
PYTHON_BUILD(talos ${python})
INSTALL(FILES talos/${python} DESTINATION ${PYTHON_SITELIB}/${SOTTALOSBALANCE_PYNAME}/talos)
PYTHON_INSTALL_ON_SITE(${PY_NAME}/talos ${python})
ENDFOREACH(python ${${PROJECT_NAME}_TALOS_PYTHON_FILES})
IF(BUILD_TEST)
ADD_SUBDIRECTORY(test)
ENDIF(BUILD_TEST)
# simulation files
SET(${PROJECT_NAME}_SIMULATION_FILES
__init__.py
test_dcm_zmp_control.py
appli_dcm_zmp_control.py
test_dcm_zmp_control_distribute.py
appli_dcm_zmp_control_distribute.py
test_dcm_zmp_control_ffdc.py
appli_dcm_zmp_control_ffdc.py
test_ffSubscriber.py
appli_ffSubscriber.py
test_zmpEstimator.py
appli_zmpEstimator.py
test_dcmComControl.py
appli_dcmComControl.py
test_dcmComZmpControl.py
appli_dcmComZmpControl.py
test_dcmZmpControl.py
appli_dcmZmpControl.py
test_dcmZmpControl_file.py
appli_dcmZmpControl_file.py
test_comAdmittance.py
test_admittance_single_joint.py
appli_admittance_single_joint.py
test_admittance_end_effector.py
appli_admittance_end_effector.py
test_simple_ankle_admittance.py
appli_simple_ankle_admittance.py
test_admittance_single_joint_velocity_based.py
appli_admittance_single_joint_velocity_based.py
test_singleTraj.py
test_jointTrajGen.py
test_jointControl.py
test_COMTraj.py
appli_COMTraj.py
test_COMTraj_tracer.py
test_param_server.py
test_dcm_estimator.py
appli_dcm_estimator.py
test_hip_flexibility_compensation.py
appli_hip_flexibility_compensation.py
)
FOREACH(python ${${PROJECT_NAME}_SIMULATION_FILES})
PYTHON_INSTALL_ON_SITE(${PY_NAME}/test ${python})
ENDFOREACH(python ${${PROJECT_NAME}_SIMULATION_FILES})
# Copyright 2018, Gepetto team, LAAS-CNRS
# Verbosity level
IF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))
ADD_DEFINITIONS(-DVP_DEBUG_MODE=${CMAKE_VERBOSITY_LEVEL} -DVP_DEBUG)
ENDIF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))
IF(UNIX)
ADD_DEFINITIONS(-pthread)
ENDIF(UNIX)
SET(${LIBRARY_NAME}_SOURCES
utils/statistics.cpp
robot/robot-wrapper.cpp
sdk_qualisys/Network.cpp
sdk_qualisys/RTPacket.cpp
sdk_qualisys/RTProtocol.cpp
sdk_qualisys/Markup.cpp
)
ADD_LIBRARY(${LIBRARY_NAME} SHARED ${${LIBRARY_NAME}_SOURCES})
SET_TARGET_PROPERTIES(${LIBRARY_NAME}
PROPERTIES
SOVERSION ${PROJECT_VERSION}
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} dynamic-graph::dynamic-graph)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} sot-core::sot-core)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} pinocchio)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} parametric-curves)
IF(UNIX)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${CMAKE_DL_LIBS})
IF(NOT APPLE)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} pthread)
ENDIF(NOT APPLE)
ENDIF(UNIX)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES})
IF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
#This project will create many plugins as shared libraries, listed here
SET(plugins
example
delay
......@@ -87,77 +42,36 @@ SET(plugins
hip-flexibility-compensation
)
#set(ADDITIONAL_feature-task_LIBS feature-generic task)
# set(feature-task_deps feature-generic task)
#Plugins compilation, link, and installation
#Compiles a plugin. The plugin library is ${LIBRARY_NAME}
FOREACH(plugin ${plugins})
#retrieve plugin name
GET_FILENAME_COMPONENT(LIBRARY_NAME ${plugin} NAME)
ADD_LIBRARY(${LIBRARY_NAME} SHARED ${plugin})
# only one source file per plugin
ADD_LIBRARY(${LIBRARY_NAME}
SHARED
${plugin}.cpp)
#remove the "lib" prefix from the plugin output name
SET_TARGET_PROPERTIES(${LIBRARY_NAME}
PROPERTIES
PREFIX "")
SET_TARGET_PROPERTIES(${LIBRARY_NAME}
PROPERTIES
SOVERSION ${PROJECT_VERSION}
INSTALL_RPATH ${CMAKE_INSTALL_LIBDIR}/plugin)
# Link with sot-talos-balance library
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${SOTTALOSBALANCE_LIB_NAME})
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES})
ADD_DEPENDENCIES(${LIBRARY_NAME} ${SOTTALOSBALANCE_LIB_NAME})
IF(ADDITIONAL_${LIBRARY_NAME}_LIBS)
ADD_DEPENDENCIES(${LIBRARY_NAME} ${ADDITIONAL_${LIBRARY_NAME}_LIBS})
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${ADDITIONAL_${LIBRARY_NAME}_LIBS})
ENDIF(ADDITIONAL_${LIBRARY_NAME}_LIBS)
IF(SUFFIX_SO_VERSION)
SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
ENDIF(SUFFIX_SO_VERSION)
# Linux dynamic loading library flags
IF(UNIX)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${CMAKE_DL_LIBS})
IF(NOT APPLE)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} dl pthread)
ENDIF(NOT APPLE)
ENDIF(UNIX)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${PROJECT_NAME} ${${LIBRARY_NAME}_deps})
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} dynamic-graph::dynamic-graph)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} sot-core::sot-core)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} pinocchio)
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
INSTALL(TARGETS ${LIBRARY_NAME} EXPORT ${TARGETS_EXPORT_NAME}
DESTINATION ${DYNAMIC_GRAPH_PLUGINDIR})
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
# build python submodule
# (replace minus with underscore to make Python happy)
IF(BUILD_PYTHON_INTERFACE)
STRING(REPLACE - _ PYTHON_LIBRARY_NAME ${LIBRARY_NAME})
SOT_TALOS_BALANCE_PYTHON_MODULE(
${PYTHON_LIBRARY_NAME}
${LIBRARY_NAME}
sot-talos-balance-${PYTHON_LIBRARY_NAME}-wrap
)
SOT_TALOS_BALANCE_PYTHON_MODULE(${PYTHON_LIBRARY_NAME}
${LIBRARY_NAME} ${PROJECT_NAME}-${PYTHON_LIBRARY_NAME}-wrap)
ENDIF(BUILD_PYTHON_INTERFACE)
# Install plugins
IF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
INSTALL(TARGETS ${LIBRARY_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/plugin)
ENDIF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
ENDFOREACH(plugin)
# Bindings Python
IF(BUILD_PYTHON_INTERFACE)
SOT_TALOS_BALANCE_PYTHON_MODULE("" ${SOTTALOSBALANCE_LIB_NAME} wrap)
SOT_TALOS_BALANCE_PYTHON_MODULE("" ${PROJECT_NAME} wrap)
# Install empty __init__.py files in intermediate directories.
INSTALL(FILES
${CMAKE_CURRENT_BINARY_DIR}/${SOTTALOSBALANCE_PYNAME}/__init__.py
DESTINATION ${PYTHON_SITELIB}/${SOTTALOSBALANCE_PYNAME}
${CMAKE_CURRENT_BINARY_DIR}/${PY_NAME}/__init__.py
DESTINATION ${PYTHON_SITELIB}/${PY_NAME}
)
ENDIF(BUILD_PYTHON_INTERFACE)
# Copyright 2010, François Bleibel, Olivier Stasse, JRL, CNRS/AIST
# Relative plug-in directory (i.e. lib/plugin for instance)
# as exposed by the dynamic-graph pkg-config file.
SET(PLUGINDIR ${DYNAMIC_GRAPH_PLUGINDIRNAME})
SET(FULLPLUGINDIR ${CMAKE_INSTALL_PREFIX}/${PLUGINDIR})
SET(SOT_PLUGIN_OUT_DIR ${CMAKE_BINARY_DIR}/src)
CONFIG_FILES_CMAKE(test-paths.h)
IF(UNIX)
ADD_DEFINITIONS(-pthread)
ENDIF(UNIX)
# Make Boost.Test generates the main function in test cases.
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
# Definition of a macro that corresponds to the suffix for a dynamic lib
ADD_DEFINITIONS(-DTESTS_DYNLIBSUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}")
# The sot-core plugin libraries that tests have to be linked against
# the name of the variable for test EXECUTABLE_NAME is
# TEST_${EXECUTABLE_NAME}_LIBS
SET(TEST_test_distribute_LIBS
SET(test_distribute_deps
distribute-wrench
)
SET(TEST_test_distribute_EXT_LIBS
sot-core::sot-core ${SOT_CORE_LIBDIR}/plugin/parameter-server.so
sot-core::sot-core parameter-server
)
#test paths and names (without .cpp extension)
SET (tests
SET(tests
dummy
test_distribute
)
#IF(UNIX)
# ADD_LIBRARY(pluginabstract
# SHARED
# tools/plugin.cc)
# ADD_EXECUTABLE(test_abstract_interface
# tools/test_abstract_interface.cpp
# )
# TARGET_LINK_LIBRARIES(test_abstract_interface
# pluginabstract ${CMAKE_DL_LIBS} ${Boost_LIBRARIES})
# LINK_DIRECTORIES(${SOT_PLUGIN_OUT_DIR} ${FULLPLUGINDIR})
#ENDIF(UNIX)
IF(UNIX)
LINK_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/lib/plugin)
LINK_DIRECTORIES(${DYNAMIC_GRAPH_PLUGINDIR})
ENDIF(UNIX)
ADD_DEFINITIONS(-DDEBUG=2)
# Add MatrixAbstractLayer compilation flags
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/unittest)
FOREACH(test ${tests})
GET_FILENAME_COMPONENT(EXECUTABLE_NAME ${test} NAME)
ADD_EXECUTABLE(${EXECUTABLE_NAME} ${test}.cpp)
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${PROJECT_NAME})
ADD_DEPENDENCIES (${EXECUTABLE_NAME} ${PROJECT_NAME})
IF( TEST_${EXECUTABLE_NAME}_LIBS )
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${TEST_${EXECUTABLE_NAME}_LIBS})
ADD_DEPENDENCIES (${EXECUTABLE_NAME} ${TEST_${EXECUTABLE_NAME}_LIBS})
ENDIF( TEST_${EXECUTABLE_NAME}_LIBS )
IF( TEST_${EXECUTABLE_NAME}_EXT_LIBS )
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${TEST_${EXECUTABLE_NAME}_EXT_LIBS})
ENDIF( TEST_${EXECUTABLE_NAME}_EXT_LIBS )
IF (UNIX)
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${CMAKE_DL_LIBS})
ENDIF(UNIX)
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} dynamic-graph::dynamic-graph)
PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} pinocchio)
IF(BUILD_PYTHON_INTERFACE)
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME}
dynamic-graph-python::dynamic-graph-python)
ENDIF(BUILD_PYTHON_INTERFACE)
# Link against Boost.
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME}
${Boost_LIBRARIES} ${Boost_SYSTEM_LIBRARY})
ADD_TEST(${test} ${EXECUTABLE_NAME})
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}:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/plugin:${BOOST_ROOT}/lib:${EXTRA_LD_LIBRARY_PATH}")
ENDIF(UNIX)
ADD_UNIT_TEST(${test} ${test}.cpp)
TARGET_LINK_LIBRARIES(${test} ${PROJECT_NAME} ${${test}_deps})
TARGET_INCLUDE_DIRECTORIES(${test} PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
ENDFOREACH(test)
IF(BUILD_PYTHON_INTERFACE)
......
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