[CMake] Clang not using C++11 on Linux

Rolf Eike Beer eike at sf-mail.de
Sun Jan 18 03:58:24 EST 2015


Am Samstag, 17. Januar 2015, 19:09:38 schrieb Robert Dailey:
> I'm running a custom built CMake 3.1 on Ubuntu Server 12. I have Clang
> 3.4 installed. At the top of my root CMakeLists.txt, I have enabled
> C++11 like so:
> 
> cmake_minimum_required( VERSION 3.1 )
> if( UNIX )
>     set( CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++" )
> endif()
> project( FrontEnd )

[…]

> How do I get C++11 working?

Set the compiler flags after project(). The compiler is detected in project(), 
and then CMake initializes all the flag variables, so you changes will get 
overwritten.

If you just want to enable C++11 with CMake 3.1 then do

 set(CMAKE_CXX_STANDARD 11)

after the project call and CMake will take care of the rest.

Greetings,

Eike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150118/6f605d3a/attachment.sig>


More information about the CMake mailing list