summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2022-05-18 08:01:29 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-07 19:19:46 +0000
commit8bf7fc6245b689b905d30e49a2d2e6f380981f25 (patch)
tree77304e9bb09db1855570d831af19883f8a87aab3 /cmake
parent544e1cd4c8f323b9e4bb1802d80cce2e09e22cf0 (diff)
Fix unsupported @file notation on macos archiver
Create intermediate object file and use it as imported object library. Fixes: QTBUG-103579 Change-Id: I2ff7d57509ab1f071876de3b6fdc5ed9874c4697 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 88a91f8b30df1b95cf9adebacb13a8c0fc3f06c9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Functions.cmake33
1 files changed, 26 insertions, 7 deletions
diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake
index 89f4cdd39..e66aa0694 100644
--- a/cmake/Functions.cmake
+++ b/cmake/Functions.cmake
@@ -408,7 +408,18 @@ function(get_copy_of_response_file result target rsp)
add_dependencies(${cmakeTarget} ${cmakeTarget}_${rsp}_copy_${config})
endfunction()
-function(extend_cmake_target target buildDir completeStatic)
+function(add_archiver_options target buildDir completeStatic)
+ get_target_property(config ${target} CONFIG)
+ string(TOUPPER ${config} cfg)
+ get_target_property(ninjaTarget ${target} NINJA_TARGET)
+ get_target_property(cmakeTarget ${target} CMAKE_TARGET)
+ set(objects_out "${buildDir}/${cmakeTarget}_objects.o")
+ add_library(GnObject_${cmakeTarget}_${config} OBJECT IMPORTED GLOBAL)
+ target_link_libraries(${cmakeTarget} PRIVATE $<$<CONFIG:${config}>:GnObject_${cmakeTarget}_${config}>)
+ set_property(TARGET GnObject_${cmakeTarget}_${config} PROPERTY IMPORTED_OBJECTS_${cfg} ${objects_out})
+endfunction()
+
+function(add_linker_options target buildDir completeStatic)
get_target_property(config ${target} CONFIG)
get_target_property(ninjaTarget ${target} NINJA_TARGET)
get_target_property(cmakeTarget ${target} CMAKE_TARGET)
@@ -452,7 +463,7 @@ function(extend_cmake_target target buildDir completeStatic)
endif()
endfunction()
-function(add_rsp_command target buildDir completeStatic)
+function(add_intermediate_archive target buildDir completeStatic)
get_target_property(config ${target} CONFIG)
get_target_property(arch ${target} ARCH)
get_target_property(ninjaTarget ${target} NINJA_TARGET)
@@ -493,13 +504,15 @@ function(add_rsp_command target buildDir completeStatic)
)
endfunction()
-function(add_ios_rsp_command target buildDir completeStatic)
+function(add_intermediate_object target buildDir completeStatic)
get_target_property(config ${target} CONFIG)
get_target_property(arch ${target} ARCH)
get_target_property(ninjaTarget ${target} NINJA_TARGET)
get_target_property(cmakeTarget ${target} CMAKE_TARGET)
string(TOUPPER ${config} cfg)
- get_ios_target_triple_and_sysroot(args ${arch})
+ if(IOS)
+ get_ios_target_triple_and_sysroot(args ${arch})
+ endif()
set(objects_rsp "${buildDir}/${ninjaTarget}_objects.rsp")
set(objects_out "${buildDir}/${cmakeTarget}_objects.o")
add_custom_command(
@@ -1081,11 +1094,17 @@ function(add_gn_build_aritfacts_to_target cmakeTarget ninjaTarget module buildDi
LINK_DEPENDS ${buildDir}/${config}/${arch}/${ninjaTarget}.stamp
)
if(QT_IS_MACOS_UNIVERSAL)
- add_rsp_command(${target} ${buildDir}/${config}/${arch} ${completeStatic})
+ add_intermediate_archive(${target} ${buildDir}/${config}/${arch} ${completeStatic})
elseif(IOS)
- add_ios_rsp_command(${target} ${buildDir}/${config}/${arch} ${completeStatic})
+ add_intermediate_object(${target} ${buildDir}/${config}/${arch} ${completeStatic})
else()
- extend_cmake_target(${target} ${buildDir}/${config}/${arch} ${completeStatic})
+ if(MACOS AND QT_FEATURE_static)
+ # mac archiver does not support @file notation, do intermediate object istead
+ add_intermediate_object(${target} ${buildDir}/${config}/${arch} ${completeStatic})
+ add_archiver_options(${target} ${buildDir}/${config}/${arch} ${completeStatic})
+ else()
+ add_linker_options(${target} ${buildDir}/${config}/${arch} ${completeStatic})
+ endif()
endif()
unset(target)
endforeach()