Skip to content

Commit

Permalink
Merge pull request #485 from jorisv/topic/workspace
Browse files Browse the repository at this point in the history
Enable jrl-cmakemodules workspace compatiblity
  • Loading branch information
jorisv authored Jul 24, 2024
2 parents 615b427 + c66ee14 commit bbc26ed
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/conda/environment_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:
- eigen
- cmake
- numpy
- numpy<2.0
- pkg-config
- boost
- ccache
Expand Down
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 ([#485](https://github.com/stack-of-tasks/eigenpy/pull/485))

## [3.7.0] - 2024-06-11

### Added
Expand Down
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ set(PROJECT_USE_CMAKE_EXPORT TRUE)
set(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
set(PROJECT_CUSTOM_HEADER_EXTENSION "hpp")
set(PROJECT_COMPATIBILITY_VERSION AnyNewerVersion)
# 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})

# Check if the submodule cmake have been initialized
set(JRL_CMAKE_MODULES "${CMAKE_CURRENT_LIST_DIR}/cmake")
Expand Down Expand Up @@ -344,10 +348,12 @@ set(${PROJECT_NAME}_SOURCES

add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
set_standard_output_directory(${PROJECT_NAME})
target_include_directories(
${PROJECT_NAME} SYSTEM
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

modernize_target_link_libraries(
Expand Down Expand Up @@ -450,3 +456,5 @@ pkg_config_append_libs(${PROJECT_NAME})
pkg_config_append_cflags("-I${PYTHON_INCLUDE_DIRS}")
pkg_config_append_cflags("-I${NUMPY_INCLUDE_DIRS}")
pkg_config_append_boost_libs(${BOOST_COMPONENTS})

setup_project_finalize()
2 changes: 1 addition & 1 deletion cmake
6 changes: 3 additions & 3 deletions doc/Doxyfile.extra.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
INPUT = @CMAKE_SOURCE_DIR@/src \
@CMAKE_SOURCE_DIR@/doc/additionalDoc
IMAGE_PATH = @CMAKE_SOURCE_DIR@/doc/pictures
INPUT = @PROJECT_SOURCE_DIR@/src \
@PROJECT_SOURCE_DIR@/doc/additionalDoc
IMAGE_PATH = @PROJECT_SOURCE_DIR@/doc/pictures

FILE_PATTERNS = *.cc *.cpp *.h *.hpp *.hxx

Expand Down
15 changes: 8 additions & 7 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ make_directory("${${PROJECT_NAME}_BINARY_DIR}/python/${PROJECT_NAME}")
include(${JRL_CMAKE_MODULES}/python-helpers.cmake)
include("${JRL_CMAKE_MODULES}/stubs.cmake")

add_custom_target(python)
set_target_properties(python PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True)
add_custom_target(${PROJECT_NAME}_python)
set_target_properties(${PROJECT_NAME}_python
PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True)

add_library(${PYWRAP} MODULE main.cpp)
add_dependencies(python ${PYWRAP})
add_dependencies(${PROJECT_NAME}_python ${PYWRAP})
target_link_libraries(${PYWRAP} PUBLIC ${PROJECT_NAME})

python_build_get_target(python_build_target)
Expand All @@ -40,13 +41,13 @@ set_target_properties(
PROPERTIES PREFIX ""
SUFFIX ${PYTHON_EXT_SUFFIX}
LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/python/${PROJECT_NAME}"
LIBRARY_OUTPUT_DIRECTORY_<CONFIG>
"${CMAKE_BINARY_DIR}/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/python/${PROJECT_NAME}"
RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/python/${PROJECT_NAME}"
RUNTIME_OUTPUT_DIRECTORY_<CONFIG>
"${CMAKE_BINARY_DIR}/python/${PROJECT_NAME}")
"${PROJECT_BINARY_DIR}/python/${PROJECT_NAME}")

if(UNIX)
get_relative_rpath(${${PYWRAP}_INSTALL_DIR} ${PYWRAP}_INSTALL_RPATH)
Expand Down
48 changes: 28 additions & 20 deletions unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@
# Copyright (c) 2014-2019 CNRS Copyright (c) 2018-2024 INRIA
#

macro(ADD_LIB_UNIT_TEST test)
function(ADD_LIB_UNIT_TEST test)
create_ctest_build_tests_target()
set(test_target ${PROJECT_NAME}-${test})

if(BUILD_TESTING)
add_library(${test} SHARED "${test}.cpp")
else(BUILD_TESTING)
add_library(${test} SHARED EXCLUDE_FROM_ALL "${test}.cpp")
endif(BUILD_TESTING)
set_standard_output_directory(${test})
add_library(${test_target} SHARED "${test}.cpp")
else()
add_library(${test_target} SHARED EXCLUDE_FROM_ALL "${test}.cpp")
endif()
set_standard_output_directory(${test_target})

target_link_libraries(${test} PUBLIC ${PROJECT_NAME})
set_target_properties(${test} PROPERTIES PREFIX "")
target_link_libraries(${test_target} PUBLIC ${PROJECT_NAME})
set_target_properties(
${test_target}
PROPERTIES PREFIX ""
LIBRARY_OUTPUT_NAME ${test}
RUNTIME_OUTPUT_NAME ${test})

set_target_properties(${test} PROPERTIES SUFFIX ${PYTHON_EXT_SUFFIX})
set_target_properties(${test_target} PROPERTIES SUFFIX ${PYTHON_EXT_SUFFIX})

add_test(
NAME ${test}
NAME ${test_target}
COMMAND ${PYTHON_EXECUTABLE} -c "import ${test}"
WORKING_DIRECTORY $<TARGET_FILE_DIR:${test}>)
WORKING_DIRECTORY $<TARGET_FILE_DIR:${test_target}>)

add_dependencies(build_tests ${test})
add_dependencies(build_tests ${test_target})
if(NOT BUILD_TESTING)
set_tests_properties(${test} PROPERTIES DEPENDS ctest_build_tests)
set_tests_properties(${test_target} PROPERTIES DEPENDS ctest_build_tests)
endif(NOT BUILD_TESTING)
endmacro(ADD_LIB_UNIT_TEST)
endfunction()

add_dependencies(build_tests ${PYWRAP})
add_lib_unit_test(matrix)
Expand Down Expand Up @@ -58,17 +63,20 @@ if(CMAKE_CXX_STANDARD GREATER 14 AND CMAKE_CXX_STANDARD LESS 98)
endif()

function(add_python_lib_unit_test name source)
add_python_unit_test(${name} ${source} "lib" "bin")
set(test_target ${PROJECT_NAME}-${name})
add_python_unit_test(${test_target} ${source} "lib" "bin")
endfunction()

function(add_python_eigenpy_lib_unit_test name source)
add_python_unit_test(${name} ${source} "lib" "bin" "python")
set_tests_properties(${name} PROPERTIES DEPENDS ${PYWRAP})
set(test_target ${PROJECT_NAME}-${name})
add_python_unit_test(${test_target} ${source} "lib" "bin" "python")
set_tests_properties(${test_target} PROPERTIES DEPENDS ${PYWRAP})
endfunction()

function(add_python_eigenpy_unit_test name source)
add_python_unit_test(${name} ${source} "python")
set_tests_properties(${name} PROPERTIES DEPENDS ${PYWRAP})
set(test_target ${PROJECT_NAME}-${name})
add_python_unit_test(${test_target} ${source} "python")
set_tests_properties(${test_target} PROPERTIES DEPENDS ${PYWRAP})
endfunction()

function(config_test test tagname opttype)
Expand All @@ -80,7 +88,7 @@ function(config_test test tagname opttype)
configure_file(python/test_${test}.py.in
${CMAKE_CURRENT_BINARY_DIR}/python/${py_file})
add_lib_unit_test(${MODNAME})
set(PYTHON_TEST_NAME "py-${test}-${tagname}")
set(PYTHON_TEST_NAME "${PROJECT_NAME}-py-${test}-${tagname}")
add_test(NAME ${PYTHON_TEST_NAME}
COMMAND ${PYTHON_EXECUTABLE}
"${CMAKE_CURRENT_BINARY_DIR}/python/${py_file}")
Expand Down
2 changes: 1 addition & 1 deletion unittest/python/test_user_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ def test_cast(from_dtype, to_dtype):

v = user_type.CustomDouble(1)
a = np.array(v)
assert type(v) == a.dtype.type
assert type(v) is a.dtype.type

0 comments on commit bbc26ed

Please sign in to comment.