Changeset View
Changeset View
Standalone View
Standalone View
files/qt6-gen-pkgconfig.patch
- This file was added.
| --- /dev/null | |||||
| +++ b/cmake/Library.pc.in | |||||
| @@ -0,0 +1,12 @@ | |||||
| +prefix=@CMAKE_INSTALL_PREFIX@ | |||||
| +exec_prefix=${prefix} | |||||
| +bindir=${prefix}/@INSTALL_BINDIR@ | |||||
| +libdir=${prefix}/@INSTALL_LIBDIR@ | |||||
| +includedir=${prefix}/@INSTALL_INCLUDEDIR@ | |||||
| + | |||||
| +Name: @pkgconfig_name@ | |||||
| +Description: @pkgconfig_description@ | |||||
| +Version: @PROJECT_VERSION@ | |||||
| +Libs: -L${libdir} @target_libraries@ | |||||
| +Cflags: -I${includedir}/@target_dirname@ @target_defines@ | |||||
| +Requires: @target_requires@ | |||||
| --- a/cmake/QtBaseGlobalTargets.cmake | |||||
| +++ b/cmake/QtBaseGlobalTargets.cmake | |||||
| @@ -189,6 +189,7 @@ qt_install(FILES | |||||
| # The functions defined inside can not be used in public projects. | |||||
| # They can only be used while building Qt itself. | |||||
| qt_copy_or_install(FILES | |||||
| + cmake/Library.pc.in | |||||
| cmake/ModuleDescription.json.in | |||||
| cmake/Qt3rdPartyLibraryConfig.cmake.in | |||||
| cmake/Qt3rdPartyLibraryHelpers.cmake | |||||
| --- a/cmake/QtModuleHelpers.cmake | |||||
| +++ b/cmake/QtModuleHelpers.cmake | |||||
| @@ -11,6 +11,7 @@ macro(qt_internal_get_internal_add_modul | |||||
| NO_PRIVATE_MODULE | |||||
| NO_CONFIG_HEADER_FILE | |||||
| NO_ADDITIONAL_TARGET_INFO | |||||
| + NO_PKG_CONFIG | |||||
| NO_GENERATE_METATYPES | |||||
| GENERATE_METATYPES # TODO: Remove once it is not used anymore | |||||
| ) | |||||
| @@ -49,6 +50,10 @@ endmacro() | |||||
| # Don't generate a Qt6*AdditionalTargetInfo.cmake file. | |||||
| # The caller is responsible for creating one. | |||||
| # | |||||
| +# NO_PKG_CONFIG | |||||
| +# Don't generate a Qt6*.pc file. | |||||
| +# The caller is responsible for creating one. | |||||
| +# | |||||
| # MODULE_INTERFACE_NAME | |||||
| # The custom name of the module interface. This name is used as a part of the include paths | |||||
| # associated with the module and other interface names. The default value is the target name. | |||||
| @@ -673,6 +678,10 @@ set(QT_LIBINFIX \"${QT_LIBINFIX}\")") | |||||
| EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target} | |||||
| CONFIG_INSTALL_DIR "${config_install_dir}") | |||||
| + if(NOT arg_NO_PKG_CONFIG) | |||||
| + qt_internal_export_pkg_config_file(${target}) | |||||
| + endif() | |||||
| + | |||||
| ### fixme: cmake is missing a built-in variable for this. We want to apply it only to modules and plugins | |||||
| # that belong to Qt. | |||||
| if(NOT arg_HEADER_MODULE) | |||||
| --- a/cmake/QtTargetHelpers.cmake | |||||
| +++ b/cmake/QtTargetHelpers.cmake | |||||
| @@ -835,3 +835,102 @@ function(qt_internal_add_target_include_ | |||||
| qt_record_extra_third_party_dependency("${target}" "${dep_target}") | |||||
| endfunction() | |||||
| + | |||||
| +# Create a Qt6*.pc file intended for pkg-config consumption. | |||||
| +function(qt_internal_export_pkg_config_file module) | |||||
| + cmake_parse_arguments(arg | |||||
| + "${option_args}" | |||||
| + "${single_args}" | |||||
| + "${multi_args}" | |||||
| + ${ARGN}) | |||||
| + | |||||
| + set(pkgconfig_file "${QT_CMAKE_EXPORT_NAMESPACE}${module}") | |||||
| + set(pkgconfig_name "${QT_CMAKE_EXPORT_NAMESPACE} ${module}") | |||||
| + set(target_dirname "Qt${module}") | |||||
| + set(pkgconfig_description "Qt ${module} module") | |||||
| + set(target "${QT_CMAKE_EXPORT_NAMESPACE}::${module}") | |||||
| + | |||||
| + get_target_property(internal_module ${target} _qt_is_internal_module) | |||||
| + if(internal_module) | |||||
| + return() | |||||
| + endif() | |||||
| + | |||||
| + get_target_property(loose_target_defines ${target} INTERFACE_COMPILE_DEFINITIONS) | |||||
| + list(FILTER loose_target_defines EXCLUDE REGEX "\\$<TARGET_PROPERTY:[^,>]+>") | |||||
| + list(TRANSFORM loose_target_defines PREPEND "-D") | |||||
| + list(JOIN loose_target_defines " " target_defines) | |||||
| + | |||||
| + get_target_property(target_type ${target} TYPE) | |||||
| + if(arg_PRIVATE) | |||||
| + if(target_type STREQUAL "INTERFACE_LIBRARY") | |||||
| + set(libs) | |||||
| + else() | |||||
| + get_target_property(libs ${target} LINK_LIBRARIES) | |||||
| + list(REMOVE_DUPLICATES libs) | |||||
| + endif() | |||||
| + get_target_property(public_libs ${target} INTERFACE_LINK_LIBRARIES) | |||||
| + list(REMOVE_DUPLICATES public_libs) | |||||
| + | |||||
| + # Remove all Qt::Foo and Qt6::Foo from libs that also appear in public_libs. | |||||
| + set(libs_to_remove "") | |||||
| + foreach(lib IN LISTS public_libs) | |||||
| + list(APPEND libs_to_remove "${lib}") | |||||
| + if(lib MATCHES "^Qt::(.*)") | |||||
| + list(APPEND libs_to_remove "${QT_CMAKE_EXPORT_NAMESPACE}::${CMAKE_MATCH_1}") | |||||
| + elseif(lib MATCHES "^{QT_CMAKE_EXPORT_NAMESPACE}::(.*)") | |||||
| + list(APPEND libs_to_remove "Qt::${CMAKE_MATCH_1}") | |||||
| + endif() | |||||
| + endforeach() | |||||
| + | |||||
| + list(REMOVE_DUPLICATES libs_to_remove) | |||||
| + list(REMOVE_ITEM libs ${libs_to_remove}) | |||||
| + else() | |||||
| + get_target_property(libs ${target} INTERFACE_LINK_LIBRARIES) | |||||
| + endif() | |||||
| + | |||||
| + set(loose_target_requires "") | |||||
| + set(loose_target_libraries "-l${pkgconfig_file}") | |||||
| + foreach(dep IN LISTS libs) | |||||
| + if(dep MATCHES "^\\$<LINK_ONLY:(.*)>$") | |||||
| + set(dep ${CMAKE_MATCH_1}) | |||||
| + endif() | |||||
| + get_target_property(type ${dep} TYPE) | |||||
| + string(REGEX REPLACE "(Qt|{QT_CMAKE_EXPORT_NAMESPACE})::" "${QT_CMAKE_EXPORT_NAMESPACE}" req ${dep}) | |||||
| + if(type STREQUAL INTERFACE_LIBRARY) | |||||
| + get_target_property(lib ${dep} INTERFACE_LINK_LIBRARIES) | |||||
| + if(NOT lib) | |||||
| + continue() | |||||
| + endif() | |||||
| + get_target_property(modName ${lib} _qt_config_module_name) | |||||
| + if(modName) | |||||
| + message("Library is ${lib}") | |||||
| + message("Module name is ${modName}") | |||||
| + list(APPEND loose_target_requires ${req}) | |||||
| + endif() | |||||
| + endif() | |||||
| + if(type STREQUAL SHARED_LIBRARY) | |||||
| + list(APPEND loose_target_requires ${req}) | |||||
| + elseif(type STREQUAL STATIC_LIBRARY) | |||||
| + list(APPEND loose_target_libraries -l${req}) | |||||
| + endif() | |||||
| + endforeach() | |||||
| + list(JOIN loose_target_requires " " target_requires) | |||||
| + list(JOIN loose_target_libraries " " target_libraries) | |||||
| + | |||||
| + set(path_suffix "${INSTALL_LIBDIR}/pkgconfig") | |||||
| + qt_path_join(build_dir ${QT_BUILD_DIR} ${path_suffix}) | |||||
| + qt_path_join(install_dir ${QT_INSTALL_DIR} ${path_suffix}) | |||||
| + | |||||
| + set(descfile_in "${QT_CMAKE_DIR}/Library.pc.in") | |||||
| + set(descfile_out "${build_dir}/${pkgconfig_file}.pc") | |||||
| + configure_file("${descfile_in}" "${descfile_out}" @ONLY) | |||||
| + | |||||
| + if(NOT target_requires) | |||||
| + file(STRINGS "${build_dir}/${pkgconfig_file}.pc" pkgconfig_lines) | |||||
| + list(FILTER pkgconfig_lines EXCLUDE REGEX "^Requires:") | |||||
| + list(JOIN pkgconfig_lines "\n" pkgconfig_out) | |||||
| + file(WRITE "${build_dir}/${pkgconfig_file}.pc" "${pkgconfig_out}") | |||||
| + endif() | |||||
| + | |||||
| + qt_install(FILES "${descfile_out}" DESTINATION "${install_dir}") | |||||
| +endfunction() | |||||
Copyright © 2015-2021 Solus Project. The Solus logo is Copyright © 2016-2021 Solus Project. All Rights Reserved.