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

How to enter compiler flags into CMakeLists

asked 2016-07-20 10:32:56 -0500

Cerin gravatar image

When I compile my ROS code, I'm getting a ton of warnings like:

warning: extended initializer lists only available with -std=c++11 or -std=gnu++11

According to this SO question I need to add -std=c++0x to my compiler's flags.

I see in my auto-generated CMakeLists.txt, there's already the commented-out option:

 #set(CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")

so I changed that to:

 set(CMAKE_C_FLAGS "-std=c++0x ${CMAKE_C_FLAGS}")

However, when I re-run catkin_make --pkg mypackage I still see these warnings. I tried the other flags suggested in the SO question, but the output is the same. Why is CMake ignoring CMAKE_C_FLAGS?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2016-07-20 11:11:11 -0500

ahendrix gravatar image

CMAKE_C_FLAGS are for compiling C files, but you're building C++ files, so you need to set the CMAKE_CXX_FLAGS variable.

The CMake documentation includes a list of useful variables and describes what they're used for.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-07-20 10:32:56 -0500

Seen: 4,489 times

Last updated: Jul 20 '16