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

feat: enable to build with both ros1 and ros2 #16

Merged
merged 2 commits into from
Oct 23, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- xmllint
- lint_cmake
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v2.5.0
- uses: ros-tooling/action-ros-lint@0.1.3
with:
linter: ${{ matrix.linter }}
Expand Down
31 changes: 22 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ cmake_minimum_required(VERSION 3.9)

project(osqp_vendor)

find_package(ament_cmake REQUIRED)
find_package(ros_environment REQUIRED)

if($ENV{ROS_VERSION} EQUAL 1)
find_package(catkin REQUIRED)
elseif($ENV{ROS_VERSION} EQUAL 2)
find_package(ament_cmake REQUIRED)
endif()

macro(build_osqp)
set(git_tag "v0.6.2")
Expand All @@ -15,7 +21,7 @@ macro(build_osqp)

include(ExternalProject)
externalproject_add(osqp-${git_tag}
GIT_REPOSITORY https://github.com/oxfordcontrol/osqp.git
GIT_REPOSITORY https://github.com/osqp/osqp.git
GIT_TAG ${git_tag}
GIT_SHALLOW ON
TIMEOUT 60
Expand All @@ -39,12 +45,19 @@ endmacro()

build_osqp()

ament_export_libraries(osqp)
ament_export_dependencies(osqp)
if($ENV{ROS_VERSION} EQUAL 1)
catkin_package(
LIBRARIES osqp
DEPENDS osqp
CFG_EXTRAS osqp_vendor-extras.cmake)
elseif($ENV{ROS_VERSION} EQUAL 2)
ament_export_libraries(osqp)
ament_export_dependencies(osqp)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
ament_package(CONFIG_EXTRAS cmake/osqp_vendor-extras.cmake)
endif()

ament_package(CONFIG_EXTRAS osqp_vendor-extras.cmake)
File renamed without changes.
12 changes: 8 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
<url type="website">https://github.com/oxfordcontrol/osqp</url>
<author email="esteve.fernandez@autoware.org">Esteve Fernandez</author>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend condition="$ROS_VERSION == 1">catkin</buildtool_depend>
<buildtool_depend condition="$ROS_VERSION == 2">ament_cmake</buildtool_depend>
<buildtool_depend>git</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<build_depend>ros_environment</build_depend>

<test_depend condition="$ROS_VERSION == 2">ament_lint_auto</test_depend>
<test_depend condition="$ROS_VERSION == 2">ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
<build_type condition="$ROS_VERSION == 1">catkin</build_type>
<build_type condition="$ROS_VERSION == 2">ament_cmake</build_type>
</export>
</package>