Skip to content

Commit 731d9a1

Browse files
committed
CMake: Make generated pkgconfig files relocatable
Don't write an absolute prefix into generated .pc files but one that's relative to ${pcfiledir}. This makes the files relocatable, and we don't have to patch them in the Qt online installer. Pick-to: 6.8 6.9 Fixes: QTBUG-136210 Change-Id: I5c2f9398917be03f6c63286e553c87ff52971285 Reviewed-by: Alexey Edelev <[email protected]>
1 parent e307746 commit 731d9a1

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

cmake/PkgConfigLibrary.pc.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
prefix=@CMAKE_INSTALL_PREFIX@
1+
prefix=${pcfiledir}/@relative_install_prefix@
22
exec_prefix=${prefix}
33
bindir=${prefix}/@INSTALL_BINDIR@
44
libexecdir=${prefix}/@INSTALL_LIBEXECDIR@

cmake/QtPkgConfigHelpers.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ function(qt_internal_generate_pkg_config_file module)
125125
qt_path_join(pc_step1_path "${build_dir}" ${step_prefix}_step1.pc)
126126
qt_path_join(pc_step2_path "${build_dir}" ${step_prefix}_$<CONFIG>_step2.pc)
127127

128+
file(RELATIVE_PATH relative_install_prefix "/${path_suffix}" "/foo")
129+
get_filename_component(relative_install_prefix "${relative_install_prefix}" DIRECTORY)
130+
128131
configure_file("${template_pc}" "${pc_step1_path}" @ONLY)
129132

130133
file(GENERATE OUTPUT "${pc_step2_path}" INPUT "${pc_step1_path}")

0 commit comments

Comments
 (0)