Skip to content

Commit

Permalink
Merge pull request #339 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 8787130 + f733f5c commit 4045f58
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 49 deletions.
2 changes: 0 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@
[submodule "external/cereal"]
path = external/cereal
url = https://github.com/USCiLab/cereal.git
[submodule "cmake"]
url = https://github.com/jrl-umi3218/jrl-cmakemodules.git
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Added
* Allow use of installed cereal and jrl-cmakemodules via cmake
* Add compatibility with jrl-cmakemodules workspace ([#339](https://github.com/Simple-Robotics/proxsuite/pull/339))

## [0.6.6] - 2024-06-15

Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

cmake_minimum_required(VERSION 3.10)

if(DEFINED PROJECT_NAME)
if(DEFINED PROJECT_NAME AND NOT PROJECT_WORKSPACE)
set(PROXSUITE_AS_SUBPROJECT ON)
endif()

Expand All @@ -14,6 +14,10 @@ set(PROJECT_URL "http://github.com/Simple-Robotics/proxsuite")
set(PROJECT_CUSTOM_HEADER_EXTENSION "hpp")
set(PROJECT_USE_CMAKE_EXPORT TRUE)
set(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
# 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-module")
Expand Down Expand Up @@ -241,3 +245,5 @@ if(BUILD_PYTHON_INTERFACE)
FILES ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/python_path.dsv
DESTINATION share/${PROJECT_NAME}/hook)
endif(BUILD_PYTHON_INTERFACE)

setup_project_finalize()
4 changes: 2 additions & 2 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_custom_target(bench)
add_custom_target(${PROJECT_NAME}_bench)

macro(proxsuite_benchmark bench_name)
if(BUILD_BENCHMARK)
Expand All @@ -12,7 +12,7 @@ macro(proxsuite_benchmark bench_name)
else()
target_link_libraries(${bench_name} PUBLIC proxsuite)
endif()
add_dependencies(bench ${bench_name})
add_dependencies(${PROJECT_NAME}_bench ${bench_name})
endmacro(proxsuite_benchmark)

proxsuite_benchmark(timings-lp)
Expand Down
32 changes: 16 additions & 16 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/external/pybind11)
add_subdirectory(external/pybind11
${CMAKE_CURRENT_BINARY_DIR}/external/pybind11)

add_custom_target(python)
add_custom_target(${PROJECT_NAME}_python)

# Collect files
file(GLOB_RECURSE PYWRAP_HEADERS ${CMAKE_CURRENT_LIST_DIR}/src/*.hpp)
Expand All @@ -27,26 +27,26 @@ file(GLOB_RECURSE PYWRAP_SOURCES ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp)
# Add simd feature detectors for current intel CPU
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
python3_add_library(instructionset MODULE helpers/instruction-set.cpp)
add_dependencies(python instructionset)
add_dependencies(${PROJECT_NAME}_python instructionset)
target_link_libraries(instructionset PRIVATE proxsuite pybind11::module)
set_target_properties(
instructionset
PROPERTIES OUTPUT_NAME instructionset
PREFIX ""
SUFFIX ${PYTHON_EXT_SUFFIX}
LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
LIBRARY_OUTPUT_DIRECTORY_RELEASE
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
LIBRARY_OUTPUT_DIRECTORY_DEBUG
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
# On Windows, shared library are treat as binary
RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}")
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}")
if(UNIX AND NOT APPLE)
set_target_properties(instructionset PROPERTIES INSTALL_RPATH
"\$ORIGIN/../../..")
Expand All @@ -70,7 +70,7 @@ endfunction(list_filter)

function(CREATE_PYTHON_TARGET target_name COMPILE_OPTIONS dependencies)
python3_add_library(${target_name} MODULE ${PYWRAP_SOURCES} ${PYWRAP_HEADERS})
add_dependencies(python ${target_name})
add_dependencies(${PROJECT_NAME}_python ${target_name})

target_link_libraries(${target_name} PUBLIC ${dependencies} pybind11::module)
target_compile_options(${target_name} PRIVATE ${COMPILE_OPTIONS})
Expand Down Expand Up @@ -104,18 +104,18 @@ function(CREATE_PYTHON_TARGET target_name COMPILE_OPTIONS dependencies)
PREFIX ""
SUFFIX ${PYTHON_EXT_SUFFIX}
LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
LIBRARY_OUTPUT_DIRECTORY_RELEASE
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
LIBRARY_OUTPUT_DIRECTORY_DEBUG
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
# On Windows, shared library are treat as binary
RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}")
"${PROJECT_BINARY_DIR}/bindings/python/${PROJECT_NAME}")

if(UNIX AND NOT APPLE)
set_target_properties(${target_name} PROPERTIES INSTALL_RPATH
Expand Down Expand Up @@ -195,7 +195,7 @@ else()
endif()

python_build_get_target(compile_pyc)
add_dependencies(python ${compile_pyc})
add_dependencies(${PROJECT_NAME}_python ${compile_pyc})

set(PYTHON_FILES torch/__init__.py torch/qplayer.py torch/utils.py)

Expand Down
2 changes: 1 addition & 1 deletion cmake-module
6 changes: 3 additions & 3 deletions doc/Doxyfile.extra.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
INPUT = @CMAKE_SOURCE_DIR@/doc \
@CMAKE_SOURCE_DIR@/include \
INPUT = @PROJECT_SOURCE_DIR@/doc \
@PROJECT_SOURCE_DIR@/include \

RECURSIVE = YES

Expand Down Expand Up @@ -54,7 +54,7 @@ SOURCE_BROWSER = YES

ALPHABETICAL_INDEX = YES

USE_MDFILE_AS_MAINPAGE = @CMAKE_SOURCE_DIR@/doc/1-Overview.md
USE_MDFILE_AS_MAINPAGE = @PROJECT_SOURCE_DIR@/doc/1-Overview.md

BUILTIN_STL_SUPPORT = YES
HAVE_DOT = YES
Expand Down
8 changes: 4 additions & 4 deletions examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# Copyright (c) 2022 INRIA
#

add_custom_target(example-cpp)
add_custom_target(${PROJECT_NAME}-example-cpp)

function(ADD_PROXSUITE_CPP_EXAMPLE EXAMPLE)
get_filename_component(EXAMPLE_NAME ${EXAMPLE} NAME_WE)
set(EXAMPLE_TARGET "example-cpp-${EXAMPLE_NAME}")
set(EXAMPLE_TARGET "${PROJECT_NAME}-example-cpp-${EXAMPLE_NAME}")
add_unit_test(${EXAMPLE_TARGET} "${EXAMPLE}")
target_link_libraries(${EXAMPLE_TARGET} PRIVATE proxsuite-test-util)

add_dependencies(example-cpp ${EXAMPLE_TARGET})
add_dependencies(${PROJECT_NAME}-example-cpp ${EXAMPLE_TARGET})
endfunction()

file(GLOB_RECURSE ${PROJECT_NAME}_CPP_EXAMPLES *.cpp)

foreach(EXAMPLE ${${PROJECT_NAME}_CPP_EXAMPLES})
add_proxsuite_cpp_example(${EXAMPLE})
endforeach(EXAMPLE ${${PROJECT_NAME}_CPP_EXAMPLES})
endforeach()
5 changes: 3 additions & 2 deletions examples/julia/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ file(GLOB_RECURSE ${PROJECT_NAME}_JULIA_EXAMPLES *.jl)
foreach(EXAMPLE ${${PROJECT_NAME}_JULIA_EXAMPLES})
string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/examples/julia/" "" EXAMPLE
${EXAMPLE})
add_julia_unit_test("example-jl-${EXAMPLE}" "examples/julia/${EXAMPLE}")
endforeach(EXAMPLE ${${PROJECT_NAME}_JULIA_EXAMPLES})
add_julia_unit_test("${PROJECT_NAME}-example-jl-${EXAMPLE}"
"examples/julia/${EXAMPLE}")
endforeach()
6 changes: 3 additions & 3 deletions examples/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ file(GLOB_RECURSE ${PROJECT_NAME}_PYTHON_EXAMPLES *.py)
foreach(EXAMPLE_FILE ${${PROJECT_NAME}_PYTHON_EXAMPLES})
get_filename_component(EXAMPLE_NAME ${EXAMPLE_FILE} NAME_WE)
string(REGEX REPLACE "${PROJECT_SOURCE_DIR}" "" EXAMPLE_FILE ${EXAMPLE_FILE})
add_python_unit_test("example-py-${EXAMPLE_NAME}" "${EXAMPLE_FILE}"
"bindings/python")
endforeach(EXAMPLE_FILE ${${PROJECT_NAME}_PYTHON_EXAMPLES})
add_python_unit_test("${PROJECT_NAME}-example-py-${EXAMPLE_NAME}"
"${EXAMPLE_FILE}" "bindings/python")
endforeach()
32 changes: 17 additions & 15 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
include(../cmake-external/doctest.cmake)
find_package(Matio REQUIRED)

add_library(doctest STATIC doctest/doctest.cpp)
target_include_directories(doctest PUBLIC ./doctest)
add_library(${PROJECT_NAME}-doctest STATIC doctest/doctest.cpp)
target_include_directories(${PROJECT_NAME}-doctest PUBLIC ./doctest)
add_library(cnpy OBJECT src/cnpy.cpp)
target_link_libraries(cnpy Eigen3::Eigen)
target_include_directories(cnpy PUBLIC ./include)
Expand All @@ -20,13 +20,14 @@ else()
endif()

macro(proxsuite_test name path)
add_executable(test-cpp-${name} ${path})
doctest_discover_tests(test-cpp-${name})
target_link_libraries(test-cpp-${name} PUBLIC proxsuite doctest
proxsuite-test-util)
target_compile_definitions(test-cpp-${name}
set(target_name ${PROJECT_NAME}-test-cpp-${name})
add_executable(${target_name} ${path})
# doctest_discover_tests(${target_name})
target_link_libraries(${target_name} PUBLIC proxsuite ${PROJECT_NAME}-doctest
proxsuite-test-util)
target_compile_definitions(${target_name}
PRIVATE PROBLEM_PATH="${CMAKE_CURRENT_SOURCE_DIR}")
add_dependencies(build_tests test-cpp-${name})
add_dependencies(build_tests ${target_name})
endmacro()

proxsuite_test(dense_ruiz_equilibration src/dense_ruiz_equilibration.cpp)
Expand All @@ -45,7 +46,8 @@ proxsuite_test(cvxpy src/cvxpy.cpp)

if(BUILD_WITH_OPENMP_SUPPORT)
proxsuite_test(parallel src/parallel_qp_solve.cpp)
target_link_libraries(test-cpp-parallel PRIVATE OpenMP::OpenMP_CXX)
target_link_libraries(${PROJECT_NAME}-test-cpp-parallel
PRIVATE OpenMP::OpenMP_CXX)
endif()

# Test serialization
Expand All @@ -54,19 +56,19 @@ macro(ADD_TEST_CFLAGS target flag)
TARGET ${target}
APPEND_STRING
PROPERTY COMPILE_FLAGS " ${flag}")
endmacro(ADD_TEST_CFLAGS)
endmacro()

make_directory("${CMAKE_CURRENT_BINARY_DIR}/serialization-data")
proxsuite_test(serialization src/serialization.cpp)
add_test_cflags(
test-cpp-serialization
${PROJECT_NAME}-test-cpp-serialization
"-DTEST_SERIALIZATION_FOLDER=\\\\\"${CMAKE_CURRENT_BINARY_DIR}/serialization-data\\\\\""
)
if(cereal_FOUND)
target_link_libraries(test-cpp-serialization PRIVATE cereal)
target_link_libraries(${PROJECT_NAME}-test-cpp-serialization PRIVATE cereal)
else()
target_include_directories(
test-cpp-serialization SYSTEM
${PROJECT_NAME}-test-cpp-serialization SYSTEM
PRIVATE ${PROJECT_SOURCE_DIR}/external/cereal/include)
endif()

Expand All @@ -87,7 +89,7 @@ if(BUILD_PYTHON_INTERFACE)
foreach(TEST_FILE ${${PROJECT_NAME}_PYTHON_UNITTEST})
get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE)
string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/" "" TEST_FILE ${TEST_FILE})
add_python_unit_test("test-py-${TEST_NAME}" "${TEST_FILE}"
add_python_unit_test("${PROJECT_NAME}-test-py-${TEST_NAME}" "${TEST_FILE}"
"bindings/python")
endforeach(TEST_FILE ${${PROJECT_NAME}_PYTHON_UNITTEST})
endforeach()
endif(BUILD_PYTHON_INTERFACE)

0 comments on commit 4045f58

Please sign in to comment.