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

[CMake] clean: keep minimal required instructions

parent b1a543f7
...@@ -5,40 +5,77 @@ ...@@ -5,40 +5,77 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.1) CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
SET(PROJECT_NAMESPACE stack-of-tasks) # Project properties
SET(PROJECT_ORG stack-of-tasks)
SET(PROJECT_NAME dynamic-graph-tutorial) SET(PROJECT_NAME dynamic-graph-tutorial)
SET(PROJECT_DESCRIPTION "Tutorial for dynamic-graph") SET(PROJECT_DESCRIPTION "Tutorial for dynamic-graph")
SET(PROJECT_URL "http://github.com/${PROJECT_NAME}/${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 "dynamic-graph/tutorial")
# JRL-cmakemodule setup
INCLUDE(cmake/base.cmake) INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake) INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/test.cmake)
INCLUDE(cmake/python.cmake) INCLUDE(cmake/python.cmake)
INCLUDE(cmake/sphinx.cmake) INCLUDE(cmake/sphinx.cmake)
OPTION (BUILD_PYTHON_INTERFACE "Build the python binding" ON) # Project definition
OPTION (INSTALL_PYTHON_INTERFACE_ONLY "Install *ONLY* the python binding" OFF)
SET (CUSTOM_HEADER_DIR "dynamic-graph/tutorial")
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX) COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS}) PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
# Project dependencies
ADD_PROJECT_DEPENDENCY(dynamic-graph REQUIRED PKG_CONFIG_REQUIRES dynamic-graph) ADD_PROJECT_DEPENDENCY(dynamic-graph REQUIRED PKG_CONFIG_REQUIRES dynamic-graph)
SET(BOOST_COMPONENTS unit_test_framework) SET(BOOST_COMPONENTS unit_test_framework)
IF(BUILD_PYTHON_INTERFACE) IF(BUILD_PYTHON_INTERFACE)
ADD_PROJECT_DEPENDENCY(dynamic-graph-python REQUIRED PKG_CONFIG_REQUIRES dynamic-graph-python)
FINDPYTHON() 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) SET(BOOST_COMPONENTS ${BOOST_COMPONENTS} python)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
ENDIF(BUILD_PYTHON_INTERFACE) ENDIF(BUILD_PYTHON_INTERFACE)
SEARCH_FOR_BOOST() SEARCH_FOR_BOOST()
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ADD_SUBDIRECTORY(include/${CUSTOM_HEADER_DIR}) # Main Library
SET(${PROJECT_NAME}_HEADERS
include/${CUSTOM_HEADER_DIR}/inverted-pendulum.hh
include/${CUSTOM_HEADER_DIR}/feedback-controller.hh
)
SET(${PROJECT_NAME}_SOURCES
src/inverted-pendulum
src/feedback-controller
)
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}
dynamic-graph::dynamic-graph)
IF(SUFFIX_SO_VERSION)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
ENDIF(SUFFIX_SO_VERSION)
#IF(BUILD_PYTHON_INTERFACE) # TODO
#TARGET_LINK_LIBRARIES(${PROJECT_NAME} dynamic-graph-python::dynamic-graph-python)
#ENDIF(BUILD_PYTHON_INTERFACE)
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib)
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(doc)
ADD_SUBDIRECTORY(tests) ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(doc)
#INSTALL(FILES package.xml DESTINATION share/${PROJECT_NAME}) # TODO
Subproject commit 4514454f5f9462047b5c29f61b6c3e0db731c416 Subproject commit 321eb1ccf1d94570eb564f3659b13ef3ef82239e
# Copyright 2010, 2019-2020, Florent Lamiraux, Guilhem Saurel CNRS # Copyright 2010, 2019-2020, Florent Lamiraux, Guilhem Saurel CNRS
# #
IF(BUILD_PYTHON_INTERFACE) IF(BUILD_PYTHON_INTERFACE AND NOT INSTALL_PYTHON_INTERFACE_ONLY)
SPHINX_SETUP() SPHINX_SETUP()
SPHINX_FINALIZE() SPHINX_FINALIZE()
ENDIF(BUILD_PYTHON_INTERFACE) ENDIF(BUILD_PYTHON_INTERFACE AND NOT INSTALL_PYTHON_INTERFACE_ONLY)
SET(${PROJECT_NAME}_HEADERS
inverted-pendulum.hh
feedback-controller.hh
)
IF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
INSTALL(FILES ${${PROJECT_NAME}_HEADERS} DESTINATION include/${CUSTOM_HEADER_DIR})
ENDIF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
# Copyright 2010, 2018, Florent Lamiraux, CNRS
#
SET(${PROJECT_NAME}_SOURCES
inverted-pendulum
feedback-controller
)
SET(${PY_NAME}_PYTHON
simu.py
)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC dynamic-graph::dynamic-graph)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} dynamic-graph::dynamic-graph)
IF(BUILD_PYTHON_INTERFACE) IF(BUILD_PYTHON_INTERFACE)
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC dynamic-graph-python::dynamic-graph-python) PYTHON_INSTALL_ON_SITE("dynamic_graph/tutorial" simu.py)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} dynamic-graph-python::dynamic-graph-python)
DYNAMIC_GRAPH_PYTHON_MODULE("tutorial" ${PROJECT_NAME} wrap) DYNAMIC_GRAPH_PYTHON_MODULE("tutorial" ${PROJECT_NAME} wrap)
INSTALL(FILES ${${PY_NAME}_PYTHON} DESTINATION "${PYTHON_SITELIB}/dynamic_graph/tutorial/")
ENDIF(BUILD_PYTHON_INTERFACE) ENDIF(BUILD_PYTHON_INTERFACE)
IF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib)
ENDIF (NOT INSTALL_PYTHON_INTERFACE_ONLY)
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN) ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
ADD_UNIT_TEST(pendulum pendulum) ADD_UNIT_TEST(pendulum pendulum.cpp)
TARGET_LINK_LIBRARIES(pendulum ${PROJECT_NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} dynamic-graph::dynamic-graph) TARGET_LINK_LIBRARIES(pendulum ${PROJECT_NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} dynamic-graph::dynamic-graph)
TARGET_INCLUDE_DIRECTORIES(pendulum PUBLIC dynamic-graph::dynamic-graph) TARGET_INCLUDE_DIRECTORIES(pendulum PUBLIC dynamic-graph::dynamic-graph)
ADD_UNIT_TEST(controller controller) ADD_UNIT_TEST(controller controller.cpp)
TARGET_LINK_LIBRARIES(controller ${PROJECT_NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} dynamic-graph::dynamic-graph) TARGET_LINK_LIBRARIES(controller ${PROJECT_NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} dynamic-graph::dynamic-graph)
TARGET_INCLUDE_DIRECTORIES(controller PUBLIC dynamic-graph::dynamic-graph) TARGET_INCLUDE_DIRECTORIES(controller PUBLIC dynamic-graph::dynamic-graph)
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