[CMake] Enabling C++0x support

Guido Winkelmann guido-cm at unknownsite.de
Wed May 4 17:58:56 EDT 2011


Is there a way to specify, in a cross-platform compatible manner, that a given 
C++ source file (or a target or an entire project) requires support for C++ 0x, 
so that whatever compiler flags would be necessary for that for the current 
platform and compiler will be set?

For example, when using GCC, you need to pass "-std=c++0x" as an argument to 
the compiler in order to get C++0x support. I could just set(CMAKE_CXX_FLAGS 
"-std=c++0x"), but that's not really portable... the current platform might 
use a different compiler that needs a different option to enable C++ 0x and 
won't understand "-std=c++0x", or, at some point in the future, it might use a 
GCC release which makes 0x the default and does not even need a special flag.


More information about the CMake mailing list