Skip to content

Commit e1ba5ff

Browse files
committed
[cmake] update to make sure all options work
+ make building with Crocoddyl support a dependent option on Pinocchio support
1 parent 7df44b8 commit e1ba5ff

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

CMakeLists.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ option(ENABLE_TEMPLATE_INSTANTIATION "Template instantiation of the main library
124124

125125
# --- OPTIONAL DEPENDENCIES -------------------------
126126
option(BUILD_WITH_PINOCCHIO_SUPPORT "Build the library with support for Pinocchio" ON)
127-
option(BUILD_CROCODDYL_COMPAT "Build the Crocoddyl compatibility module" OFF)
127+
cmake_dependent_option(
128+
BUILD_CROCODDYL_COMPAT "Build the Crocoddyl compatibility module" OFF
129+
BUILD_WITH_PINOCCHIO_SUPPORT OFF
130+
)
128131
option(BUILD_WITH_OPENMP_SUPPORT "Build the library with the OpenMP support" ON)
129132
option(BUILD_WITH_CHOLMOD_SUPPORT "Build with support for backends enabled by Cholmod" OFF)
130133
option(BUILD_BENCHMARKS "Build benchmarks" ON)
@@ -360,15 +363,13 @@ macro(create_ex_or_bench exfile exname)
360363
target_include_directories(${exname} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
361364

362365
target_link_libraries(${exname} PUBLIC ${PROJECT_NAME})
363-
target_link_libraries(${exname} PUBLIC example-robot-data::example-robot-data)
364-
endmacro()
365-
366-
macro(target_add_example_robot_data target_name)
367-
target_link_libraries(${target_name} PRIVATE example-robot-data::example-robot-data)
368366
endmacro()
369367

370368
if(BUILD_WITH_PINOCCHIO_SUPPORT AND (BUILD_EXAMPLES OR BUILD_BENCHMARKS))
371369
add_project_private_dependency(example-robot-data 4.0.9 REQUIRED)
370+
macro(target_add_example_robot_data target_name)
371+
target_link_libraries(${target_name} PRIVATE example-robot-data::example-robot-data)
372+
endmacro()
372373
endif()
373374

374375
# create an utility library to avoid recompiling crocoddyl talos arm problem
@@ -392,11 +393,11 @@ if(BUILD_BENCHMARKS OR BUILD_TESTING)
392393
set_standard_output_directory(gar_test_utils)
393394
endif()
394395

395-
if(${pinocchio_VERSION} VERSION_GREATER "2.9.0")
396+
if(BUILD_WITH_PINOCCHIO_SUPPORT AND ${pinocchio_VERSION} VERSION_GREATER "2.9.0")
396397
set(PINOCCHIO_V3 True)
397398
endif()
398399

399-
if(PINOCCHIO_V3)
400+
if(PINOCCHIO_V3 AND (BUILD_EXAMPLES OR BUILD_BENCHMARKS))
400401
add_library(
401402
talos_walk_utils STATIC ${PROJECT_SOURCE_DIR}/examples/talos-walk-utils.cpp
402403
${PROJECT_SOURCE_DIR}/examples/talos-walk-utils.hpp

examples/CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,16 @@ function(create_example_with_croco exfile)
1616
target_link_libraries(${exname} PRIVATE aligator::croc_compat croc_talos_arm_utils)
1717
endfunction()
1818

19-
function(create_example_with_walk exfile)
20-
create_example(${exfile})
21-
target_add_talos_walk(${exname})
22-
endfunction()
23-
2419
create_example(se2-car.cpp)
2520
create_example(clqr.cpp)
2621
if(PINOCCHIO_V3)
27-
create_example_with_walk(talos-walk.cpp)
22+
create_example(talos-walk.cpp)
23+
target_add_talos_walk(${exname})
2824
endif()
2925

3026
if(BUILD_CROCODDYL_COMPAT)
3127
create_example_with_croco(talos-arm.cpp)
32-
target_add_example_robot_data(${PROJECT_NAME}-example-talos-arm)
28+
target_add_example_robot_data(${exname})
3329
endif()
3430

3531
file(GLOB EXAMPLES_PY *.py)

0 commit comments

Comments
 (0)