Ask Your Question
0

CGAL with -std=c++11

asked 2014-08-25 08:45:48 -0500

galou gravatar image

updated 2014-08-25 17:51:10 -0500

tfoote gravatar image

Hi community,

I have a problem compiling a ROS package with CGAL and "-std=c++11" flag.

Here is a minimal CMakeLists.txt to reproduce the error:

cmake_minimum_required(VERSION 2.8.3)
project(cgal_cmake_flags)

find_package(catkin REQUIRED)

set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} " -std=c++11")

find_package(CGAL REQUIRED COMPONENTS Core)
set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "Don't override flags")
message(CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS})
include(${CGAL_USE_FILE})
message(CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS})

During the cmake process, this line gets printed:

"-- USING CXXFLAGS = '-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2  -frounding-math; -std=c++11 -O3 -DNDEBUG'"

You will notice the semi-colon after -frounding-math. This causes big problems when compiling. I tried "catkin_make -DCGAL_DONT_OVERRIDE_CMAKE_FLAGS=TRUE" but it didn't help.

Does someone has experience setting c++11 standard and using CGAL with catkin?

Thanks a lot, Gaël

edit retag flag offensive close merge delete

Comments

afaik ROS does not support c++11.

dornhege gravatar imagedornhege ( 2014-08-25 08:48:37 -0500 )edit

I didn't know that but I know that I already compiled some of my packages with c++11.

galou gravatar imagegalou ( 2014-08-25 09:04:53 -0500 )edit
2

The current guideline for ROS packages is to not require C++11. It does not prevent packages to build with C++11 if they are aware that this might make them incompatible with platforms which do not support a C++11 compiler yet.

Dirk Thomas gravatar imageDirk Thomas ( 2014-08-25 10:59:43 -0500 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2014-08-25 10:57:59 -0500

Dirk Thomas gravatar image

updated 2014-08-25 11:00:21 -0500

The semicolon is coming from your line changing the CMAKE_CXX_FLAGS. Whenever you set a CMake variable with multiple arguments you are not defining a string variable but a list - and list items are separated with a semicolon in CMake.

Therefore you should set the variable with a single value:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
edit flag offensive delete link more

Comments

This solved the issue. I had to correct this in other packages because the fact to include CGAL in one of my packages modifies CMAKE_CXX_FLAGS for all packages even with

set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "Don't override flags")

galou gravatar imagegalou ( 2014-08-26 01:27:24 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-08-25 08:45:48 -0500

Seen: 1,212 times

Last updated: Aug 25 '14