diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2021-06-02 23:19:45 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2021-06-17 18:02:52 (GMT) |
commit | 20ab49193ba1196421909b7910c9e0c7a30fa31f (patch) | |
tree | f056580936a34f6bb349fb6c10d6d3f5e1b31f6d /Tests/IncludeDirectories/SystemIncludeDirectories | |
parent | 809f7b0c3af8d46610ae0963e061415b50f2a363 (diff) | |
download | CMake-20ab49193ba1196421909b7910c9e0c7a30fa31f.zip CMake-20ab49193ba1196421909b7910c9e0c7a30fa31f.tar.gz CMake-20ab49193ba1196421909b7910c9e0c7a30fa31f.tar.bz2 |
Tests/IncludeDirectories: factor out applying flags to targets
Diffstat (limited to 'Tests/IncludeDirectories/SystemIncludeDirectories')
-rw-r--r-- | Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index ff52c98..7874d5e 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -6,9 +6,13 @@ project(SystemIncludeDirectories) add_library(systemlib systemlib.cpp) target_include_directories(systemlib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/systemlib") +function (apply_error_flags target) + target_compile_options(${target} PRIVATE -Werror=unused-variable) +endfunction () + add_library(upstream upstream.cpp) target_link_libraries(upstream LINK_PUBLIC systemlib) -target_compile_options(upstream PRIVATE -Werror=unused-variable) +apply_error_flags(upstream) target_include_directories(upstream SYSTEM PUBLIC $<TARGET_PROPERTY:systemlib,INTERFACE_INCLUDE_DIRECTORIES> @@ -29,7 +33,7 @@ endif() add_library(consumer consumer.cpp) target_link_libraries(consumer upstream config_specific) -target_compile_options(consumer PRIVATE -Werror=unused-variable) +apply_error_flags(consumer) add_library(iface IMPORTED INTERFACE) set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES @@ -38,21 +42,21 @@ set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES add_library(imported_consumer imported_consumer.cpp) target_link_libraries(imported_consumer iface) -target_compile_options(imported_consumer PRIVATE -Werror=unused-variable) +apply_error_flags(imported_consumer) add_library(imported_consumer2 imported_consumer.cpp) target_link_libraries(imported_consumer2 imported_consumer) -target_compile_options(imported_consumer2 PRIVATE -Werror=unused-variable) +apply_error_flags(imported_consumer2) # add a target which has a relative system include add_library(somelib imported_consumer.cpp) target_include_directories(somelib SYSTEM PUBLIC "systemlib_header_only") -target_compile_options(somelib PRIVATE -Werror=unused-variable) +apply_error_flags(somelib) # add a target which consumes a relative system include add_library(otherlib upstream.cpp) target_link_libraries(otherlib PUBLIC somelib) -target_compile_options(otherlib PRIVATE -Werror=unused-variable) +apply_error_flags(otherlib) macro(do_try_compile error_option) set(TC_ARGS |