I'm in the process of splitting a library of mine into a header-only lib and a compiled lib, so, for the first time, I'm trying to use CMake to "build", or rather expose, a header-only library.
Reading this and the CMake documentation, I understand I need to use an INTERFACE library, without sources. But - my headers must be compiled with a C++ language standard version of at least C++11. When I was actually compiling something, I made do with:
set_property(TARGET foo PROPERTY CXX_STANDARD 11)
set_property(TARGET foo PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET foo PROPERTY CXX_EXTENSIONS OFF)
but that's:
- Not exactly what I need for code using the header-only lib - I need to say "at least C++11".
- Can't be used on INTERFACE libraries.
I noticed there is no set_property(... INTERFACE)
. So how am I suppoed to force dependent code to use C++11-or-later?
Edit: I am interested both in answers for constraining an exact C++ version choice in dependents, and for constraining "at least" - in case the latter is problematic/difficult/impossible.