Verified Commit f05d6051 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

cmake: correctly export the project

parent 243fe383
......@@ -9,6 +9,8 @@ SET(PROJECT_NAME pinocchio)
SET(PROJECT_DESCRIPTION "A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives")
SET(PROJECT_URL "http://github.com/stack-of-tasks/pinocchio")
SET(PROJECT_CUSTOM_HEADER_EXTENSION "hpp")
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
SET(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)
......@@ -249,7 +251,7 @@ ADD_SUBDIRECTORY(examples)
ADD_SUBDIRECTORY(benchmark)
# --- PACKAGING ----------------------------------------------------------------
PKG_CONFIG_APPEND_LIBS (${PROJECT_NAME})
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_REQUIRED_COMPONENTS})
FOREACH(cflags ${CFLAGS_DEPENDENCIES})
......
......@@ -19,7 +19,7 @@ MACRO(ADD_BENCH bench_name)
SET(link_to_main_lib ${ARGV1})
IF(link_to_main_lib)
SET_TARGET_PROPERTIES(${bench_name} PROPERTIES COMPILE_DEFINITIONS PINOCCHIO_MODEL_DIR="${PINOCCHIO_MODEL_DIR}")
TARGET_LINK_LIBRARIES(${bench_name} ${PROJECT_NAME})
TARGET_LINK_LIBRARIES(${bench_name} PUBLIC ${PROJECT_NAME})
PKG_CONFIG_USE_DEPENDENCY(${bench_name} eigen3)
IF(HPP_FCL_FOUND)
......@@ -47,7 +47,7 @@ IF(CPPADCG_FOUND)
ADD_BENCH(timings-cg TRUE)
SET_PROPERTY(TARGET timings-cg PROPERTY CXX_STANDARD 11)
PKG_CONFIG_USE_DEPENDENCY(timings-cg "cppadcg")
TARGET_LINK_LIBRARIES(timings-cg ${CMAKE_DL_LIBS})
TARGET_LINK_LIBRARIES(timings-cg PUBLIC ${CMAKE_DL_LIBS})
ENDIF(CPPADCG_FOUND)
# timings
......
#
# Copyright (c) 2015-2019 CNRS INRIA
# Copyright (c) 2015-2020 CNRS INRIA
# Copyright (c) 2015 Wandercraft, 86 rue de Paris 91400 Orsay, France.
#
......@@ -127,8 +127,8 @@ IF(BUILD_PYTHON_INTERFACE)
ADD_SOURCE_GROUP(${PYWRAP}_SOURCES)
PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} eigenpy)
TARGET_LINK_LIBRARIES(${PYWRAP} ${PROJECT_NAME})
TARGET_LINK_BOOST_PYTHON(${PYWRAP})
TARGET_LINK_LIBRARIES(${PYWRAP} PUBLIC ${PROJECT_NAME})
TARGET_LINK_BOOST_PYTHON(${PYWRAP} PUBLIC)
IF(HPP_FCL_FOUND)
PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} hpp-fcl)
......
......@@ -6,7 +6,7 @@ FUNCTION(ADD_PINOCCHIO_CPP_EXAMPLE EXAMPLE)
GET_FILENAME_COMPONENT(EXAMPLE_NAME ${EXAMPLE} NAME)
SET(EXAMPLE_NAME "example-cpp-${EXAMPLE_NAME}")
ADD_UNIT_TEST(${EXAMPLE_NAME} ${EXAMPLE})
TARGET_LINK_LIBRARIES(${EXAMPLE_NAME} ${PROJECT_NAME})
TARGET_LINK_LIBRARIES(${EXAMPLE_NAME} PUBLIC ${PROJECT_NAME})
PKG_CONFIG_USE_DEPENDENCY(${EXAMPLE_NAME} eigen3)
IF(URDFDOM_FOUND)
PKG_CONFIG_USE_DEPENDENCY(${EXAMPLE_NAME} urdfdom)
......
......@@ -11,15 +11,19 @@ SET(${PROJECT_NAME}_SOURCES
${${PROJECT_NAME}_PARSERS_SOURCES}
)
# Extract the compile definitions of the project for export
GET_DIRECTORY_PROPERTY(CURRENT_COMPILE_DEFINITIONS COMPILE_DEFINITIONS)
IF(UNIX)
# Create target libpinocchio.so
ADD_LIBRARY(${PROJECT_NAME} SHARED ${HEADERS} ${${PROJECT_NAME}_SOURCES})
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PUBLIC ${CURRENT_COMPILE_DEFINITIONS})
IF(BUILD_WITH_COMMIT_VERSION)
TAG_LIBRARY_VERSION(${PROJECT_NAME})
ENDIF(BUILD_WITH_COMMIT_VERSION)
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} eigen3)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_SERIALIZATION_LIBRARY})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_SERIALIZATION_LIBRARY})
IF(URDFDOM_FOUND)
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} urdfdom)
......
......@@ -34,8 +34,8 @@ MACRO(ADD_PINOCCHIO_UNIT_TEST NAME)
PKG_CONFIG_USE_DEPENDENCY(${TEST_NAME} hpp-fcl)
ENDIF(HPP_FCL_FOUND)
TARGET_LINK_LIBRARIES(${TEST_NAME} ${PROJECT_NAME})
TARGET_LINK_LIBRARIES(${TEST_NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
TARGET_LINK_LIBRARIES(${TEST_NAME} PUBLIC ${PROJECT_NAME})
TARGET_LINK_LIBRARIES(${TEST_NAME} PRIVATE ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
ENDMACRO(ADD_PINOCCHIO_UNIT_TEST)
# --- RULES -------------------------------------------------------------------
......@@ -77,8 +77,8 @@ ENDIF(URDFDOM_FOUND)
IF(BUILD_PYTHON_INTERFACE)
ADD_PINOCCHIO_UNIT_TEST(python_parser eigenpy)
TARGET_LINK_LIBRARIES(test-cpp-python_parser ${PYWRAP})
TARGET_LINK_LIBRARIES(test-cpp-python_parser ${PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(test-cpp-python_parser PUBLIC ${PYWRAP})
TARGET_LINK_LIBRARIES(test-cpp-python_parser PUBLIC ${PYTHON_LIBRARIES})
SET(ENV_VARIABLES "PYTHONPATH=${CMAKE_BINARY_DIR}/bindings/python:$ENV{PYTHONPATH}")
IF(APPLE)
LIST(APPEND ENV_VARIABLES "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}")
......
#
# Copyright (c) 2015-2018 CNRS
# Copyright (c) 2015-2020 CNRS INRIA
#
# --- MACROS ------------------------------------------------------------------
......@@ -16,10 +16,10 @@ MACRO(ADD_UTIL NAME UTIL_SRC PKGS)
FOREACH(PKG ${PKGS})
PKG_CONFIG_USE_DEPENDENCY(${NAME} ${PKG})
ENDFOREACH(PKG)
TARGET_LINK_LIBRARIES (${NAME} ${Boost_LIBRARIES} ${PROJECT_NAME})
TARGET_LINK_LIBRARIES (${NAME} PUBLIC ${PROJECT_NAME})
IF(BUILD_PYTHON_INTERFACE)
TARGET_LINK_BOOST_PYTHON(${NAME})
TARGET_LINK_LIBRARIES(${NAME} ${PYTHON_LIBRARIES})
TARGET_LINK_BOOST_PYTHON(${NAME} PUBLIC)
TARGET_LINK_LIBRARIES(${NAME} PUBLIC ${PYTHON_LIBRARIES})
ENDIF(BUILD_PYTHON_INTERFACE)
IF(HPP_FCL_FOUND)
......
Supports Markdown
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