Skip to content

Commit

Permalink
Simplify external projects (#6)
Browse files Browse the repository at this point in the history
* Simplify external projects

* pre-commit

* Revert old repo
  • Loading branch information
rafal-gorecki authored Jan 23, 2025
1 parent 8e7e064 commit 822ea28
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 34 deletions.
20 changes: 9 additions & 11 deletions wibotic_connector_can/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
cmake_minimum_required(VERSION 3.8)
project(wibotic_connector_can)
# Handle superbuild first
option(USE_SUPERBUILD "Whether or not a superbuild should be invoked" ON)

option(USE_SUPERBUILD "Whether or not a superbuild should be invoked" ON)
if(USE_SUPERBUILD)
project(SUPERBUILD NONE)
include(cmake/SuperBuild.cmake)
return()
else()
project(wibotic_connector_can)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand All @@ -24,30 +19,33 @@ endforeach()
include_directories(${CMAKE_INSTALL_PREFIX}/include)

add_library(wibotic_can_driver src/wibotic_can_driver.cpp)
add_dependencies(wibotic_can_driver uavcan linux_uavcan)
target_compile_options(wibotic_can_driver PRIVATE -std=c++11)
target_include_directories(
wibotic_can_driver BEFORE
PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/wibotic_connector_can/ep_platform_specific_components/upstream/linux/libuavcan/uavcan_linux
)
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/uavcan/include
${CMAKE_CURRENT_BINARY_DIR}/linux_uavcan/include)
target_include_directories(
wibotic_can_driver
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

ament_target_dependencies(wibotic_can_driver ${PACKAGE_DEPENDENCIES})

set(UAVCAN_LIB ${CMAKE_INSTALL_PREFIX}/lib/libuavcan.a)
set(UAVCAN_LIB ${CMAKE_CURRENT_BINARY_DIR}/uavcan/lib/libuavcan.a)

target_link_libraries(wibotic_can_driver ${UAVCAN_LIB} rt)

add_executable(wibotic_connector_can src/wibotic_can_driver_node.cpp
src/main.cpp)
add_dependencies(wibotic_can_driver uavcan linux_uavcan)
target_compile_options(wibotic_connector_can PRIVATE -std=c++17)
target_include_directories(
wibotic_connector_can
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
$<INSTALL_INTERFACE:include>
${CMAKE_CURRENT_BINARY_DIR}/uavcan/include
${CMAKE_CURRENT_BINARY_DIR}/linux_uavcan/include)

ament_target_dependencies(wibotic_connector_can ${PACKAGE_DEPENDENCIES})

Expand Down
34 changes: 11 additions & 23 deletions wibotic_connector_can/cmake/SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,26 @@
include(ExternalProject)

ExternalProject_Add(
ep_libuavcan
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/ep_libuavcan/upstream
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
uavcan
# Probable newer repo also will work: https://github.com/dronecan/libuavcan
GIT_REPOSITORY https://github.com/OpenCyphal-Garage/libcyphal/
GIT_TAG dcc3a4de237b7482e04543d2393c3a9385685312
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/ep_libuavcan
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
INSTALL_COMMAND make install INSTALL_PREFIX=<INSTALL_DIR>
UPDATE_DISCONNECTED 1
BUILD_IN_SOURCE 1
STEP_TARGETS build)
PREFIX uavcan
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/uavcan)

ExternalProject_Add(
ep_platform_specific_components
DEPENDS ep_libuavcan
linux_uavcan
DEPENDS uavcan
GIT_REPOSITORY
https://github.com/OpenCyphal-Garage/platform_specific_components/
GIT_TAG 4745ef59f57b7e1c34705b127ea8c7a35e3874c1
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/ep_platform_specific_components
PREFIX linux_uavcan
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND
${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_BINARY_DIR}/ep_platform_specific_components/src/ep_platform_specific_components/linux/libuavcan/include
${CMAKE_INSTALL_PREFIX}/include)
${CMAKE_BINARY_DIR}/linux_uavcan/src/linux_uavcan/linux/libuavcan/include
${CMAKE_BINARY_DIR}/linux_uavcan/include)

install(DIRECTORY ${INSTALL_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX})

ExternalProject_Add(
ep_wibotic_connector_can
DEPENDS ep_platform_specific_components
SOURCE_DIR ${PROJECT_SOURCE_DIR}
CMAKE_ARGS -DUSE_SUPERBUILD=OFF
INSTALL_COMMAND ""
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
install(DIRECTORY ${CMAKE_BINARY_DIR}/uavcan ${CMAKE_BINARY_DIR}/linux_uavcan
DESTINATION include)

0 comments on commit 822ea28

Please sign in to comment.