在CMake中启用VS2017的C++17特性

VS2017的C++17特性默认并未开启,需要在编译参数中手动开启。找到项目的CMakeLists.txt,在查找编译器的代码后面加入如下内容即可。

if (MSVC_VERSION GREATER_EQUAL "1900")
    include(CheckCXXCompilerFlag)
    CHECK_CXX_COMPILER_FLAG("/std:c++latest" _cpp_latest_flag_supported)
    if (_cpp_latest_flag_supported)
        add_compile_options("/std:c++latest")
    endif()
endif()

猜你喜欢

转载自www.cnblogs.com/airscrat/p/10152348.html