summaryrefslogtreecommitdiffstats
path: root/cmake/QtGenerateLibPri.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/QtGenerateLibPri.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/QtGenerateLibPri.cmake')
-rw-r--r--cmake/QtGenerateLibPri.cmake74
1 files changed, 1 insertions, 73 deletions
diff --git a/cmake/QtGenerateLibPri.cmake b/cmake/QtGenerateLibPri.cmake
index 0e62536a1a..d4e0d04682 100644
--- a/cmake/QtGenerateLibPri.cmake
+++ b/cmake/QtGenerateLibPri.cmake
@@ -33,79 +33,7 @@ function(qmake_list out_var)
set(${out_var} ${result} PARENT_SCOPE)
endfunction()
-# Given "/usr/lib/x86_64-linux-gnu/libcups.so"
-# Returns "cups" or an empty string if the file is not an absolute library path.
-# Aka it strips the "lib" prefix, the .so extension and the base path.
-function(qt_get_library_name_without_prefix_and_suffix out_var file_path)
- set(out_value "")
- if(IS_ABSOLUTE "${file_path}")
- get_filename_component(basename "${file_path}" NAME_WE)
- get_filename_component(ext "${file_path}" EXT)
- foreach(libsuffix ${LIBRARY_SUFFIXES})
- # Handle weird prefix extensions like in the case of
- # "/usr/lib/x86_64-linux-gnu/libglib-2.0.so"
- # it's ".0.so".
- if(ext MATCHES "^(\\.[0-9]+)*${libsuffix}(\\.[0-9]+)*")
- set(is_linkable_library TRUE)
- set(weird_numbered_extension "${CMAKE_MATCH_1}")
- break()
- endif()
- endforeach()
- if(is_linkable_library)
- set(out_value "${basename}")
- if(LIBRARY_PREFIXES)
- foreach(libprefix ${LIBRARY_PREFIXES})
- # Strip any library prefix like "lib" for a library that we will use with a link
- # flag.
- if(libprefix AND out_value MATCHES "^${libprefix}(.+)")
- set(out_value "${CMAKE_MATCH_1}")
- break()
- endif()
- endforeach()
- endif()
- if(weird_numbered_extension)
- set(out_value "${out_value}${weird_numbered_extension}")
- endif()
- endif()
- endif()
-
- # Reverse the dependency order to be in sync with what qmake generated .pri files
- # have.
- list(REVERSE out_list)
-
- set(${out_var} "${out_value}" PARENT_SCOPE)
-endfunction()
-
-# Given "/usr/lib/x86_64-linux-gnu/libcups.so"
-# Returns "-lcups" or an empty string if the file is not an absolute library path.
-function(qt_get_library_with_link_flag out_var file_path)
- qt_get_library_name_without_prefix_and_suffix(lib_name "${file_path}")
-
- set(out_value "")
- if(lib_name)
- set(out_value "${lib_name}")
- if(LINK_LIBRARY_FLAG)
- string(PREPEND out_value "${LINK_LIBRARY_FLAG}")
- endif()
- endif()
-
- set(${out_var} "${out_value}" PARENT_SCOPE)
-endfunction()
-
-# Given a list of potential library paths, returns a transformed list where absolute library paths
-# are replaced with library link flags.
-function(qt_transform_absolute_library_paths_to_link_flags out_var library_path_list)
- set(out_list "")
- foreach(library_path ${library_path_list})
- qt_get_library_with_link_flag(lib_name_with_link_flag "${library_path}")
- if(lib_name_with_link_flag)
- list(APPEND out_list "${lib_name_with_link_flag}")
- else()
- list(APPEND out_list "${library_path}")
- endif()
- endforeach()
- set(${out_var} "${out_list}" PARENT_SCOPE)
-endfunction()
+include("${CMAKE_CURRENT_LIST_DIR}/QtGenerateLibHelpers.cmake")
list(POP_FRONT IN_FILES in_pri_file)
file(READ ${in_pri_file} content)