How to enable C++17 in CMake

前端 未结 6 1641
旧时难觅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:52

    Your approach is the correct one, but it will not work for MSVC on versions of CMake prior to 3.10.

    From the CMake 3.9 documentation:

    For compilers that have no notion of a standard level, such as MSVC, this has no effect.

    In short, CMake haven't been updated to accommodate for the standard flags added to VC++ 2017.

    You have to detect if VC++ 2017 (or later) is used and add the corresponding flags yourself for now.


    In CMake 3.10 (and later) this have been fixed for newer version of VC++. See the 3.10 documentation.

提交回复
热议问题