I have a rather large application configured in CMake. I have recently added a couple of classes that use C++0x functionality, and it breaks the build, since CMake is not configured to compile with C++0x support. How do I add that as an option to CMake?
You need to add the flag to CMAKE_CXX_FLAGS
:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
I use this snippet for GCC, but it is a more complicated way:
if(CMAKE_COMPILER_IS_GNUCXX)
SET(ENABLE_CXX11 "-std=c++11")
EXECUTE_PROCESS(COMMAND "${CMAKE_CXX_COMPILER} -dumpversion" OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_LESS 4.7)
SET(ENABLE_CXX11 "-std=c++0x")
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ENABLE_CXX11}")
endif()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With