jeudi 16 avril 2015

How to define transitive CXX_STANDARD C++11 in Cmake

I have a header only C++11 library, so I want to configure it, using CMake > 3.1, compile features seems reasonable way to do so:



target_compile_features(my_header_lib INTERFACE cxx_range_for)


But I would prefer not having to indicate individual features, but just C++11 or C++14. Then I could try to use the following:



set_property(TARGET my_target PROPERTY CXX_STANDARD 11)


The problem is that my_target cannot be INTERFACE here, it is not supported, and I cannot define it PUBLIC, so consumers (many EXEs) of my header only library will automatically have the C++11 configuration propagated from the lib.


Is there some way to define at a high level 11/14 standard, but also configure it for a header only (INTERFACE) library? I would prefer not to fall back to old manual -std=c++11.


Aucun commentaire:

Enregistrer un commentaire