diff options
author | Alexandru Croitor <alexandru@croitor.qt.io> | 2020-07-24 20:12:19 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-07-29 17:33:15 +0200 |
commit | 9d55d6b45bfc1f4e3c603bcc95f694ebe3a9206f (patch) | |
tree | 99f9daf2b9fc9838819164cc5dfa54e2deb8dc10 /cmake/QtFinishPrlFile.cmake | |
parent | 7b9904849fe1a43f0db8216076a9e974ebca5c78 (diff) |
CMake: Fix building debug apps with qmake on Windows
Our CMake build system only generated working .prl files for
the Release configuration in debug_and_release.
This caused a linking failure when building a Widgets example that
links against qtmain, specifically
qtmaind.lib(qtmain_win.cpp.obj) : error LNK2019: unresolved external
symbol __imp_CommandLineToArgvW referenced in function WinMain
The symbol is located in shell32.dll, which was not linked in, because
there was no qtmaind.prl file.
The fix to generate per config prl files is a bit complicated, because
add_custom_command does not support generator expressions in OUTPUT
and DEPENDS.
Instead we pre-generate 2 files per config, one with the preliminary
prl file content and another file that contains the final prl file
path (via generator expression).
Then we iterate over all configurations and create custom commands
with well known paths, and the final prl file is created by the script
called by the command.
Amends 06557312d2a030f9ff771488bd6c97690a125a3d
Task-number: QTBUG-85240
Change-Id: I413b705bc69732b0cbe1ee8cd089a1aef19365db
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake/QtFinishPrlFile.cmake')
-rw-r--r-- | cmake/QtFinishPrlFile.cmake | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/QtFinishPrlFile.cmake b/cmake/QtFinishPrlFile.cmake index 4927761674..d6901e168f 100644 --- a/cmake/QtFinishPrlFile.cmake +++ b/cmake/QtFinishPrlFile.cmake @@ -60,3 +60,18 @@ foreach(line ${lines}) endif() endforeach() file(WRITE "${OUT_FILE}" "${content}") + +# Read the prl meta file to find out where should the final prl file be placed, +# Copy it there, if the contents hasn't changed. +file(STRINGS "${IN_META_FILE}" lines) + +foreach(line ${lines}) + if(line MATCHES "^FINAL_PRL_FILE_PATH = (.*)") + set(final_prl_file_path "${CMAKE_MATCH_1}") + configure_file( + "${OUT_FILE}" + "${final_prl_file_path}" + COPYONLY + ) + endif() +endforeach() |