5b07f14a4f
After the update to the CMake based build system the ability to generate pkgconfig files, like it was with QMake, was lost. This patch adds pkgconfig generation again via a new internal command named qt_internal_export_pkg_config_file. The functionality of this command consists in checking if the target is internal. Then gets the compile definitions. It performs a search for dependencies that is somewhat similar to qt_get_direct_module_dependencies, although it won't recurse down for more deps. Each dependency is then again, checked if it's internal or has a public interface. Later these deps get deduplicated and lastly a pkgconfig file is filled. The resulting pkgconfig files of many of the Qt6 packages were validated via invocations of `pkg-config --validate` and `pkg-config --simulate` commands and later used to build local projects plus tests that use the pkg-config provided details at compilation time. Although it has some limitations, with qt_internal_add_qml_module if it specifies non-public deps these won't be listed and with non-Qt requirements, notably in static builds, not being appended to the PkgConfig file. Task-number: QTBUG-86080 Change-Id: I0690bb3ca729eec328500f227261db9b7e7628f6 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
29 lines
999 B
CMake
29 lines
999 B
CMake
# Finish a preliminary .pc file.
|
|
#
|
|
# - Appends to each requirement the proper configuration postfix.
|
|
# - Strips empty PkgConfig fields.
|
|
#
|
|
# This file is to be used in CMake script mode with the following variables set:
|
|
# IN_FILE: path to the step 2 preliminary .pc file.
|
|
# OUT_FILE: path to the .pc file that is going to be created.
|
|
# POSTFIX: postfix for each requirement (optional).
|
|
|
|
cmake_policy(SET CMP0057 NEW)
|
|
file(STRINGS "${IN_FILE}" lines)
|
|
set(content "")
|
|
set(emptied "Libs:" "Cflags:" "Requires:")
|
|
foreach(line ${lines})
|
|
if(POSTFIX)
|
|
if(line MATCHES "^Libs:")
|
|
string(REGEX REPLACE "( -lQt[^ ]+)" "\\1${POSTFIX}" line "${line}")
|
|
elseif(line MATCHES "^Requires:")
|
|
string(REGEX REPLACE "( Qt[^ ]+)" "\\1${POSTFIX}" line "${line}")
|
|
endif()
|
|
endif()
|
|
string(REGEX REPLACE " +$" "" line "${line}")
|
|
if(NOT line IN_LIST emptied)
|
|
string(APPEND content "${line}\n")
|
|
endif()
|
|
endforeach()
|
|
file(WRITE "${OUT_FILE}" "${content}")
|