Skip to content

Instantly share code, notes, and snippets.

@orensbruli
Forked from dirk-thomas/CMakeLists.txt
Created March 7, 2023 06:04
Show Gist options
  • Save orensbruli/e5cddb33493463c44342fcd9743a4b31 to your computer and use it in GitHub Desktop.
Save orensbruli/e5cddb33493463c44342fcd9743a4b31 to your computer and use it in GitHub Desktop.
CMakeLists.txt example with ament auto
cmake_minimum_required(VERSION 2.8.3)
project(foo)
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
endif()
# find dependencies
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()
# message generation
ament_auto_generate_code()
# setup targets
ament_auto_add_library(foo_lib src/lib.cpp)
ament_auto_add_executable(foo_bin src/bin.cpp)
# export information to downstream packages
ament_auto_package(
CONFIG_EXTRAS "foo-extras.cmake"
)
# tests
if(AMENT_ENABLE_TESTING)
find_package(ament_cmake_gtest REQUIRED)
ament_add_gtest(foo_gtest test/my_test.cpp)
target_link_libraries(foo_gtest ${rclcpp_LIBRARIES} ${rmw_connext_cpp_LIBRARIES} ${std_interfaces})
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment