I need to replace the /std:c++14
flag of an INTERFACE
target (header-only library) with /std:c++17
. CMake doesn't support setting C++17 flags in VS directly yet (see How to enable /std:c++17 in VS2017 with CMake) so I need to manually replace it.
However get_target_property(my_compile_flags mylib COMPILE_OPTIONS)
to retrieve the list of currently set flags to then subsequently replace /std:c++14 with /std:c++17 doesn't work:
INTERFACE_LIBRARY targets may only have whitelisted properties. The property "COMPILE_OPTIONS" is not allowed.
You can set them however via target_compile_features(...)
and manually via e.g. target_compile_options(mylib INTERFACE /std:c++17)
. But the latter command adds the flag, without removing /std:c++14
.
How to go about that?