ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OK, I finally solved the problem. These were the solutions that had no effect in CMakeLists.txt as they got overridden:

  • add_compile_options(-std=c++14)
  • set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
  • target_compile_options(targetName PRIVATE -std=c++14)

I also tried to set compile options in catkin environment and configuration, but still no effect. What finally worked, after reading about CMAKE_CXX_STANDARD, was to force CMAKE C++ standard at the beginning of CMakeLists.txt:

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

My guess is that some other library managed to set it to version 11 somehow (although I did not find any evidence). CMAKE_CXX_STANDARD obviously overwrites the options set in any other way, even those that are set later in the file.

OK, I finally solved the problem. These were the solutions that had no effect in CMakeLists.txt as they got overridden:

  • add_compile_options(-std=c++14)
  • set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
  • target_compile_options(targetName PRIVATE -std=c++14)

I also tried to set compile options in catkin environment and configuration, but still no effect. What finally worked, after reading about CMAKE_CXX_STANDARD, was to force CMAKE C++ standard at the beginning of CMakeLists.txt:

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

My guess is that some other library managed to set it to version 11 somehow (although I did not find any evidence). CMAKE_CXX_STANDARD obviously overwrites the options set in any other way, even those that are set later in the file.