Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable jrl-cmakemodules workspace compatiblity #225

Merged
merged 6 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 18 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}")
Expand All @@ -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 $<INSTALL_INTERFACE:include>)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_include_directories(
${PROJECT_NAME}
INTERFACE $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_compile_definitions(
${PROJECT_NAME}
INTERFACE
EXAMPLE_ROBOT_DATA_MODEL_DIR="$<INSTALL_PREFIX>/share/${PROJECT_NAME}/robots"
$<INSTALL_INTERFACE:EXAMPLE_ROBOT_DATA_MODEL_DIR="$<INSTALL_PREFIX>/share/${PROJECT_NAME}/robots">
$<BUILD_INTERFACE:EXAMPLE_ROBOT_DATA_MODEL_DIR="${CMAKE_CURRENT_SOURCE_DIR}/robots">
)
install(
TARGETS ${PROJECT_NAME}
Expand All @@ -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()
2 changes: 1 addition & 1 deletion cmake
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 3 additions & 10 deletions unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
cmastalli marked this conversation as resolved.
Show resolved Hide resolved

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()