Repository navigation
Compile options - #221
Compile options#221
Conversation
make ARM happy? pass flag to specific targets explicitly remove todo, compiler come from redefinition of typedef
| macro(set_properties _build_type) | ||
| set_target_properties(${_target_name} PROPERTIES | ||
| COMPILE_FLAGS "${_extension_compile_flags}" | ||
| COMPILE_FLAGS ${_extension_compile_flags} |
There was a problem hiding this comment.
Can't use COMPILE_OPTIONS here because the evaluation of _extension_compile_flags results in a string.
We could work around it by checking the compiler within this macro and make a different call to "set_target_properties" with COMPILE_DEFINITION only if the compiler supports the flags we want
There was a problem hiding this comment.
Currently the variable contains a string. Have you tried to convert it into a list and then use COMPILE_OPTIONS?
| set(_extension_compile_flags "-Wall -Wextra") | ||
| elseif("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") | ||
| if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
| set(_extension_compile_flags "-Wall;-Wextra") |
There was a problem hiding this comment.
I would suggest to not use a semicolon here. Just pass both value parts as separate values and the variable will be a list (same as the add_compile_options invocation above).
|
While this looks good I am not sure CMake allows multiple values per property (see https://cmake.org/cmake/help/v3.5/command/set_target_properties.html). Have you checked that all warning levels are being enabled as desired? |
|
looks like it works as expected: set(a "")
get_target_property(a ${_target_name} COMPILE_OPTIONS)
message(FATAL_ERROR "COMPILE_OPTIONS:${a}")prints: I'll check the compilet invocation tomorrow to confirm that it passes the flags as expected. target_compile_options(${rosidl_generate_interfaces_TARGET}${_target_suffix}
PUBLIC -Wall -Wextra -Wpedantic)or switch back to use the deprecate |
dirk-thomas
left a comment
There was a problem hiding this comment.
Thanks for checking. I am pretty confident that the compiler args are fine if CMake reports the property correctly
|
confirmed passing |
This is part of ros2/ros2#362
I open a PR for this one because there is slightly more change than the other repos.
Connects to ros2/ros2#362