diff options
author | Michal Klocek <michal.klocek@qt.io> | 2021-08-18 10:41:36 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2021-08-30 19:47:53 +0200 |
commit | add4dd7c1f50e09677f968a47c75309351e16743 (patch) | |
tree | 1e99cbdc608e50361f2d0d7cde421c817a459878 | |
parent | 6bb20409cc25897df93663d2679edf8791960e94 (diff) |
Add 'amazing' windows linker workaround for rsp files
This should be part of previous patch, however it deserved
separate commit message with explanation.
On windows cmake generates ninja rules with
cmake wrapper for linker in form of:
cmake.exe -E vs_link_dll
vs_link_dll internal command unfortunately expands all
rsp files passed to liker before calling it (it looks for '@')
and also swaps the order. This ends in bogus linker call.
Make a workaround based on:
https://github.com/Kitware/CMake/blob/master/Source/cmcmd.cxx#L2102
Use response files prefixed with 'CMakeFiles' so internal
command of cmake will skip the processing. Since
rsp files must now start with filename and not with filepath
we also need to copy them to directory where we call the
linker.
Task-number: QTBUG-95590
Change-Id: I8e96ebf3a9ac7c7d751db6682ce37f38880be793
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 9f4914248a2bf447d4728bc6bc8361dbbfc8709f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | cmake/Functions.cmake | 25 | ||||
-rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/process/CMakeLists.txt | 3 |
3 files changed, 29 insertions, 0 deletions
diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake index 96ff575fa..59ee72799 100644 --- a/cmake/Functions.cmake +++ b/cmake/Functions.cmake @@ -327,6 +327,27 @@ function(add_gn_target_for_cmake_target gnTarget cmakeTarget ninjaTarget config ) endfunction() +function(copy_response_files gnTarget) + get_target_property(config ${gnTarget} CONFIG) + get_target_property(ninjaTarget ${gnTarget} NINJA_TARGET) + get_target_property(cmakeTarget ${gnTarget} CMAKE_TARGET) + list(REMOVE_ITEM ARGN ${gnTarget}) + foreach(rsp IN ITEMS ${ARGN}) + set(rsp_dst "CMakeFiles_${ninjaTarget}_${config}_${rsp}.rsp") + set(rsp_src "${${rsp}_rsp}") + add_custom_command( + OUTPUT ${PROJECT_BINARY_DIR}/${rsp_dst} + COMMAND ${CMAKE_COMMAND} -E copy ${rsp_src} ${PROJECT_BINARY_DIR}/${rsp_dst} + DEPENDS ${rsp_src} + ) + set(${rsp}_rsp ${rsp_dst} PARENT_SCOPE) + add_custom_target(${cmakeTarget}_${rsp}_copy_${config} + DEPENDS ${PROJECT_BINARY_DIR}/${rsp_dst} + ) + add_dependencies(${cmakeTarget} ${cmakeTarget}_${rsp}_copy_${config}) + endforeach() +endfunction() + function(extend_target_with_gn_target gnTarget buildDir) get_target_property(config ${gnTarget} CONFIG) get_target_property(ninjaTarget ${gnTarget} NINJA_TARGET) @@ -355,10 +376,14 @@ function(extend_target_with_gn_target gnTarget buildDir) ) endif() if(WIN32) + copy_response_files(${gnTarget} objects archives libs) target_link_options(${cmakeTarget} PRIVATE "$<$<CONFIG:${config}>:@${objects_rsp}>" "$<$<CONFIG:${config}>:@${archives_rsp}>" + "$<$<CONFIG:${config}>:@${libs_rsp}>" ) + # we need libs rsp also when linking process with sandbox lib + set_property(TARGET ${cmakeTarget} PROPERTY LIBS_RSP ${libs_rsp}) endif() endfunction() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e4283e1d9..ffb327c2e 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -491,6 +491,7 @@ if(WIN32) add_custom_target(sandboxLibrary_${config} DEPENDS ${buildDir}/${config}/${arch}/QtWebEngineCoreSandbox.lib) add_dependencies(WebEngineCoreSandbox sandboxLibrary_${config}) + add_dependencies(WebEngineCoreSandbox WebEngineCore) endforeach() endif() diff --git a/src/process/CMakeLists.txt b/src/process/CMakeLists.txt index 87adc0c88..9b515f1d9 100644 --- a/src/process/CMakeLists.txt +++ b/src/process/CMakeLists.txt @@ -17,6 +17,9 @@ if(WIN32) target_sources(${qtWebEngineProcessName} PRIVATE support_win.cpp) target_link_libraries(${qtWebEngineProcessName} PRIVATE WebEngineCoreSandbox) set_property(TARGET ${qtWebEngineProcessName} PROPERTY WIN32_EXECUTABLE TRUE) + # get libs rsp file, since cmake is not aware of PUBLIC libs for WebEngineCore + get_target_property(libs_rsp WebEngineCore LIBS_RSP) + target_link_options(${qtWebEngineProcessName} PRIVATE "@${libs_rsp}") endif() target_link_libraries(${qtWebEngineProcessName} |