diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-05-17 14:22:57 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-05-20 13:15:16 +0000 |
commit | e4b8c488bd8b350f1a19874c4859ae2699afc747 (patch) | |
tree | 2c232002f97aae4f010e49c1dab09f8a9d9b4be5 /util/cmake/configurejson2cmake.py | |
parent | 42c8c38564c11a86a553139f21322ad232ab5957 (diff) |
Improve configure2cmake to find_package only in certain conditions
It doesn't make much sense to look for X11 related packages on
macOS and Windows by default. Usually they would not be there, and
as a result the configuration step would show a long list of scary
not found packages, and also eat precious configure time.
Change the conversion script to allow putting conditions around
generated find_package calls.
These conditions can be manually set in the conversion script
library mapping, using the emit_if argument,
which we do for the X11 and Wayland related packages.
They are also computed by checking which features use a given library,
and if the feature is protected by a simple emitIf condition like
config.linux, the relevant library find_package call will be protected
by the same condition.
If a developer still wishes to look for all packages, they can define
the CACHE variable QT_FIND_ALL_PACKAGES_ALWAYS to ON.
The relevant configure.cmake files are regenerated in this patch.
Change-Id: I6f918a94f50257ec41d6216305dae9774933389a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'util/cmake/configurejson2cmake.py')
-rwxr-xr-x | util/cmake/configurejson2cmake.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py index 040e8ee7b4..d1646ed082 100755 --- a/util/cmake/configurejson2cmake.py +++ b/util/cmake/configurejson2cmake.py @@ -181,9 +181,29 @@ def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set): if newlib.targetName in cmake_find_packages_set: return + # If certain libraries are used within a feature, but the feature + # is only emitted conditionally with a simple condition (like + # 'on Windows' or 'on Linux'), we should enclose the find_package + # call for the library into the same condition. + emit_if = newlib.emit_if + + # Only look through features if a custom emit_if wasn't provided. + if not emit_if: + for feature in data['features']: + feature_data = data['features'][feature] + if 'condition' in feature_data and \ + 'libs.{}'.format(lib) in feature_data['condition'] and \ + 'emitIf' in feature_data and \ + 'config.' in feature_data['emitIf']: + emit_if = feature_data['emitIf'] + break + + if emit_if: + emit_if = map_condition(emit_if) + cmake_find_packages_set.add(newlib.targetName) - cm_fh.write(generate_find_package_info(newlib)) + cm_fh.write(generate_find_package_info(newlib, emit_if=emit_if)) def lineify(label, value, quote=True): @@ -890,7 +910,7 @@ def processLibraries(ctx, data, cm_fh): return for lib in data['libraries']: - parseLib(ctx, lib, data['libraries'][lib], cm_fh, cmake_find_packages_set) + parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set) def processSubconfigs(dir, ctx, data): |