From b1b3f84b993405e611cd10ddf151242994216124 Mon Sep 17 00:00:00 2001 From: Kenji Miyake Date: Tue, 3 May 2022 07:53:34 +0900 Subject: [PATCH 1/2] feat: add autoware_cmake package Signed-off-by: Kenji Miyake --- autoware_cmake/CMakeLists.txt | 20 +++++++++ autoware_cmake/README.md | 19 +++++++++ autoware_cmake/autoware_cmake-extras.cmake | 15 +++++++ autoware_cmake/cmake/autoware_package.cmake | 45 +++++++++++++++++++++ autoware_cmake/package.xml | 18 +++++++++ 5 files changed, 117 insertions(+) create mode 100644 autoware_cmake/CMakeLists.txt create mode 100644 autoware_cmake/README.md create mode 100644 autoware_cmake/autoware_cmake-extras.cmake create mode 100644 autoware_cmake/cmake/autoware_package.cmake create mode 100644 autoware_cmake/package.xml diff --git a/autoware_cmake/CMakeLists.txt b/autoware_cmake/CMakeLists.txt new file mode 100644 index 00000000..2689b2e2 --- /dev/null +++ b/autoware_cmake/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.5) + +project(autoware_cmake NONE) + +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() + +list(APPEND ${PROJECT_NAME}_CONFIG_EXTRAS + "autoware_cmake-extras.cmake" +) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + +ament_auto_package( + INSTALL_TO_SHARE + cmake +) diff --git a/autoware_cmake/README.md b/autoware_cmake/README.md new file mode 100644 index 00000000..8c6e2a39 --- /dev/null +++ b/autoware_cmake/README.md @@ -0,0 +1,19 @@ +# autoware_cmake + +This package provides CMake scripts for Autoware. + +## Usage + +### autoware_package.cmake + +Call `autoware_package()` before defining build targets, which will set common options for Autoware. + +```cmake +cmake_minimum_required(VERSION 3.5) +project(package_name) + +find_package(autoware_cmake REQUIRED) +autoware_package() + +ament_auto_add_library(...) +``` diff --git a/autoware_cmake/autoware_cmake-extras.cmake b/autoware_cmake/autoware_cmake-extras.cmake new file mode 100644 index 00000000..08caf9fa --- /dev/null +++ b/autoware_cmake/autoware_cmake-extras.cmake @@ -0,0 +1,15 @@ +# Copyright 2022 The Autoware Contributors +# +# 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. + +include("${autoware_cmake_DIR}/autoware_package.cmake") diff --git a/autoware_cmake/cmake/autoware_package.cmake b/autoware_cmake/cmake/autoware_package.cmake new file mode 100644 index 00000000..af2660a5 --- /dev/null +++ b/autoware_cmake/cmake/autoware_package.cmake @@ -0,0 +1,45 @@ +# Copyright 2022 The Autoware Contributors +# +# 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. + +macro(autoware_package) + # Set compile options + if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) + endif() + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic -Werror) + endif() + + # Set ROS_DISTRO macros + set(ROS_DISTRO $ENV{ROS_DISTRO}) + if(${ROS_DISTRO} STREQUAL "rolling") + add_definitions(-DROS_DISTRO_ROLLING) + elseif(${ROS_DISTRO} STREQUAL "galactic") + add_definitions(-DROS_DISTRO_GALACTIC) + elseif(${ROS_DISTRO} STREQUAL "humble") + add_definitions(-DROS_DISTRO_HUMBLE) + endif() + + # Find dependencies + find_package(ament_cmake_auto REQUIRED) + ament_auto_find_build_dependencies() + + # Find test dependencies + if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() + endif() +endmacro() diff --git a/autoware_cmake/package.xml b/autoware_cmake/package.xml new file mode 100644 index 00000000..acc9fdcb --- /dev/null +++ b/autoware_cmake/package.xml @@ -0,0 +1,18 @@ + + + + autoware_cmake + 0.1.0 + CMake scripts for Autoware + Kenji Miyake + Apache License 2.0 + + ament_cmake_auto + + ament_lint_auto + autoware_lint_common + + + ament_cmake + + From 28a58b9201838a70df98e336d8882257e5f85834 Mon Sep 17 00:00:00 2001 From: Kenji Miyake Date: Wed, 4 May 2022 04:46:22 +0900 Subject: [PATCH 2/2] ignore PCL errors in clang Signed-off-by: Kenji Miyake --- autoware_cmake/cmake/autoware_package.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autoware_cmake/cmake/autoware_package.cmake b/autoware_cmake/cmake/autoware_package.cmake index af2660a5..ea490b4f 100644 --- a/autoware_cmake/cmake/autoware_package.cmake +++ b/autoware_cmake/cmake/autoware_package.cmake @@ -23,6 +23,11 @@ macro(autoware_package) add_compile_options(-Wall -Wextra -Wpedantic -Werror) endif() + # Ignore PCL errors in Clang + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wno-gnu-anonymous-struct -Wno-nested-anon-types) + endif() + # Set ROS_DISTRO macros set(ROS_DISTRO $ENV{ROS_DISTRO}) if(${ROS_DISTRO} STREQUAL "rolling")