c++ - How to enable C++17 in CMake -
i'm using vs 15.3, supports integrated cmake 3.8. how can target c++17 without writing flags each specific compilers? current global settings don't work:
# https://cmake.org/cmake/help/latest/prop_tgt/cxx_standard.html set(cmake_cxx_standard 17) set(cmake_cxx_standard_required on) set(cmake_cxx_extensions off) # expected behaviour #set(cmake_cxx_flags "${cmake_cxx_flags} /std:c++lastest")
i expected cmake add "/std:c++lastest" or equivalents when generating vs solution files, no c++17 flags found, resulted in compiler error:
c1189 #error: class template optional available c++17.
you can keep set(cmake_cxx_standard 17)
other compilers, clang , gcc. visual studio, it's useless.
if cmake still doesn't support this, can following:
if(msvc) set(cmake_cxx_flags "${cmake_cxx_flags} /std:c++17") endif(msvc)
Comments
Post a Comment