In my CMakeList.txt file, I have the following in order to add c++11 supports:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
This works fine under Mac with Xcode. However, I get the following warning message from Visual Studio. Any idea?
Command line warning D9002: ignoring unknown option '-std=c++0x'
Other than the compile warning, the program gets compile and run with no problem. I am using VS2013. If I remove that single "set flag" line, the warning goes away.
The -std=c++11
option is for GCC/CLang only, it is not available in Visual Studio. C++ 11 support in Visual Studio should be turned on by default. So, you should use this option for GCC-like compilers only:
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
If you are using the latest versions of CMake you might try to use new compiler features mechanism : http://www.cmake.org/cmake/help/v3.1/manual/cmake-compile-features.7.html