From aa1e0d84b93e0901bb8db497e67276329ef9cc66 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 9 Jan 2023 10:24:32 +0400 Subject: [PATCH] Allow weak-linking of macOS frameworks. --- options_mac.cmake | 1 - target_link_frameworks.cmake | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/options_mac.cmake b/options_mac.cmake index afab1c7..8da4ab4 100644 --- a/options_mac.cmake +++ b/options_mac.cmake @@ -84,5 +84,4 @@ INTERFACE MediaPlayer IOSurface Metal - NaturalLanguage ) diff --git a/target_link_frameworks.cmake b/target_link_frameworks.cmake index 1c03093..01730d0 100644 --- a/target_link_frameworks.cmake +++ b/target_link_frameworks.cmake @@ -4,8 +4,9 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL -function(target_link_frameworks target_name) +function(target_link_frameworks_generic type target_name) set(list ${ARGV}) + list(REMOVE_AT list 1) list(REMOVE_AT list 0) set(writing_now "") @@ -16,7 +17,7 @@ function(target_link_frameworks target_name) if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE") set(writing_now ${entry}) else() - set(full_argument "-framework ${entry}") + set(full_argument "${type} ${entry}") if ("${writing_now}" STREQUAL "PRIVATE") list(APPEND private_frameworks ${full_argument}) elseif ("${writing_now}" STREQUAL "PUBLIC") @@ -39,3 +40,11 @@ function(target_link_frameworks target_name) target_link_libraries(${target_name} INTERFACE ${interface_frameworks}) endif() endfunction() + +function(target_link_frameworks target_name) + target_link_frameworks_generic("-framework" ${ARGV}) +endfunction() + +function(target_link_frameworks_weak target_name) + target_link_frameworks_generic("-weak_framework" ${ARGV}) +endfunction()