Programmatically select cxx_std_<yy> meta features

Hey all

I’m working on packaging abseil-cpp for conda-forge; abseil already uses target_compile_features, but sets it only to cxx_std_11, which is to my understanding not correct if abseil itself is compiled with a newer C++ standard (the API changes based on the C++ version, e.g. whether it’s using std::string_view or absl::string_view).

In the “old world” (see else-clause in link above), the feature level could be set dynamically, à la:

      set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD})
      set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)

But I’m wondering how to dynamically set the meta feature in the new world, à la:

target_compile_features(${_NAME} PUBLIC cxx_std_<MY_STANDARD>)

Is this possible, and if yes, how? If no, it would seem like a feature gap in the “new world” to me, but maybe I’m looking at this wrong…?

Thanks,
H.

target_compile_features(${_NAME} PUBLIC cxx_std_${ABSL_CXX_STANDARD})

should work.

Thanks for the quick response. Wasn’t sure that would work. :slight_smile: