summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2020-02-11 15:38:47 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-02-12 08:43:29 +0000
commit572c03eb7a583baf1f48e5144d2868e5588d292a (patch)
tree2125b11072cddf76e204619cc571dd009531202f /util
parenta2eb09a377ff95e3f695937d893c101f9c409e75 (diff)
Add support for qt_helper_lib()
Add qt_add_3rdparty_library() function as a replacement for qmake's qt_helper_lib feature. All 3rdparty libraries will be available under the Qt:: alias when built through this method so that they can properly register as dependencies of a Qt module. This patch also adds Qt3rdPartyLibraryConfig.cmake.in to export the CMake configuration for static builds and shared libraries. Change-Id: I52bf3a95ca22fccd9ab54343468847bb1b570c28 Fixes: QTBUG-81969 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-xutil/cmake/pro2cmake.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index a93c506169..709ab01c39 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -327,6 +327,7 @@ def set_up_cmake_api_calls():
api[2]["qt_add_resource"] = "qt_add_resource"
api[2]["qt_add_qml_module"] = "qt_add_qml_module"
api[2]["qt_add_cmake_library"] = "qt_add_cmake_library"
+ api[2]["qt_add_3rdparty_library"] = "qt_add_3rdparty_library"
return api
@@ -2802,6 +2803,41 @@ def write_main_part(
cm_fh.write(ignored_keys_report)
+def write_3rdparty_library(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
+
+ # Remove default QT libs.
+ scope._append_operation("QT", RemoveOperation(["core", "gui"]))
+
+ target_name = re.sub(r"^qt", "", scope.TARGET)
+ target_name = target_name.replace("-", "_")
+
+ library_type = ""
+
+ if "dll" in scope.get("CONFIG"):
+ library_type = "SHARED"
+ else:
+ library_type = "STATIC"
+
+ extra_lines = []
+
+ if library_type:
+ extra_lines.append(library_type)
+
+ write_main_part(
+ cm_fh,
+ target_name,
+ "Generic Library",
+ get_cmake_api_call("qt_add_3rdparty_library"),
+ scope,
+ extra_lines=extra_lines,
+ indent=indent,
+ known_libraries={},
+ extra_keys=[],
+ )
+
+ return target_name
+
+
def write_generic_library(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
target_name = scope.TARGET
@@ -3524,6 +3560,9 @@ def handle_app_or_lib(
if is_jar:
write_jar(cm_fh, scope, indent=indent)
+ elif "qt_helper_lib" in scope.get("_LOADED"):
+ assert not is_example
+ target = write_3rdparty_library(cm_fh, scope, indent=indent)
elif is_example:
target = write_example(cm_fh, scope, gui, indent=indent, is_plugin=is_plugin)
elif is_qt_plugin: