summaryrefslogtreecommitdiffstats
path: root/cmake/QtGenerateLibHelpers.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-10-28 18:05:24 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-10-29 12:11:53 +0100
commitbae96f1792da1fe0f3ca4b738096c0c1a27eb862 (patch)
tree16c849a77372948f16897ed94ac3782dc60731b4 /cmake/QtGenerateLibHelpers.cmake
parent3a1bc4bad5757d72e5af8b4abe236e3cfac9621d (diff)
CMake: Fix generation of prl files for non-qtbase modules
Previously we determined if a library represented by an absolute path is a Qt module by checking if it's located in the build dir of the current repo. That is not sufficient for non-qtbase prefix builds, where a Qt module might link against both a module in the current build dir and in the prefix dir. Detect such cases, and rewrite the absolute paths to relocatable paths (either framework flags or paths starting with $$[QT_INSTALL_LIBS]. This should fix building examples with qmake that use QtQuick. Fixes: QTBUG-87840 Change-Id: Icaf8f1a7c66292c80662fd0d5771a5a1628a9899 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtGenerateLibHelpers.cmake')
-rw-r--r--cmake/QtGenerateLibHelpers.cmake23
1 files changed, 23 insertions, 0 deletions
diff --git a/cmake/QtGenerateLibHelpers.cmake b/cmake/QtGenerateLibHelpers.cmake
index 06de484ac4..dedcdc7950 100644
--- a/cmake/QtGenerateLibHelpers.cmake
+++ b/cmake/QtGenerateLibHelpers.cmake
@@ -88,3 +88,26 @@ function(qt_strip_library_version_suffix out_var file_path)
endif()
set(${out_var} "${final_value}" PARENT_SCOPE)
endfunction()
+
+# Checks if `input_path` is relative to at least one path given in the list of `qt_lib_paths`.
+# Sets TRUE or FALSE in `out_var_is_relative`.
+# Assigns the relative path to `out_var_relative_path` if the path is relative, otherwise assigns
+# the original path.
+function(qt_internal_path_is_relative_to_qt_lib_path
+ input_path qt_lib_paths out_var_is_relative out_var_relative_path)
+ set(is_relative "FALSE")
+ set(relative_path_value "${input_path}")
+
+ foreach(qt_lib_path ${qt_lib_paths})
+ file(RELATIVE_PATH relative_path "${qt_lib_path}" "${input_path}")
+ if(IS_ABSOLUTE "${relative_path}" OR (relative_path MATCHES "^\\.\\."))
+ set(is_relative "FALSE")
+ else()
+ set(is_relative "TRUE")
+ set(relative_path_value "${relative_path}")
+ break()
+ endif()
+ endforeach()
+ set(${out_var_is_relative} "${is_relative}" PARENT_SCOPE)
+ set(${out_var_relative_path} "${relative_path_value}" PARENT_SCOPE)
+endfunction()