Skip to content

Commit

Permalink
Fix osqp_interface dependencies (tier4#66)
Browse files Browse the repository at this point in the history
* [osqp_interface] fix eigen3 dependencies

fixes tier4#63

* Fix link order in consumers of osqp_interface
  • Loading branch information
fred-apex-ai authored and nik-tier4 committed Nov 26, 2020
1 parent 392a9fd commit a311ad5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
20 changes: 10 additions & 10 deletions common/math/osqp_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ 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)

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()
6 changes: 4 additions & 2 deletions common/math/osqp_interface/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
<license>Apache 2</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>eigen3_cmake_module</buildtool_depend>
<buildtool_export_depend>eigen3_cmake_module</buildtool_export_depend>
<build_depend>eigen</build_depend>
<build_export_depend>eigen</build_export_depend>

<depend>osqp_vendor</depend>

<export>
<build_type>ament_cmake</build_type>
</export>

<depend>rclcpp</depend>
</package>

0 comments on commit a311ad5

Please sign in to comment.