CD86
CD86

Reputation: 1089

cmake target_compile_features C++17

Adhering to the best practice for modern CMake I want to use this command instead of flags or set-based commands. However, I cant seem to make it work, since I cannot find associated commands for the newly introduced C++17 features. For C++14 I can do something along the following lines

target_compile_features(Foo
  PUBLIC
    cxx_strong_enums
  PRIVATE
    cxx_lambdas
)

I guess what I am asking is, what is the proper way to enable the latest standard of C++ in cmake without resorting back to legacy cmake

Upvotes: 1

Views: 2594

Answers (1)

Florian
Florian

Reputation: 42912

You're going in the right direction, you may just need to update your CMake version.

It started with CMake Version 3.8:

The Compile Features functionality is now aware of C++ 17. No specific features are yet enumerated besides the cxx_std_17 meta-feature.

For VS you need e.g. at least CMake Version 3.10.

References

Upvotes: 2

Related Questions