summaryrefslogtreecommitdiffstats
path: root/util/cmake/configurejson2cmake.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-04-15 18:48:26 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-04-17 15:59:25 +0200
commit67ee92f4d898ee76c40b7efd8e69782a6a4a3754 (patch)
tree57c4934656c2f15a59a70cd53aa0f73fd4fd838d /util/cmake/configurejson2cmake.py
parente6d880e511db7f12bda1f8ee599246d30b7ebf1b (diff)
CMake: Handle automatic rpath embedding correctly
Instead of using CMAKE_INSTALL_RPATH to embed an absolute path to prefix/libdir into all targets, use the more sophisticated aproach that qmake does. For certain targets (modules, plugins, tools) use relative rpaths. Otherwise embed absolute paths (examples, regular binaries). Installed tests currently have no rpaths. On certain platforms rpaths are not used (Windows, Android, iOS / uikit). Frameworks, app bundles and shallow bundles should also be handled correctly. Additional rpaths can be provided via QT_EXTRA_RPATHS variable (similar to the -R option that configure takes). Automatic embedding can be disabled either via QT_FEATURE_rpath=OFF or QT_DISABLE_RPATH=ON. Note that installed examples are not relocatable at the moment (due to always having an absolute path rpath), so this is a missing feature compared to qmake. This is due to missing information on where examples will be installed, so a relative rpath can not be computed. By default a Qt installation is relocatable, so there is no need to pass -DQT_EXTRA_RPATHS=. like Coin used to do with qmake e.g. -R . Relative rpaths will have the appropriate 'relative base' prefixed to them (e.g $ORIGIN on linux and @loader_path on darwin platforms). There is currently no support for other platforms that might have a different 'relative base' than the ones mentioned above. Any extra rpaths are saved to BuildInternalsExtra which are re-used when building other repositories. configurejson2cmake modified to include correct conditions for the rpath feature. It's very likely that we will need a new qt_add_internal_app() function for gui apps that are to be installed to prefix/bin. For example for Assistant from qttools. Currently such apps use qt_add_executable(). The distinction is necessary to make sure that relative rpaths are embedded into apps, but not executables (which tests are part of). Amends e835a6853b9c0fb7af32798ed8965de3adf0e15b Task-number: QTBUG-83497 Change-Id: I3510f63c0a59489741116cc8ec3ef6a0a7704f25 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'util/cmake/configurejson2cmake.py')
-rwxr-xr-xutil/cmake/configurejson2cmake.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py
index 85ac26ec2b..f004e732f6 100755
--- a/util/cmake/configurejson2cmake.py
+++ b/util/cmake/configurejson2cmake.py
@@ -876,10 +876,9 @@ def get_feature_mapping():
"qpa_default_platform": None, # Not a bool!
"release": None,
"release_tools": None,
- "rpath_dir": None, # merely used to fill the qmake variable EXTRA_RPATHS
"rpath": {
"autoDetect": "1",
- "condition": "BUILD_SHARED_LIBS AND UNIX AND NOT WIN32 AND NOT ANDROID AND NOT APPLE",
+ "condition": "BUILD_SHARED_LIBS AND UNIX AND NOT WIN32 AND NOT ANDROID",
},
"sanitize_address": None, # sanitizer
"sanitize_memory": None,
@@ -1222,6 +1221,12 @@ def processSummaryHelper(ctx, entries, cm_fh):
print(f" XXXX UNHANDLED SUMMARY TYPE {entry}.")
+report_condition_mapping = {
+ "(features.rpath || features.rpath_dir) && !features.shared": "(features.rpath || QT_EXTRA_RPATHS) && !features.shared",
+ "(features.rpath || features.rpath_dir) && var.QMAKE_LFLAGS_RPATH == ''": None
+}
+
+
def processReportHelper(ctx, entries, cm_fh):
feature_mapping = get_feature_mapping()
@@ -1265,6 +1270,13 @@ def processReportHelper(ctx, entries, cm_fh):
if unhandled_condition:
print(f" XXXX UNHANDLED CONDITION in REPORT TYPE {entry}.")
continue
+
+ if isinstance(condition, str) and condition in report_condition_mapping:
+ new_condition = report_condition_mapping[condition]
+ if new_condition is None:
+ continue
+ else:
+ condition = new_condition
condition = map_condition(condition)
entry_args.append(lineify("CONDITION", condition, quote=False))
entry_args_string = "".join(entry_args)