In my CMakeList.txt file, I have the following in order to add c++11 supports:
在我CMakeList。在txt文件中,我有以下命令来添加c++11支持:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
集(CMAKE_CXX_FLAGS " $ { CMAKE_CXX_FLAGS }化c + + 11”)
This works fine under Mac with Xcode. However, I get the following warning message from Visual Studio. Any idea?
这在Mac下很好用Xcode。但是,我从Visual Studio得到以下警告消息。任何想法?
Command line warning D9002: ignoring unknown option '-std=c++0x'
命令行警告D9002:忽略未知选项'-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.
除了编译警告之外,程序还可以毫无问题地编译和运行。我用VS2013。如果我删除了那个单一的“设置标志”行,警告就会消失。
1 个解决方案
#1
6
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:
std=c++11选项只适用于GCC/CLang,在Visual Studio中是不可用的。默认情况下,在Visual Studio中支持c++ 11。因此,您应该仅为gcc类编译器使用此选项:
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
如果您使用的是最新版本的CMake,您可能会尝试使用新的编译器特性机制:http://www.cmake.org/cmake/help/v3.1/manual/cmake- compi_features.7.html。
#1
6
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:
std=c++11选项只适用于GCC/CLang,在Visual Studio中是不可用的。默认情况下,在Visual Studio中支持c++ 11。因此,您应该仅为gcc类编译器使用此选项:
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
如果您使用的是最新版本的CMake,您可能会尝试使用新的编译器特性机制:http://www.cmake.org/cmake/help/v3.1/manual/cmake- compi_features.7.html。