I have a simple CMake (3.9.4) project with 3 libraries.
Basic library is an INTERFACE one (header only). It's using some features from C++17 that are present in Visual Studio (like constexpr if). Obviously I try to set a target property so that it propagated to dependent libraries.
I've tried:
target_compile_features(my_lib INTERFACE cxx_std_17)
But nothing changed.
Second attempt was:
set_target_properties(my_lib PROPERITES CXX_STANDARD 17)
But I get:
CMake Error at cpp/CMakeLists.txt:20 (set_target_properties):
INTERFACE_LIBRARY targets may only have whitelisted properties. The
property "CXX_STANDARD" is not allowed.
Finally I ended up with:
target_compile_options(bit INTERFACE /std:c++17)
which works fine. Is this a correct solution? Taking a look at all the compile features I believe there should be something better I can do. Also that forces me to wrap the above command in some kind of if(MSVC) ... endif()
shenanigans.