Use ament_cmake_ros_core::ament_ros_defaults instead of setting CMAKE_C_STANDARD or CMAKE_CXX_STANDARD
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 74/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- c, cmake
- Domain
- build-system
Research direction
Start with rmw/CMakeLists.txt and rmw_security_common/CMakeLists.txt, then check each package.xml for the required ament_cmake_ros_core dependency. Remove manual C and C++ standard settings, add the required find_package call, and link every listed target to ament_cmake_ros_core::ament_ros_defaults. Done means both packages use the shared defaults and exported libraries declare the dependency when required.
Written by the indexing model from the issue text.
Description
These packages manually set the C or C++ standard using CMAKE_C_STANDARD or CMAKE_CXX_STANDARD. Instead, we should use ament_cmake_ros_core::ament_ros_defaults. This target automatically sets the C and C++ standard versions to the right version for a given ROS distribution.
To make this change for each package listed below:
- Add
<buildtool_depend>ament_cmake_ros_core</buildtool_depend>(and<buildtool_export_depend>ament_cmake_ros_core</buildtool_export_depend>if exporting a library target) to the package'spackage.xmlif it is not already present. - Delete the lines in
CMakeLists.txtthat setCMAKE_C_STANDARD,CMAKE_CXX_STANDARD, orCMAKE_CXX_STANDARD_REQUIRED. - Make sure
CMakeLists.txtcallsfind_package(ament_cmake_ros_core REQUIRED). - Link every target (libraries, executables, and tests) in
CMakeLists.txtagainstament_cmake_ros_core::ament_ros_defaultsusingtarget_link_libraries(). You can usePUBLICorPRIVATEvisibility (preferPUBLICby default for libraries because headers likely use the latest standard,PRIVATEfor executables/tests, orINTERFACEforINTERFACElibraries). If a library target is exported and usesPUBLICorINTERFACE, also passament_cmake_ros_coretoament_export_dependencies().
Example
In package.xml:
<buildtool_depend>ament_cmake_ros_core</buildtool_depend>
<buildtool_export_depend>ament_cmake_ros_core</buildtool_export_depend>
Before (CMakeLists.txt):
# Default to C++20
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
find_package(ament_cmake_ros REQUIRED)
add_library(my_library src/my_library.cpp)
target_link_libraries(my_library PUBLIC
rcutils::rcutils
)
After (CMakeLists.txt):
find_package(ament_cmake_ros REQUIRED)
find_package(ament_cmake_ros_core REQUIRED)
add_library(my_library src/my_library.cpp)
target_link_libraries(my_library PUBLIC
ament_cmake_ros_core::ament_ros_defaults
rcutils::rcutils
)
Files to modify
rmw/CMakeLists.txtrmw_security_common/CMakeLists.txt
- Dominant language
- C
- Stars
- 121
- Forks
- 89
- Avg merge
- 17h 40m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ros2/rmw
-
Delete ament_export_include_directories() and ament_export_libraries() callsMay be free again @EkenoSamson claimed this 62 days ago, and no pull request is open. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
-
Service request timeouts missing in RCL → RMW interactionMay be free again @JEnoch claimed this 420 days ago, and no pull request is open. Openenhancement
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Similar issues
-
area/docdb kind/failing-test priority/medium status/awaiting-triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
yugabyte/yugabyte-db#39462 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
libreswan/libreswan#3185 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days