summaryrefslogtreecommitdiffstats
path: root/util/cmake/pro2cmake.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-07-06 17:46:10 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-07-07 11:48:45 +0200
commit19b04f6928a0541e7251f1f44fab436398e3bdc2 (patch)
tree62086ae44bc89a76cf6bfe05c4ace979c79dc17b /util/cmake/pro2cmake.py
parent82cb1ecca20fb2403c63657dfea3bef3c7a506b1 (diff)
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 <joerg.bornemann@qt.io>
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-xutil/cmake/pro2cmake.py35
1 files 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: