library needs atleast cpp14 but if cpp17 is available, it unlocks more features. I tried the below.
cmake_minimum_required(VERSION 3.10)
project(dummy)
add_library(awesomelib STATIC awesomelib.cpp awesomelib.h)
target_compile_features(awesomelib INTERFACE cxx_std_14)
add_executable(dummy14 main.cpp)
target_link_libraries(dummy14 awesomelib)
target_compile_features(dummy14 PRIVATE cxx_std_14)
add_executable(dummy17 main.cpp)
target_link_libraries(dummy17 awesomelib)
target_compile_features(dummy17 PRIVATE cxx_std_17)
What I want is:
- dummy14 to compile using the C++14 standard
- dummy17 and awesomelib to compile using the C++17 standard
But what happens is that awesomelib is compiled (only once) according to the c++14 std.
Update
I have shown the executables in the same file for simplicity. In real setup, the library would be in a separate project/repository and the users will be in a different project. I am looking for how the library can advertise its minimum requirements. i.e it needs at least c++14 standard and depending on the user, it has to be compiled with whatever latest version the user has.


