From be6a8d649807b06d4d443b25ac889e3f28467b02 Mon Sep 17 00:00:00 2001 From: Guilhem Saurel <guilhem.saurel@gmail.com> Date: Fri, 17 Aug 2018 16:54:31 +0200 Subject: [PATCH] [CMake] add BUILD_PYTHON_INTERFACE option --- CMakeLists.txt | 15 +++++++++++---- python/CMakeLists.txt | 11 ++++++----- src/CMakeLists.txt | 28 ++++++++++++++++------------ unitTesting/CMakeLists.txt | 6 +++--- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e064e6..b7387f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,10 +41,9 @@ SET(PKG_CONFIG_ADDITIONAL_VARIABLES SETUP_PROJECT() # Search for dependencies. -ADD_REQUIRED_DEPENDENCY("pinocchio >= 1.2.6") ADD_REQUIRED_DEPENDENCY("eigenpy") +ADD_REQUIRED_DEPENDENCY("pinocchio >= 1.2.6") ADD_REQUIRED_DEPENDENCY("dynamic-graph >= 3.0.0") -ADD_REQUIRED_DEPENDENCY("dynamic-graph-python >= 3.0.0") ADD_REQUIRED_DEPENDENCY("sot-core >= 3.0.0") ADD_REQUIRED_DEPENDENCY("sot-tools >= 2.0.0") @@ -69,8 +68,16 @@ PKG_CONFIG_APPEND_LIBS(${LIBRARY_NAME}) # Search for dependencies. # Boost -SET(BOOST_COMPONENTS filesystem system unit_test_framework python) -FINDPYTHON() +SET(BOOST_COMPONENTS filesystem system unit_test_framework) + +OPTION (BUILD_PYTHON_INTERFACE "Build the python binding" ON) +IF(BUILD_PYTHON_INTERFACE) + FINDPYTHON() + ADD_REQUIRED_DEPENDENCY("dynamic-graph-python >= 3.0.0") + SET(BOOST_COMPONENTS ${BOOST_COMPONENTS} python) + INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) +ENDIF(BUILD_PYTHON_INTERFACE) + SEARCH_FOR_BOOST() SEARCH_FOR_EIGEN() diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index d0d241b..b76b0f7 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,5 +1,6 @@ -INSTALL( - FILES kine_romeo.py kine_romeo_small.py - DESTINATION ${PYTHON_SITELIB}/dynamic_graph/tutorial -) - +IF(BUILD_PYTHON_INTERFACE) + INSTALL( + FILES kine_romeo.py kine_romeo_small.py + DESTINATION ${PYTHON_SITELIB}/dynamic_graph/tutorial + ) +ENDIF(BUILD_PYTHON_INTERFACE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3c29c10..c8df282 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,12 +50,14 @@ FOREACH(lib ${plugins}) INSTALL(TARGETS ${libname} DESTINATION ${DYNAMIC_GRAPH_PLUGINDIR}) # build python submodule - STRING(REPLACE - _ PYTHON_LIBRARY_NAME ${lib}) + IF(BUILD_PYTHON_INTERFACE) + STRING(REPLACE - _ PYTHON_LIBRARY_NAME ${lib}) - DYNAMIC_GRAPH_PYTHON_MODULE("sot/dynamics_pinocchio/${PYTHON_LIBRARY_NAME}" - ${libname} - sot-dynamic-pinocchio-${PYTHON_LIBRARY_NAME}-wrap - ) + DYNAMIC_GRAPH_PYTHON_MODULE("sot/dynamics_pinocchio/${PYTHON_LIBRARY_NAME}" + ${libname} + sot-dynamic-pinocchio-${PYTHON_LIBRARY_NAME}-wrap + ) + ENDIF(BUILD_PYTHON_INTERFACE) UNSET({libname}) ENDFOREACH(lib) @@ -73,10 +75,12 @@ INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) TARGET_LINK_LIBRARIES(dp-dynamic ${LIBRARY_NAME}) # Install empty __init__.py files in intermediate directories. -INSTALL(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/dynamics_pinocchio/__init__.py - ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/dynamics_pinocchio/humanoid_robot.py - ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/dynamics_pinocchio/tools.py - ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/dynamics_pinocchio/parser.py - DESTINATION ${PYTHON_SITELIB}/dynamic_graph/sot/dynamics_pinocchio - ) +IF(BUILD_PYTHON_INTERFACE) + INSTALL(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/dynamics_pinocchio/__init__.py + ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/dynamics_pinocchio/humanoid_robot.py + ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/dynamics_pinocchio/tools.py + ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/dynamics_pinocchio/parser.py + DESTINATION ${PYTHON_SITELIB}/dynamic_graph/sot/dynamics_pinocchio + ) +ENDIF(BUILD_PYTHON_INTERFACE) diff --git a/unitTesting/CMakeLists.txt b/unitTesting/CMakeLists.txt index 3247e7f..e456016 100644 --- a/unitTesting/CMakeLists.txt +++ b/unitTesting/CMakeLists.txt @@ -52,8 +52,6 @@ FOREACH(test ${tests}) SET(EXECUTABLE_NAME "${test}_exe") ADD_EXECUTABLE(${EXECUTABLE_NAME} ${test}.cpp) - MESSAGE("PYTHON_INCLUDE_PATH: ${PYTHON_INCLUDE_PATH}") - INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} dp-zmpreffromcom @@ -70,7 +68,9 @@ FOREACH(test ${tests}) PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} pinocchio) PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} sot-core) PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} dynamic-graph) - PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} dynamic-graph-python) + IF(BUILD_PYTHON_INTERFACE) + PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} dynamic-graph-python) + ENDIF(BUILD_PYTHON_INTERFACE) IF(${test}_plugins_dependencies) ADD_DEPENDENCIES(${EXECUTABLE_NAME} "${${test}_plugins_dependencies}") -- GitLab