I have the following content in my CMakeLists.txt:
project( Matfile )
SET ( CMAKE_CXX_FLAGS \"-std=c++0x\" )
set ( SOURCES
\"foo.cpp\"
\"bar.cp
The most straightforward solution should be using add_compile_options() if you are using version 2.8.12 or newer. For older versions you can "abuse" add_definitions(). While it is only meant for add -D flags, it also works with any other compiler flag. However, I think it is not meant to be used that way and could break in a future version.
add_compile_options(-std=c++0x) # CMake 2.8.12 or newer
or
add_definitions(-std=c++0x) # CMake 2.8.11 or older
Starting with CMake 3.3 you can also make this flag only apply to a specific language (e.g. only C or C++) using the strange generator expressions syntax:
add_compile_options($<$:-std=c++14> $<$:-std=c99>)
However this will not work with the Visual studio generator, so make sure to only use this for Make/Ninja generators or use target_compile_options() to set it on a per-target scope.