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

[CMake] Export

parent 82adf61b
# Copyright (c) 2015-2018, CNRS
# Authors: Justin Carpentier <jcarpent@laas.fr>
# Copyright (c) 2015-2020, CNRS
# Authors: Justin Carpentier <jcarpent@laas.fr>, Guilhem Saurel
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
SET(PROJECT_NAMESPACE loco-3d)
# Project properties
SET(PROJECT_ORG loco-3d)
SET(PROJECT_NAME multicontact-api)
SET(PROJECT_DESCRIPTION "API to define and store Contact phases and Contact Sequences")
SET(PROJECT_URL "https://gepgitlab.laas.fr/${PROJECT_NAMESPACE}/${PROJECT_NAME}")
SET(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
# 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)
# Project configuration
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
SET(CUSTOM_HEADER_DIR "${PROJECT_NAME}")
SET(CMAKE_CXX_STANDARD 11)
SET(CXX_DISABLE_WERROR TRUE)
SET(DOXYGEN_USE_MATHJAX YES)
# JRL-cmakemodule setup
INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/eigen.cmake)
INCLUDE(cmake/python.cmake)
INCLUDE(cmake/ide.cmake)
INCLUDE(cmake/test.cmake)
SET(CMAKE_CXX_STANDARD 11)
OPTION(BUILD_PYTHON_INTERFACE "Build the python binding" ON)
OPTION(INSTALL_PYTHON_INTERFACE_ONLY "Install *ONLY* the python binding" OFF)
IF(INSTALL_PYTHON_INTERFACE_ONLY)
SET(INSTALL_DOCUMENTATION OFF CACHE BOOL "documentation is not in python interface")
SET(INSTALL_GENERATED_HEADERS OFF CACHE BOOL "headers are not in python interface")
SET(INSTALL_PKG_CONFIG_FILE OFF CACHE BOOL ".pc is not in python interface")
ENDIF(INSTALL_PYTHON_INTERFACE_ONLY)
SET(DOXYGEN_USE_MATHJAX YES)
SET(CXX_DISABLE_WERROR True)
SET(CUSTOM_HEADER_DIR "${PROJECT_NAME}")
# Project definition
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
ADD_REQUIRED_DEPENDENCY("pinocchio >= 2.0.0")
ADD_REQUIRED_DEPENDENCY("curves >= 0.3")
# Project dependencies
ADD_PROJECT_DEPENDENCY(pinocchio REQUIRED PKG_CONFIG_REQUIRES "pinocchio >= 2.0.0")
ADD_PROJECT_DEPENDENCY(curves REQUIRED PKG_CONFIG_REQUIRES "curves >= 0.3")
SET(BOOST_COMPONENTS unit_test_framework serialization)
IF(BUILD_PYTHON_INTERFACE)
ADD_REQUIRED_DEPENDENCY("eigenpy >= 1.6.12")
SET(BOOST_COMPONENTS ${BOOST_COMPONENTS} python)
FINDPYTHON()
STRING(REGEX REPLACE "-" "_" PY_NAME ${CUSTOM_HEADER_DIR})
ADD_PROJECT_DEPENDENCY(eigenpy REQUIRED PKG_CONFIG_REQUIRES "eigenpy >= 1.6.12")
SET(BOOST_COMPONENTS ${BOOST_COMPONENTS} python)
INCLUDE_DIRECTORIES(SYSTEM ${PYTHON_INCLUDE_DIRS})
STRING(REGEX REPLACE "-" "_" PY_NAME ${PROJECT_NAME})
SET(${PY_NAME}_INSTALL_DIR ${PYTHON_SITELIB}/${PY_NAME})
......@@ -51,6 +51,16 @@ ENDIF(BUILD_PYTHON_INTERFACE)
SEARCH_FOR_BOOST()
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})
# Main Library
ADD_LIBRARY(${PROJECT_NAME} INTERFACE)
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:include>)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} INTERFACE pinocchio::pinocchio curves::curves)
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib)
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
ADD_SUBDIRECTORY(include/${CUSTOM_HEADER_DIR})
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
......
# Copyright (c) 2015-2018, CNRS
# Authors: Justin Carpentier <jcarpent@laas.fr>
# Copyright (c) 2015-2020, CNRS
# Authors: Justin Carpentier <jcarpent@laas.fr>, Guilhem Saurel
SET(${PROJECT_NAME}_PYTHON_SOURCES
module.cpp
......@@ -14,16 +14,22 @@ SET(${PROJECT_NAME}_PYTHON_SOURCES
)
ADD_LIBRARY(${PY_NAME} SHARED ${${PROJECT_NAME}_PYTHON_SOURCES} ${${PROJECT_NAME}_PYTHON_HEADERS})
ADD_SOURCE_GROUP(${PROJECT_NAME}_PYTHON_SOURCES)
PKG_CONFIG_USE_DEPENDENCY(${PY_NAME} eigenpy)
PKG_CONFIG_USE_DEPENDENCY(${PY_NAME} pinocchio)
PKG_CONFIG_USE_DEPENDENCY(${PY_NAME} curves)
TARGET_LINK_LIBRARIES(${PY_NAME} ${Boost_SERIALIZATION_LIBRARIES})
TARGET_LINK_LIBRARIES(${PY_NAME} ${PROJECT_NAME} ${Boost_SERIALIZATION_LIBRARIES} eigenpy::eigenpy)
TARGET_LINK_BOOST_PYTHON(${PY_NAME})
SET_TARGET_PROPERTIES(${PY_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PY_NAME})
SET_TARGET_PROPERTIES(${PY_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PY_NAME} SOVERSION ${PROJECT_VERSION})
TARGET_COMPILE_OPTIONS(${PY_NAME} PRIVATE "-Wno-conversion")
TARGET_COMPILE_OPTIONS(${PY_NAME} PRIVATE "-Wno-enum-compare")
INSTALL(TARGETS ${PY_NAME} DESTINATION ${${PY_NAME}_INSTALL_DIR})
ADD_SUBDIRECTORY(${PY_NAME})
SET(${PROJECT_NAME}_PYTHON_FILES
__init__.py
)
FOREACH(file ${${PROJECT_NAME}_PYTHON_FILES})
PYTHON_INSTALL_ON_SITE(${PY_NAME} ${file})
ENDFOREACH(file ${${PROJECT_NAME}_PYTHON_FILES})
SET(${PROJECT_NAME}_PYTHON_FILES
__init__.py
)
FOREACH(PYTHON_FILE ${${PROJECT_NAME}_PYTHON_FILES})
PYTHON_BUILD(. ${PYTHON_FILE})
INSTALL(FILES ${PYTHON_FILE} DESTINATION ${${PY_NAME}_INSTALL_DIR})
ENDFOREACH(PYTHON_FILE ${${PROJECT_NAME}_PYTHON_FILES})
Subproject commit 65e7f52151c93dd3bf4e0017a44c170d0547d060
Subproject commit a5c65a0ee51191be3f2e2667b95830706c211bb2
# Copyright (c) 2015-2018, CNRS
# Authors: Justin Carpentier <jcarpent@laas.fr>
# Copyright (c) 2015-2020, CNRS
# Authors: Justin Carpentier <jcarpent@laas.fr>, Guilhem Saurel
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
......@@ -11,11 +11,9 @@ SET(${PROJECT_NAME}_TESTS
FOREACH(TEST ${${PROJECT_NAME}_TESTS})
ADD_UNIT_TEST(${TEST} ${TEST})
TARGET_LINK_LIBRARIES(${TEST} ${Boost_LIBRARIES})
PKG_CONFIG_USE_DEPENDENCY(${TEST} eigen3)
PKG_CONFIG_USE_DEPENDENCY(${TEST} pinocchio)
PKG_CONFIG_USE_DEPENDENCY(${TEST} curves)
TARGET_LINK_LIBRARIES(${TEST} ${PROJECT_NAME} ${Boost_LIBRARIES})
ENDFOREACH(TEST ${${PROJECT_NAME}_TESTS})
TARGET_COMPILE_DEFINITIONS(examples PRIVATE -DTEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../examples/")
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