Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ament_cmake_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include("ament_cmake_core-extras.cmake" NO_POLICY_SCOPE)
include("ament_cmake_environment-extras.cmake" NO_POLICY_SCOPE)
include("ament_cmake_environment_hooks-extras.cmake" NO_POLICY_SCOPE)
include("ament_cmake_index-extras.cmake" NO_POLICY_SCOPE)
include("ament_cmake_language_standards.cmake" NO_POLICY_SCOPE)
include("ament_cmake_uninstall_target-extras.cmake" NO_POLICY_SCOPE)
# must be after uninstall_target
include("ament_cmake_symlink_install-extras.cmake" NO_POLICY_SCOPE)
Expand All @@ -24,6 +25,7 @@ ament_package(
"ament_cmake_environment-extras.cmake"
"ament_cmake_environment_hooks-extras.cmake"
"ament_cmake_index-extras.cmake"
"ament_cmake_language_standards.cmake"
"ament_cmake_package_templates-extras.cmake"
"ament_cmake_uninstall_target-extras.cmake"
"ament_cmake_symlink_install-extras.cmake" # must be after uninstall_target
Expand Down
29 changes: 29 additions & 0 deletions ament_cmake_core/ament_cmake_language_standards.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2026 Open Source Robotics Foundation, Inc.
#
# 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(ament_set_default_language_standards)
# C++
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()

if(NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

# C
if(NOT DEFINED CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 17)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should do this, since Windows does not implement this standard. I would keep it at C11, since Windows (mostly) implements that one.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sloretz I know you proposed C17, do you have thoughts?

endif()
endmacro()
10 changes: 1 addition & 9 deletions ament_cmake_gen_version_h/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@ cmake_minimum_required(VERSION 3.20)
project(ament_cmake_gen_version_h)
find_package(ament_cmake_core REQUIRED)

# GTest needs it, Default to C11
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 11)
endif()
# GTest needs it, Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
ament_set_default_language_standards()

include(CTest)
if(BUILD_TESTING)
Expand Down