This can be used to set the compiler features required by particular targets. An error is issued at CMake time if the compiler does not support the required feature. If a language dialect flag is required by the features used, that will be added automatically. Base the target_compile_features command on cmTargetPropCommandBase. This gives us 'free' handling of IMPORTED, ALIAS, INTERFACE, non-compilable and missing targets.
18 lines
419 B
CMake
18 lines
419 B
CMake
cmake_minimum_required(VERSION 3.0)
|
|
project(target_compile_features)
|
|
|
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
add_executable(target_compile_features main.cpp)
|
|
target_compile_features(target_compile_features
|
|
PRIVATE cxx_auto_type
|
|
)
|
|
|
|
add_library(lib_auto_type lib_auto_type.cpp)
|
|
target_compile_features(lib_auto_type
|
|
PUBLIC cxx_auto_type
|
|
)
|
|
|
|
add_executable(lib_user lib_user.cpp)
|
|
target_link_libraries(lib_user lib_auto_type)
|