Skip to content

Commit

Permalink
Use global cmake macros
Browse files Browse the repository at this point in the history
  • Loading branch information
christophfroehlich committed Feb 5, 2025
1 parent 5486fcd commit 968d128
Show file tree
Hide file tree
Showing 23 changed files with 110 additions and 194 deletions.
12 changes: 3 additions & 9 deletions ackermann_steering_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(ackermann_steering_controller)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

# find dependencies
set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down
12 changes: 3 additions & 9 deletions admittance_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(admittance_controller)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
angles
Expand Down
12 changes: 3 additions & 9 deletions bicycle_steering_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(bicycle_steering_controller)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

# find dependencies
set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down
12 changes: 3 additions & 9 deletions diff_drive_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(diff_drive_controller)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
control_toolbox
Expand Down
12 changes: 3 additions & 9 deletions effort_controllers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(effort_controllers)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
forward_command_controller
Expand Down
12 changes: 3 additions & 9 deletions force_torque_sensor_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(force_torque_sensor_broadcaster)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
controller_interface
Expand Down
12 changes: 3 additions & 9 deletions forward_command_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(forward_command_controller)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
controller_interface
Expand Down
12 changes: 3 additions & 9 deletions gpio_controllers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.8)
project(gpio_controllers)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

# find dependencies
find_package(ament_cmake REQUIRED)
Expand Down
12 changes: 3 additions & 9 deletions gripper_controllers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(gripper_controllers)

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
control_msgs
Expand Down
12 changes: 3 additions & 9 deletions imu_sensor_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(imu_sensor_broadcaster)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
controller_interface
Expand Down
12 changes: 3 additions & 9 deletions joint_state_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(joint_state_broadcaster)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
builtin_interfaces
Expand Down
12 changes: 3 additions & 9 deletions joint_trajectory_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(joint_trajectory_controller)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
angles
Expand Down
12 changes: 3 additions & 9 deletions mecanum_drive_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(mecanum_drive_controller)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

# find dependencies
set(THIS_PACKAGE_INCLUDE_DEPENDS
Expand Down
8 changes: 3 additions & 5 deletions parallel_gripper_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(parallel_gripper_controller)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
control_msgs
Expand Down
12 changes: 3 additions & 9 deletions pid_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(pid_controller)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

if(WIN32)
add_compile_definitions(
Expand Down
12 changes: 3 additions & 9 deletions pose_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(pose_broadcaster)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
controller_interface
Expand Down
12 changes: 3 additions & 9 deletions position_controllers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(position_controllers)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
forward_command_controller
Expand Down
12 changes: 3 additions & 9 deletions range_sensor_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format -Werror=range-loop-construct
-Werror=missing-braces)
endif()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(../ros2_controllers.cmake)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
controller_interface
Expand Down
44 changes: 44 additions & 0 deletions ros2_controllers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2025 AIT - Austrian Institute of Technology GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# set compiler options depending on detected compiler
macro(set_compiler_options)
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=conversion -Werror=unused-but-set-variable
-Werror=return-type -Werror=shadow -Werror=format
-Werror=missing-braces)
message(STATUS "Compiler warnings enabled for ${CMAKE_CXX_COMPILER_ID}")

# Extract major version if g++ is used
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET VERSION_LIST 0 GCC_MAJOR_VERSION)
list(GET VERSION_LIST 1 GCC_MINOR_VERSION)

message(STATUS "Detected GCC Version: ${CMAKE_CXX_COMPILER_VERSION} (Major: ${GCC_MAJOR_VERSION}, Minor: ${GCC_MINOR_VERSION})")

if (GCC_MAJOR_VERSION GREATER 10)
# GCC 11 introduced -Werror=range-loop-construct
add_compile_options(-Werror=range-loop-construct)
endif()
endif()
endif()
endmacro()

# using this instead of visibility macros
# S1 from https://github.com/ros-controls/ros2_controllers/issues/1053
macro(export_windows_symbols)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endmacro()
Loading

0 comments on commit 968d128

Please sign in to comment.