From 87ec5baa9392c8f3a1f9777453a12a8055d146b0 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 24 Mar 2020 01:51:32 +0300 Subject: common.cmake: account for ALIAS targets --- cmake/common.cmake | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cmake/common.cmake b/cmake/common.cmake index 2179a32..0d813fe 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -96,7 +96,8 @@ set(CMAKE_CXX_EXTENSIONS OFF) function(_cc_best_practices_msvc target) set(compile_options /MP /W4) get_target_property(target_type "${target}" TYPE) - if(NOT target_type STREQUAL "INTERFACE_LIBRARY") + get_target_property(aliased "${target}" ALIASED_TARGET) + if(NOT target_type STREQUAL "INTERFACE_LIBRARY" AND NOT aliased) target_compile_options("${target}" PRIVATE ${compile_options}) endif() endfunction() @@ -104,7 +105,8 @@ endfunction() function(_cc_best_practices_gcc target) set(compile_options -Wall -Wextra) get_target_property(target_type "${target}" TYPE) - if(NOT target_type STREQUAL "INTERFACE_LIBRARY") + get_target_property(aliased "${target}" ALIASED_TARGET) + if(NOT target_type STREQUAL "INTERFACE_LIBRARY" AND NOT aliased) target_compile_options("${target}" PRIVATE ${compile_options}) endif() endfunction() @@ -125,7 +127,10 @@ function(_cc_common_windows_definitions target) if(target_type STREQUAL "INTERFACE_LIBRARY") target_compile_definitions("${target}" INTERFACE ${compile_definitions}) else() - target_compile_definitions("${target}" PRIVATE ${compile_definitions}) + get_target_property(aliased "${target}" ALIASED_TARGET) + if(NOT aliased) + target_compile_definitions("${target}" PRIVATE ${compile_definitions}) + endif() endif() endfunction() @@ -133,7 +138,8 @@ endfunction() function(_cc_static_runtime_msvc target) get_target_property(target_type "${target}" TYPE) - if(NOT target_type STREQUAL "INTERFACE_LIBRARY") + get_target_property(aliased "${target}" ALIASED_TARGET) + if(NOT target_type STREQUAL "INTERFACE_LIBRARY" AND NOT aliased) target_compile_options("${target}" PRIVATE $<$:/MTd> $<$>:/MT>) @@ -142,7 +148,8 @@ endfunction() function(_cc_static_runtime_gcc target) get_target_property(target_type "${target}" TYPE) - if(target_type STREQUAL "EXECUTABLE") + get_target_property(aliased "${target}" ALIASED_TARGET) + if(NOT target_type STREQUAL "INTERFACE_LIBRARY" AND NOT aliased) # This causes issues with mixing keyword- and plain- versions of # target_link_libraries: #target_link_libraries("${target}" PRIVATE -static) @@ -166,7 +173,8 @@ endfunction() function(_cc_strip_symbols_gcc target) get_target_property(target_type "${target}" TYPE) - if(NOT target_type STREQUAL "INTERFACE_LIBRARY") + get_target_property(aliased "${target}" ALIASED_TARGET) + if(NOT target_type STREQUAL "INTERFACE_LIBRARY" AND NOT aliased) set(release_build $,$>) if(release_build) # This causes issues with mixing keyword- and plain- versions of -- cgit v1.2.3