summaryrefslogtreecommitdiffstats
path: root/util/cmake/pro2cmake.py
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-10-23 14:45:20 +0200
committerLeander Beernaert <leander.beernaert@qt.io>2019-10-28 09:20:37 +0000
commit69fb4ae343777af9078e5128ec41cfb3cea2cd76 (patch)
tree7d15b4dde18289f583dc195f121556b04dd85e55 /util/cmake/pro2cmake.py
parent080f9ad160ef7422b2bab884c7ccc950d35b3a0a (diff)
Distinguish between qt_plugin and regular plugins
If we do not encounter the load(qt_plugin) statement in the .pro file but we do see the entry CONFIG+=plugin, treat the target as a regular CMake library instead of treating it as a qt_plugin by default. Change-Id: I67ad5c865a1a5ab691a6b0d86c2db4b686aa04dd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-xutil/cmake/pro2cmake.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 36e899d781..100e81e2c5 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -2498,6 +2498,12 @@ def write_generic_library(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> s
if "dll" in scope.get("CONFIG"):
library_type = "SHARED"
+ is_plugin = False
+ if "plugin" in scope.get("CONFIG"):
+ library_type = "MODULE"
+ is_plugin = True
+
+ # static after plugin in order to handle static library plugins
if "static" in scope.get("CONFIG"):
library_type = "STATIC"
@@ -2523,6 +2529,13 @@ def write_generic_library(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> s
extra_keys=[],
)
+ if is_plugin:
+ # Plugins need to be able to run auto moc
+ cm_fh.write(f"\nqt_autogen_tools_initial_setup({target_name})\n")
+
+ if library_type == "STATIC":
+ cm_fh.write(f"\ntarget_compile_definitions({target_name} PRIVATE QT_STATICPLUGIN)\n")
+
return target_name
@@ -3077,8 +3090,9 @@ def handle_app_or_lib(
is_jar = "java" in config
is_lib = scope.TEMPLATE == "lib"
is_qml_plugin = any("qml_plugin" == s for s in scope.get("_LOADED"))
- is_plugin = (
- any("qt_plugin" == s for s in scope.get("_LOADED")) or is_qml_plugin or "plugin" in config
+ is_plugin = "plugin" in config
+ is_qt_plugin = (
+ any("qt_plugin" == s for s in scope.get("_LOADED")) or is_qml_plugin
)
target = ""
gui = all(
@@ -3089,10 +3103,10 @@ def handle_app_or_lib(
tar = write_jar(cm_fh, scope, indent=indent)
elif is_example:
target = write_example(cm_fh, scope, gui, indent=indent, is_plugin=is_plugin)
- elif is_plugin:
+ elif is_qt_plugin:
assert not is_example
target = write_plugin(cm_fh, scope, indent=indent)
- elif is_lib and "qt_module" not in scope.get("_LOADED"):
+ elif (is_lib and "qt_module" not in scope.get("_LOADED")) or is_plugin:
assert not is_example
target = write_generic_library(cm_fh, scope, indent=indent)
elif is_lib or "qt_module" in scope.get("_LOADED"):