summaryrefslogtreecommitdiffstats
path: root/cmake/QtFinishPrlFile.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-07-30 19:17:09 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-07-31 14:29:45 +0200
commit9c0f448f5a4e2e96e9b801c751c0a145c0eb6dad (patch)
tree504356a5fa4c369cdcb1c862518e99911f301d7c /cmake/QtFinishPrlFile.cmake
parent26c742c1e1c96740646bb1896df52bad2fbe105d (diff)
CMake: Fix generated content of prl files (again)
Apply the same kind of transformations to the contents of the prl files as we do for pri files. Mainly, transform system library paths that are absolute, into link flags to make them relocatable across systems. Also change the Qt frameworks to be linked via the -framework flags instead of via absolute paths. Implementation notes Move the common required functions for both QtFinishPrlFile and QtGenerateLibPri into a common QtGenerateLibHelpers.cmake file. Make sure it's listed as a dependency for the custom commands. Also make sure to pass the necessary input values like possible library prefixes and suffixes, as well as the link flag. Task-number: QTBUG-85240 Task-number: QTBUG-85801 Change-Id: I36f24207f92a1d2ed3ed2d81bb96e4e62d927b6e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake/QtFinishPrlFile.cmake')
-rw-r--r--cmake/QtFinishPrlFile.cmake38
1 files changed, 23 insertions, 15 deletions
diff --git a/cmake/QtFinishPrlFile.cmake b/cmake/QtFinishPrlFile.cmake
index d6901e168f..4b350b9339 100644
--- a/cmake/QtFinishPrlFile.cmake
+++ b/cmake/QtFinishPrlFile.cmake
@@ -3,28 +3,26 @@
# - Replaces occurrences of the build libdir with $$[QT_INSTALL_LIBDIR].
# - Strips version number suffixes from absolute paths, because qmake's lflag
# merging does not handle them correctly.
+# - Transforms absolute library paths into link flags
+# aka from "/usr/lib/x86_64-linux-gnu/libcups.so" to "-lcups"
+# - Replaces Qt absolute framework paths into a combination of -F$$[QT_INSTALL_LIBS] and
+# -framework QtFoo
+# - Prepends '-l' to values that are not absolute paths, and don't start with either '-l' or
+# '-framework'.
#
# This file is to be used in CMake script mode with the following variables set:
# IN_FILE: path to the preliminary .prl file
# OUT_FILE: path to the final .prl file that's going to be installed
# QT_BUILD_LIBDIR: path to Qt's libdir when building (those paths get replaced)
# LIBRARY_SUFFIXES: list of known library extensions, e.g. .so;.a on Linux
+# LIBRARY_PREFIXES: list of known library prefies, e.g. the "lib" in "libz" on on Linux
+# LINK_LIBRARY_FLAG: flag used to link a shared library to an executable, e.g. -l on UNIX
-function(strip_library_version_suffix out_var file_path)
- get_filename_component(dir "${file_path}" DIRECTORY)
- get_filename_component(basename "${file_path}" NAME_WE)
- get_filename_component(ext "${file_path}" EXT)
- foreach(libsuffix ${LIBRARY_SUFFIXES})
- if(ext MATCHES "^${libsuffix}(\\.[0-9]+)+")
- set(ext ${libsuffix})
- break()
- endif()
- endforeach()
- set(${out_var} "${dir}/${basename}${ext}" PARENT_SCOPE)
-endfunction()
+include("${CMAKE_CURRENT_LIST_DIR}/QtGenerateLibHelpers.cmake")
file(STRINGS "${IN_FILE}" lines)
set(content "")
+set(qt_framework_search_path_inserted FALSE)
foreach(line ${lines})
if(line MATCHES "^RCC_OBJECTS = (.*)")
set(rcc_objects ${CMAKE_MATCH_1})
@@ -35,12 +33,22 @@ foreach(line ${lines})
continue()
endif()
if(IS_ABSOLUTE "${lib}")
- strip_library_version_suffix(lib "${lib}")
file(RELATIVE_PATH relative_lib "${QT_BUILD_LIBDIR}" "${lib}")
if(IS_ABSOLUTE "${relative_lib}" OR (relative_lib MATCHES "^\\.\\."))
- list(APPEND adjusted_libs "${lib}")
+ qt_transform_absolute_library_paths_to_link_flags(lib_with_link_flag "${lib}")
+ list(APPEND adjusted_libs "${lib_with_link_flag}")
else()
- list(APPEND adjusted_libs "$$[QT_INSTALL_LIBS]/${relative_lib}")
+ # Transform Qt framework paths into -framework flags.
+ if(relative_lib MATCHES "^(Qt(.+))\\.framework/")
+ if(NOT qt_framework_search_path_inserted)
+ set(qt_framework_search_path_inserted TRUE)
+ list(APPEND adjusted_libs "-F$$[QT_INSTALL_LIBS]")
+ endif()
+ list(APPEND adjusted_libs "-framework" "${CMAKE_MATCH_1}")
+ else()
+ qt_strip_library_version_suffix(relative_lib "${relative_lib}")
+ list(APPEND adjusted_libs "$$[QT_INSTALL_LIBS]/${relative_lib}")
+ endif()
endif()
else()
if(NOT lib MATCHES "^-l" AND NOT lib MATCHES "^-framework")