How to enable C++17 in CMake

前端 未结 6 1657
旧时难觅i
旧时难觅i 2020-12-05 22:45

I\'m using VS 15.3, which supports integrated CMake 3.8. How can I target C++17 without writing flags for each specific compilers? My current global settings don\'t work:

6条回答
  •  难免孤独
    2020-12-05 22:49

    You can keep that set(CMAKE_CXX_STANDARD 17) for other compilers, like Clang and GCC. But for Visual Studio, it's useless.

    If CMake still doesn't support this, you can do the following:

    if(MSVC)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
    endif(MSVC)
    

提交回复
热议问题