在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()

 

posted @ 2018-12-20 21:08  松山居士  阅读(5700)  评论(0编辑  收藏  举报