diff --git a/common/math/osqp_interface/CMakeLists.txt b/common/math/osqp_interface/CMakeLists.txt index 10b40c51ee..14aee2e78b 100644 --- a/common/math/osqp_interface/CMakeLists.txt +++ b/common/math/osqp_interface/CMakeLists.txt @@ -12,6 +12,7 @@ endif() find_package(ament_cmake_auto REQUIRED) ament_auto_find_build_dependencies() +find_package(eigen3_cmake_module REQUIRED) find_package(Eigen3 REQUIRED) find_package(osqp_vendor REQUIRED) @@ -19,21 +20,20 @@ find_package(osqp_vendor REQUIRED) find_package(osqp REQUIRED) get_target_property(OSQP_INCLUDE_DIR osqp::osqpstatic INTERFACE_INCLUDE_DIRECTORIES) -set(EXTERNAL_INCLUDE_DIRS - "${EIGEN3_INCLUDE_DIR}" - "${OSQP_INCLUDE_DIR}" - ) - -ament_auto_add_library(osqp_interface +ament_auto_add_library(osqp_interface STATIC src/osqp_interface.cpp src/csc_matrix_conv.cpp include/osqp_interface/osqp_interface.h include/osqp_interface/csc_matrix_conv.h ) -target_link_libraries(osqp_interface osqp::osqpstatic) -target_include_directories(osqp_interface PUBLIC "${EXTERNAL_INCLUDE_DIRS}") -# needed so clients of this package don't need to worry about includes of this package -ament_export_include_directories("${EXTERNAL_INCLUDE_DIRS}") +target_include_directories(osqp_interface PUBLIC "${OSQP_INCLUDE_DIR}") +ament_target_dependencies(osqp_interface Eigen3) +ament_target_dependencies(osqp_interface osqp_vendor) + +# crucial so downstream package builds because osqp_interface exposes osqp.h +ament_export_include_directories("${OSQP_INCLUDE_DIR}") +# crucial so the linking order is correct in a downstream package: libosqp_interface.a should come before libosqp.a +ament_export_libraries(osqp::osqpstatic) ament_auto_package() diff --git a/common/math/osqp_interface/package.xml b/common/math/osqp_interface/package.xml index b2c862b6d5..3b7d190488 100644 --- a/common/math/osqp_interface/package.xml +++ b/common/math/osqp_interface/package.xml @@ -7,12 +7,14 @@ Apache 2 ament_cmake + eigen3_cmake_module + eigen3_cmake_module + eigen + eigen osqp_vendor ament_cmake - - rclcpp