From 19b04f6928a0541e7251f1f44fab436398e3bdc2 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 6 Jul 2020 17:46:10 +0200 Subject: [PATCH] CMake: pro2cmake: Fix handling of QT_SKIP_QUICKCOMPILER If a file was part of a resource that has a non-empty base directory, the script generated set_source_files_properties calls to the file path without including the base dir, which means the command did nothing. The script should set the QT_SKIP_QUICKCOMPILER on the full file path if a base dir is present, similar to how the alias handled. Refactor the alias property writing code to write all properties into the command that uses the full correct path. Change-Id: Ic75d51ecf60eef3ada9bd6ca26882de3447896e9 Reviewed-by: Joerg Bornemann --- util/cmake/pro2cmake.py | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 5f52c3218f..a87adb5d5d 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -495,16 +495,34 @@ def write_add_qt_resource_call( assert sorted_files + if base_dir: + base_dir_expanded = scope.expandString(base_dir) + if base_dir_expanded: + base_dir = base_dir_expanded + + source_file_properties = defaultdict(list) + for source in sorted_files: + full_source = posixpath.join(base_dir, source) alias = files[source] if alias: - full_source = posixpath.join(base_dir, source) + source_file_properties[full_source].append(f'QT_RESOURCE_ALIAS "{alias}"') + # If a base dir is given, we have to write the source file property + # assignments that disable the quick compiler per file. + if base_dir and skip_qtquick_compiler: + source_file_properties[full_source].append('QT_SKIP_QUICKCOMPILER 1') + + for full_source in source_file_properties: + per_file_props = source_file_properties[full_source] + if per_file_props: + prop_spaces = " " + per_file_props_joined = f'\n{prop_spaces}'.join(per_file_props) output += dedent( f"""\ - set_source_files_properties("{full_source}" - PROPERTIES QT_RESOURCE_ALIAS "{alias}" - ) - """ + set_source_files_properties("{full_source}" + PROPERTIES {per_file_props_joined} + ) + """ ) # Quote file paths in case there are spaces. @@ -525,7 +543,7 @@ def write_add_qt_resource_call( """ ) file_list = f"${{{resource_name}_resource_files}}" - if skip_qtquick_compiler: + if skip_qtquick_compiler and not base_dir: output += ( f"set_source_files_properties(${{{resource_name}_resource_files}}" " PROPERTIES QT_SKIP_QUICKCOMPILER 1)\n\n" @@ -539,15 +557,12 @@ def write_add_qt_resource_call( prefix_expanded = scope.expandString(prefix) if prefix_expanded: - prefix = perfix_expanded + prefix = prefix_expanded params = "" if lang: params += f'{spaces(1)}LANG\n{spaces(2)}"{lang}"\n' params += f'{spaces(1)}PREFIX\n{spaces(2)}"{prefix}"\n' if base_dir: - base_dir_expanded = scope.expandString(base_dir) - if base_dir_expanded: - base_dir = base_dir_expanded params += f'{spaces(1)}BASE\n{spaces(2)}"{base_dir}"\n' add_resource_command = "" if is_example: