target_compile_features standard overrides more recent standard passed through target_compile_options
Given the following CMakeLists.txt :
project(main) add_library(mylib main.cpp) target_compile_features(mylib PUBLIC cxx_alias_templates) target_compile_options(mylib PUBLIC -std=c++1z)
main.cpp ends up being compiled with :
/usr/bin/c++ -std=c++1z -std=gnu++11 -o CMakeFiles/mylib.dir/main.o -c /tmp/testcase/main.cpp
which puts GCC in C++11 mode instead of C++17.
CMAKE_CXX_STANDARD correctly overrides it, however there is currently no way to use C++1z with it.
target_compile_features call is not an option for me since it is not in my code, but in the CMake code of a library I link to (Qt).
Could a solution be to put the "cmake-detected" -std=c++something at the beginning of the compile flags instead of the end ?