From 9d55d6b45bfc1f4e3c603bcc95f694ebe3a9206f Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 24 Jul 2020 20:12:19 +0200 Subject: 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 --- cmake/QtFinishPrlFile.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cmake/QtFinishPrlFile.cmake') 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() -- cgit v1.2.3