summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-11-11 14:25:45 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-11-12 15:25:06 +0100
commit34437b9e14f531fd514941143f34e95639d9cb74 (patch)
treea2187d6b4097948babef5e1faaf2dfb451e96cb4 /util
parent2d07ef0b566fb60dcb320a574ef282dbcd2329e3 (diff)
CMake: pro2cmake: Handle AUX_QML_FILES installation
Generate copy and installation rules for AUX_QML_FILES entries. These are usually handled by mkspecs/features/qml_module.prf. For the purposes of unblocking the Designer team, instead of creating AUX_QML file specic functions that would handle installation, generate qt_copy_or_install() rules. To ensure installation destination is correct, we need to group file paths by base directory and specify those in the DESTINATION parameter. Otherwise the file hierarchy would be flattened. This is usually handled by file_copies.prf and the equivalent qmake install mechanism. In CMake we need to handle it manually. Also detect usage of wildcards to ensure we use globs for installation. Task-number: QTBUG-87818 Change-Id: I8a5db445274fb670d90cf90b38598a6b3326bc44 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-xutil/cmake/pro2cmake.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 06141cf69e..4f7118007e 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -2926,6 +2926,68 @@ def write_windows_part(cm_fh: IO[str], target: str, scope: Scope, indent: int =
write_scope_condition_end(cm_fh, condition, indent=indent)
+def write_aux_qml_file_install_call(cm_fh: IO[str], file_list: List[str], indent: int = 0):
+ cm_fh.write(f"\n{spaces(indent)}qt_copy_or_install(\n")
+ write_list(
+ cm_fh, file_list, "FILES", indent + 1
+ )
+
+ destination_option = 'DESTINATION "${__aux_qml_files_install_dir}"'
+ cm_fh.write(f'{spaces(indent + 1)}{destination_option})\n')
+
+
+def write_aux_qml_path_setup(cm_fh: IO[str], base_dir: str, indent: int = 0):
+ path_join_args = f'__aux_qml_files_install_dir "${{__aux_qml_files_install_base}}" "{base_dir}"'
+ cm_fh.write(f"\n{spaces(indent)}qt_path_join({path_join_args})\n")
+
+
+def write_aux_qml_files_part(cm_fh: IO[str], target: str, scope: Scope, indent: int = 0):
+ aux_files = scope.get_files("AUX_QML_FILES")
+ if aux_files and isinstance(aux_files, list):
+ aux_files_per_dir = defaultdict(list)
+ aux_files_globs = []
+
+ # Handle globs differently from regular paths.
+ # For regular paths, group by base dir. Each base dir will get
+ # its own install call.
+ for path in aux_files:
+ if "*" in path:
+ aux_files_globs.append(path)
+ else:
+ base_dir = os.path.dirname(path)
+ aux_files_per_dir[base_dir].append(path)
+
+ condition, indent = write_scope_condition_begin(cm_fh, scope, indent=indent)
+
+ # Extract the location of $prefix/qml, where we want to install
+ # files.
+ get_prop_args = f"__aux_qml_files_install_base {target} QT_QML_MODULE_INSTALL_DIR"
+ cm_fh.write(f"{spaces(indent)}get_target_property({get_prop_args})\n")
+
+ # Handle glob installs.
+ for path in aux_files_globs:
+ cm_fh.write(
+ f"""
+{spaces(indent)}file(GLOB_RECURSE __aux_qml_glob_files
+{spaces(indent + 1)}RELATIVE "${{CMAKE_CURRENT_SOURCE_DIR}}"
+{spaces(indent + 1)}"{path}")"""
+ )
+ file_list = ["${__aux_qml_glob_files}"]
+
+ # Extract base dir. Hopes that the globs only appear in the
+ # file name part.
+ base_dir = os.path.dirname(path)
+ write_aux_qml_path_setup(cm_fh, base_dir, indent=indent)
+ write_aux_qml_file_install_call(cm_fh, file_list, indent=indent)
+
+ # Handle regular per base-dir installs.
+ for base_dir in aux_files_per_dir:
+ file_list = aux_files_per_dir[base_dir]
+ write_aux_qml_path_setup(cm_fh, base_dir, indent=indent)
+ write_aux_qml_file_install_call(cm_fh, file_list, indent=indent)
+ write_scope_condition_end(cm_fh, condition, indent=indent)
+
+
def handle_source_subtractions(scopes: List[Scope]):
"""
Handles source subtractions like SOURCES -= painting/qdrawhelper.cpp
@@ -3185,6 +3247,8 @@ def write_main_part(
write_version_part(cm_fh, name, scopes[0], indent)
+ write_aux_qml_files_part(cm_fh, name, scopes[0], indent)
+
if "warn_off" in scope.get("CONFIG"):
write_generic_cmake_command(cm_fh, "qt_disable_warnings", [name])
@@ -3208,6 +3272,7 @@ def write_main_part(
write_windows_part(cm_fh, name, c, indent=indent)
write_darwin_part(cm_fh, name, c, main_scope_target_name=name, indent=indent)
write_version_part(cm_fh, name, c, indent=indent)
+ write_aux_qml_files_part(cm_fh, name, c, indent=indent)
write_extend_target(cm_fh, name, c, target_ref=target_ref, indent=indent)
write_simd_part(cm_fh, name, c, indent=indent)