Skip to content

Commit

Permalink
Added cmake flags for ROS2 + colcon
Browse files Browse the repository at this point in the history
  • Loading branch information
shuhaowu committed Jul 17, 2024
1 parent 60a547f commit c44efd2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
51 changes: 30 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(ENABLE_CLANG_TIDY "Run clang-tidy" OFF)
option(ENABLE_EXAMPLES "Build example programs" ON)
option(ENABLE_TRACING "Enable runtime tracing support" ON)
option(ENABLE_ROS2_SUPPORT "Enables ROS2 support" OFF)
option(BUILD_DOCS "Build documentations" OFF)

# Used for building cactus-rt when all dependencies are vendored
Expand Down Expand Up @@ -104,8 +105,10 @@ endfunction()
# Cactus RT library #
#####################

if (ENABLE_TRACING)
add_subdirectory(protos)
if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
if (ENABLE_TRACING)
add_subdirectory(protos)
endif()
endif()

add_library(cactus_rt
Expand Down Expand Up @@ -133,28 +136,28 @@ target_link_libraries(cactus_rt
# Use a bounded queue
target_compile_definitions(cactus_rt PUBLIC QUILL_USE_BOUNDED_QUEUE)

if (ENABLE_TRACING)
target_sources(cactus_rt
PRIVATE
src/cactus_rt/tracing/sink.cc
src/cactus_rt/tracing/thread_tracer.cc
src/cactus_rt/tracing/trace_aggregator.cc
src/cactus_rt/tracing/tracing_enabled.cc
src/cactus_rt/tracing/utils/string_interner.cc
)
if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
if (ENABLE_TRACING)
target_sources(cactus_rt
PRIVATE
src/cactus_rt/tracing/sink.cc
src/cactus_rt/tracing/thread_tracer.cc
src/cactus_rt/tracing/trace_aggregator.cc
src/cactus_rt/tracing/tracing_enabled.cc
src/cactus_rt/tracing/utils/string_interner.cc
)

target_link_libraries(cactus_rt
PUBLIC
cactus_tracing_embedded_perfetto_protos
)
target_link_libraries(cactus_rt
PUBLIC
cactus_tracing_embedded_perfetto_protos
)

target_compile_definitions(cactus_rt
PUBLIC
CACTUS_RT_TRACING_ENABLED=1
)
endif()
target_compile_definitions(cactus_rt
PUBLIC
CACTUS_RT_TRACING_ENABLED=1
)
endif()

if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
if (ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY clang-tidy clang-tidy-18 clang-tidy-17 clang-tidy-16 clang-tidy-15 clang-tidy-14)
else()
Expand All @@ -164,6 +167,12 @@ endif()

setup_cactus_rt_target_options(cactus_rt)

if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
if (ENABLE_ROS2_SUPPORT)
message(STATUS "Enabling ROS2 with cactus-rt")
endif()
endif()

# Build tests, examples, docs, only if this project is not embedded in another
# project.
if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
Expand Down
3 changes: 3 additions & 0 deletions colcon.pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
cmake-args:
- "-DENABLE_ROS2_SUPPORT=ON"

0 comments on commit c44efd2

Please sign in to comment.