aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cmake
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-03-24 01:51:32 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-03-24 01:51:32 +0300
commit87ec5baa9392c8f3a1f9777453a12a8055d146b0 (patch)
tree661b1f7bec725404a62594805a6142c9e6d41428 /cmake
parentMakefile: best practices (diff)
downloadcmake-common-old.tar.gz
cmake-common-old.zip
common.cmake: account for ALIAS targetsold
Diffstat (limited to 'cmake')
-rw-r--r--cmake/common.cmake20
1 files 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
$<$<CONFIG:Debug>:/MTd>
$<$<NOT:$<CONFIG:Debug>>:/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 $<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>>)
if(release_build)
# This causes issues with mixing keyword- and plain- versions of