Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit a031efe

Browse files
committed
[CMake] add INSTALL_PYTHON_INTERFACE_ONLY option
1 parent 6ff3932 commit a031efe

File tree

5 files changed

+57
-111
lines changed

5 files changed

+57
-111
lines changed

CMakeLists.txt

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ INCLUDE(cmake/base.cmake)
66
INCLUDE(cmake/boost.cmake)
77
INCLUDE(cmake/eigen.cmake)
88
INCLUDE(cmake/python.cmake)
9+
INCLUDE(cmake/test.cmake)
910

1011
SET(PROJECT_NAMESPACE stack-of-tasks)
1112
SET(PROJECT_NAME sot-dynamic-pinocchio)
@@ -35,6 +36,8 @@ ADD_REQUIRED_DEPENDENCY("sot-tools >= 2.0.0")
3536
SET(BOOST_COMPONENTS filesystem system unit_test_framework)
3637

3738
OPTION (BUILD_PYTHON_INTERFACE "Build the python binding" ON)
39+
OPTION (INSTALL_PYTHON_INTERFACE_ONLY "Install *ONLY* the python bindings" OFF)
40+
3841
IF(BUILD_PYTHON_INTERFACE)
3942
FINDPYTHON()
4043
ADD_REQUIRED_DEPENDENCY("dynamic-graph-python >= 3.0.0")
@@ -43,31 +46,16 @@ IF(BUILD_PYTHON_INTERFACE)
4346
ADD_REQUIRED_DEPENDENCY("eigenpy")
4447
ENDIF(BUILD_PYTHON_INTERFACE)
4548

46-
47-
# List plug-ins that will be compiled.
48-
SET(plugins
49-
zmpreffromcom
50-
force-compensation
51-
integrator-force-exact
52-
mass-apparent
53-
integrator-force-rk4
54-
integrator-force
55-
angle-estimator
56-
waist-attitude-from-sensor
57-
zmp-from-forces
58-
)
59-
60-
SET(LIBRARY_NAME ${PROJECT_NAME})
61-
LIST(APPEND plugins dynamic)
62-
6349
# Add dependency toward sot-dynamic-pinocchio library in pkg-config file.
64-
PKG_CONFIG_APPEND_LIBS(${LIBRARY_NAME})
50+
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
6551

6652
SEARCH_FOR_BOOST()
6753
SEARCH_FOR_EIGEN()
6854

6955
# Add subdirectories.
70-
ADD_SUBDIRECTORY(include)
56+
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
57+
ADD_SUBDIRECTORY(include/${CUSTOM_HEADER_DIR})
58+
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
7159
ADD_SUBDIRECTORY(src)
7260
ADD_SUBDIRECTORY(doc)
7361
ADD_SUBDIRECTORY(python)

include/CMakeLists.txt

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2010, François Bleibel, Olivier Stasse, JRL, CNRS/AIST
2+
3+
SET(${PROJECT_NAME}_HEADERS
4+
dynamic-pinocchio.h
5+
integrator-force-exact.h
6+
zmpreffromcom.h
7+
integrator-force.h
8+
force-compensation.h
9+
mass-apparent.h
10+
waist-attitude-from-sensor.h
11+
matrix-inertia.h
12+
integrator-force-rk4.h
13+
angle-estimator.h
14+
)
15+
16+
INSTALL(FILES ${${PROJECT_NAME}_HEADERS} DESTINATION include/${CUSTOM_HEADER_DIR})

src/CMakeLists.txt

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
11
# Copyright 2010, François Bleibel, Olivier Stasse, JRL, CNRS/AIST,
22
# Florent Lamiraux (CNRS/LAAS)
33

4-
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
54

6-
# Verbosity level
7-
IF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))
8-
ADD_DEFINITIONS(-DVP_DEBUG_MODE=${CMAKE_VERBOSITY_LEVEL} -DVP_DEBUG)
9-
ENDIF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))
10-
11-
IF(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
12-
ADD_DEFINITIONS(-DDEBUG=2)
13-
ENDIF(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
5+
# Main Library
6+
ADD_LIBRARY(${PROJECT_NAME} SHARED sot-dynamic-pinocchio)
7+
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} pinocchio)
8+
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} sot-core)
9+
PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} dynamic-graph)
10+
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_LIBRARIES})
11+
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
12+
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
13+
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
14+
15+
# List plug-ins that will be compiled.
16+
SET(plugins
17+
zmpreffromcom
18+
force-compensation
19+
integrator-force-exact
20+
mass-apparent
21+
integrator-force-rk4
22+
integrator-force
23+
angle-estimator
24+
waist-attitude-from-sensor
25+
zmp-from-forces
26+
dynamic
27+
)
1428

1529
SET(integrator-force-rk4_plugins_dependencies integrator-force)
1630
SET(integrator-force-exact_plugins_dependencies integrator-force)
1731

1832
FOREACH(lib ${plugins})
1933
SET(libname dp-${lib})
20-
ADD_LIBRARY(${libname} SHARED ${lib}.cpp)
34+
ADD_LIBRARY(${libname} SHARED ${lib})
2135
SET_TARGET_PROPERTIES(${libname} PROPERTIES
2236
PREFIX ""
2337
SOVERSION ${PROJECT_VERSION})
@@ -27,17 +41,16 @@ FOREACH(lib ${plugins})
2741
TARGET_LINK_LIBRARIES(${libname} "dp-${${lib}_plugins_dependencies}")
2842
ENDIF(${lib}_plugins_dependencies)
2943

44+
TARGET_LINK_LIBRARIES(${libname} ${PROJECT_NAME})
3045
TARGET_LINK_LIBRARIES(${libname} ${Boost_LIBRARIES})
3146

3247
PKG_CONFIG_USE_DEPENDENCY(${libname} pinocchio)
33-
IF(BUILD_PYTHON_INTERFACE)
34-
PKG_CONFIG_USE_DEPENDENCY(${libname} eigenpy)
35-
ENDIF(BUILD_PYTHON_INTERFACE)
36-
3748
PKG_CONFIG_USE_DEPENDENCY(${libname} sot-core)
3849
PKG_CONFIG_USE_DEPENDENCY(${libname} dynamic-graph)
3950

40-
INSTALL(TARGETS ${libname} DESTINATION ${DYNAMIC_GRAPH_PLUGINDIR})
51+
IF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
52+
INSTALL(TARGETS ${libname} DESTINATION ${DYNAMIC_GRAPH_PLUGINDIR})
53+
ENDIF(NOT INSTALL_PYTHON_INTERFACE_ONLY)
4154

4255
# build python submodule
4356
IF(BUILD_PYTHON_INTERFACE)
@@ -52,23 +65,8 @@ FOREACH(lib ${plugins})
5265
)
5366
PKG_CONFIG_USE_DEPENDENCY(sot-dynamic-pinocchio-${PYTHON_LIBRARY_NAME}-wrap pinocchio)
5467
ENDIF(BUILD_PYTHON_INTERFACE)
55-
56-
UNSET({libname})
5768
ENDFOREACH(lib)
5869

59-
# Main Library
60-
ADD_LIBRARY(${LIBRARY_NAME} SHARED sot-dynamic-pinocchio.cpp)
61-
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} pinocchio)
62-
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} sot-core)
63-
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} dynamic-graph)
64-
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} pinocchio)
65-
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} sot-core)
66-
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} dynamic-graph)
67-
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES})
68-
INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
69-
70-
TARGET_LINK_LIBRARIES(dp-dynamic ${LIBRARY_NAME})
71-
7270
# Install empty __init__.py files in intermediate directories.
7371
IF(BUILD_PYTHON_INTERFACE)
7472
INSTALL(FILES

unitTesting/CMakeLists.txt

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Copyright 2010, François Bleibel, Olivier Stasse, JRL, CNRS/AIST
22

3-
ADD_DEFINITIONS(-DDEBUG=2)
4-
53
SET(tests
64
test_constructor
75
#test_config
@@ -11,17 +9,11 @@ test_constructor
119
# test_results
1210
)
1311

14-
15-
#----------------------------------------------------
16-
# Install procedure for the urdf files
17-
#----------------------------------------------------
18-
1912
SET(test_dyn_plugins_dependencies dynamic)
2013

2114
# Make Boost.Test generates the main function in test cases.
2215
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
2316

24-
2517
# getting the information for the robot.
2618
#SET(samplemodelpath ${JRL_DYNAMICS_PKGDATAROOTDIR}/jrl-dynamics/examples/data/)
2719
#SET(samplespec
@@ -36,11 +28,9 @@ ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
3628
LIST(APPEND LOGGING_WATCHED_VARIABLES samplespec sampleljr)
3729

3830
FOREACH(test ${tests})
39-
SET(EXECUTABLE_NAME "${test}_exe")
40-
ADD_EXECUTABLE(${EXECUTABLE_NAME}
41-
${test}.cpp)
31+
ADD_UNIT_TEST(${test} ${test})
4232

43-
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME}
33+
TARGET_LINK_LIBRARIES(${test}
4434
dp-zmpreffromcom
4535
dp-force-compensation
4636
#integrator-force-exact
@@ -52,26 +42,14 @@ FOREACH(test ${tests})
5242
${LIBRARY_NAME}
5343
)
5444

55-
PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} pinocchio)
56-
PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} sot-core)
57-
PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} dynamic-graph)
58-
IF(BUILD_PYTHON_INTERFACE)
59-
PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} dynamic-graph-python)
60-
ENDIF(BUILD_PYTHON_INTERFACE)
45+
PKG_CONFIG_USE_DEPENDENCY(${test} pinocchio)
46+
PKG_CONFIG_USE_DEPENDENCY(${test} sot-core)
47+
PKG_CONFIG_USE_DEPENDENCY(${test} dynamic-graph)
6148

6249
IF(${test}_plugins_dependencies)
6350
ADD_DEPENDENCIES(${EXECUTABLE_NAME} "${${test}_plugins_dependencies}")
6451
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} "${${test}_plugins_dependencies}")
6552
ENDIF(${test}_plugins_dependencies)
6653

67-
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${Boost_LIBRARIES} ${Boost_SYSTEM_LIBRARY})
68-
ADD_TEST(${test} ${EXECUTABLE_NAME}
69-
${samplemodelpath} ${samplespec} ${sampleljr} )
70-
71-
IF (UNIX)
72-
SET(EXTRA_LD_LIBRARY_PATH $ENV{LD_LIBRARY_PATH})
73-
SET_PROPERTY(TEST ${test} PROPERTY
74-
ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:${CMAKE_BINARY_DIR}/src:${BOOST_ROOT}/lib:${EXTRA_LD_LIBRARY_PATH}")
75-
ENDIF(UNIX)
76-
54+
TARGET_LINK_LIBRARIES(${test} ${Boost_LIBRARIES} ${Boost_SYSTEM_LIBRARY})
7755
ENDFOREACH(test)

0 commit comments

Comments
 (0)