summaryrefslogtreecommitdiffstats
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-02 22:29:49 +0000
commita3bca83e08b6828f617f92f891f387fb6c35be9e (patch)
treefa966d1427d1c398acb9269173d9503a13d1c260
parent587e3b1908fcab5cfb96a88c0b58e348e315ed78 (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 d4183db69bb3ec7baeac63118a51c0f511264689) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--cmake/Functions.cmake33
1 files changed, 26 insertions, 7 deletions
diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake
index 5fd08c8ba..7c37d6548 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(
@@ -1074,11 +1087,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()