diff --git a/CHANGELOG.md b/CHANGELOG.md index 90ccc65..8ef7a3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Added +- Add compatibility with jrl-cmakemodules workspace ([#225](https://github.com/Gepetto/example-robot-data/pull/225)) + ## [4.1.0] - 2024-01-29 - added CHANGELOG.md in https://github.com/Gepetto/example-robot-data/pull/193 diff --git a/CMakeLists.txt b/CMakeLists.txt index 978a137..54886a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ set(PROJECT_NAME example-robot-data) set(PROJECT_DESCRIPTION "Set of robot URDFs for benchmarking and developed examples") set(PROJECT_URL https://github.com/${PROJECT_ORG}/${PROJECT_NAME}) +# To enable jrl-cmakemodules compatibility with workspace we must define the two +# following lines +set(PROJECT_AUTO_RUN_FINALIZE FALSE) +set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) # Project options option(BUILD_PYTHON_INTERFACE "Build the python unit tests and helpers" ON) @@ -51,6 +55,7 @@ endif() # JRL-cmakemodule setup include("${JRL_CMAKE_MODULES}/base.cmake") +include("${JRL_CMAKE_MODULES}/python.cmake") # Print initial message message(STATUS "${PROJECT_DESCRIPTION}, version ${PROJECT_VERSION}") @@ -67,20 +72,26 @@ if(BUILD_PYTHON_INTERFACE) add_project_dependency(eigenpy 3.0.0 REQUIRED) add_project_dependency(pinocchio 2.7.0 REQUIRED) string(REGEX REPLACE "-" "_" PY_NAME ${PROJECT_NAME}) + findpython(REQUIRED) add_subdirectory(python) if(BUILD_TESTING) add_subdirectory(unittest) endif(BUILD_TESTING) -endif(BUILD_PYTHON_INTERFACE) +endif() if(NOT INSTALL_PYTHON_INTERFACE_ONLY) add_library(${PROJECT_NAME} INTERFACE) - target_include_directories(${PROJECT_NAME} - INTERFACE $) + add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + target_include_directories( + ${PROJECT_NAME} + INTERFACE $ + $ + $) target_compile_definitions( ${PROJECT_NAME} INTERFACE - EXAMPLE_ROBOT_DATA_MODEL_DIR="$/share/${PROJECT_NAME}/robots" + $/share/${PROJECT_NAME}/robots"> + $ ) install( TARGETS ${PROJECT_NAME} @@ -91,4 +102,6 @@ if(NOT INSTALL_PYTHON_INTERFACE_ONLY) DESTINATION include/${CUSTOM_HEADER_DIR}) install(DIRECTORY robots DESTINATION share/${PROJECT_NAME}) install(FILES package.xml DESTINATION share/${PROJECT_NAME}) -endif(NOT INSTALL_PYTHON_INTERFACE_ONLY) +endif() + +setup_project_finalize() diff --git a/cmake b/cmake index 7faf6f9..91b8f5f 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 7faf6f9c4e981111bf0ac5dff4970f0959c11f69 +Subproject commit 91b8f5f2168b123a198da079b8e6c09fd1f60285 diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 6f889dc..1fdfb13 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -2,7 +2,7 @@ set(${PROJECT_NAME}_PYTHON_FILES robots_loader.py __main__.py __init__.py) foreach(python ${${PROJECT_NAME}_PYTHON_FILES}) python_install_on_site(${PY_NAME} ${python}) -endforeach(python ${${PROJECT_NAME}_PYTHON_FILES}) +endforeach() configure_file(${PY_NAME}/path.py.in ${PY_NAME}/path.py) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PY_NAME}/path.py diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index a157b67..686b67f 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1,13 +1,6 @@ -if(NOT pinocchio_FOUND) - message( - FATAL_ERROR - "Pinocchio is required to build unit tests\n" - "please either install Pinocchio or reconfigure without unit tests (-DBUILD_TESTING=OFF)" - ) -endif(NOT pinocchio_FOUND) - set(${PROJECT_NAME}_PYTHON_TESTS load) foreach(TEST ${${PROJECT_NAME}_PYTHON_TESTS}) - add_python_unit_test("py-${TEST}" "unittest/test_${TEST}.py" python) -endforeach(TEST ${${PROJECT_NAME}_PYTHON_TESTS}) + add_python_unit_test("${PROJECT_NAME}-py-${TEST}" "unittest/test_${TEST}.py" + python) +endforeach()