Add ament_set_default_language_standards#621
Conversation
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
|
Pulls: #621 |
|
Pulls: ros2/rcutils#548, #621 |
sloretz
left a comment
There was a problem hiding this comment.
Since the language standards are specific to the ROS distro release, I recommend putting this into ament_cmake_ros instead of ament_cmake_core
There was a problem hiding this comment.
Seems great, nice time and space saver, will simplify distro upgrades.
ament_cmake_ros makes sense hypothetically from @sloretz comment, though that package currently only contains some ros-specific cmake testing helpers. A bit unclear what the real intended scope of the package is, and how it differentiates from ament_cmake_ros_core - I was even under an impression it was "semi-deprecated" as we continue to focus on use of modern CMake targets and have fewer ament magic calls per package - but that could be a really old and misinformed thought.
|
I just realized, this is the old style version of setting the C++ standard, and not the modern one. The modern version would be to generate an interface target, and to link against it. add_library(default_cpp_standard INTERFACE)
target_compile_features(default_cpp_standard INTERFACE cxx_std_20)target_link_libraries(my_app PRIVATE default_cpp_standard)You can play the same game with targets for more warnings etc... I think this is more what we want, as it propagates down to consuming packages of rclcpp if we link public and export correctly. |
|
Also while we are here do we want to include something for |
fujitatomoya
left a comment
There was a problem hiding this comment.
i do like this refactoring to avoid the duplication and keep the consistency over repositories.
wjwwood
left a comment
There was a problem hiding this comment.
I had one comment that I think should be resolved before merging, and an open question about the pr in general:
Should we do this here or in ament_cmake_ros/ament_cmake_ros_core (https://github.com/ros2/ament_cmake_ros)? I feel like these settings are part of "ROS's policies", not necessarily everyone who may use ament_cmake. On the other hand, there could be room for a "default for everyone who uses ament_cmake" too, but then I'd wonder why the CMake defaults are not sufficient.
|
|
||
| # C | ||
| if(NOT DEFINED CMAKE_C_STANDARD) | ||
| set(CMAKE_C_STANDARD 17) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@sloretz I know you proposed C17, do you have thoughts?
|
I just read the other comments, sorry. I agree with @sloretz. |
|
Sorry I haven't had time to update this ticket. We discussed at pmc today to move into ament_cmake_ros_core |
I think the important lines are here: Which default us to shared libraries and add the |
jmachowinski
left a comment
There was a problem hiding this comment.
Don't set the standard globally, but do it via an interface target
|
Moved to ros2/ament_cmake_ros#62 |
Can use one point as a single source of truth for C++/C version.