summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/FindPCRE2.cmake2
-rw-r--r--cmake/FindPPS.cmake2
-rw-r--r--cmake/FindSlog2.cmake2
-rw-r--r--cmake/FindWrapDoubleConversion.cmake3
-rw-r--r--cmake/FindWrapOpenGL.cmake4
-rw-r--r--cmake/FindWrapRt.cmake2
-rw-r--r--cmake/FindZSTD.cmake1
-rw-r--r--cmake/QtBaseGlobalTargets.cmake9
-rw-r--r--cmake/QtBuild.cmake56
-rw-r--r--cmake/QtModuleConfig.cmake.in5
-rw-r--r--cmake/QtModuleDependencies.cmake.in34
-rw-r--r--cmake/QtPostProcess.cmake53
-rw-r--r--configure.cmake6
-rw-r--r--examples/widgets/graphicsview/boxes/CMakeLists.txt3
-rw-r--r--src/corelib/CMakeLists.txt4
-rw-r--r--src/corelib/configure.cmake18
-rw-r--r--src/gui/CMakeLists.txt2
-rw-r--r--src/gui/configure.cmake40
-rw-r--r--src/network/CMakeLists.txt2
-rw-r--r--src/network/configure.cmake4
-rw-r--r--src/platformsupport/eglconvenience/CMakeLists.txt2
-rw-r--r--src/platformsupport/eventdispatchers/CMakeLists.txt2
-rw-r--r--src/platformsupport/fontdatabases/CMakeLists.txt4
-rw-r--r--src/platformsupport/glxconvenience/CMakeLists.txt4
-rw-r--r--src/platformsupport/input/CMakeLists.txt8
-rw-r--r--src/platformsupport/kmsconvenience/CMakeLists.txt2
-rw-r--r--src/platformsupport/linuxaccessibility/CMakeLists.txt2
-rw-r--r--src/platformsupport/vkconvenience/CMakeLists.txt2
-rw-r--r--src/plugins/generic/tslib/CMakeLists.txt2
-rw-r--r--src/plugins/imageformats/jpeg/CMakeLists.txt2
-rw-r--r--src/plugins/platforminputcontexts/compose/CMakeLists.txt2
-rw-r--r--src/plugins/platforms/cocoa/CMakeLists.txt4
-rw-r--r--src/plugins/platforms/eglfs/CMakeLists.txt4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/CMakeLists.txt4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/CMakeLists.txt2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/CMakeLists.txt6
-rw-r--r--src/plugins/platforms/minimal/CMakeLists.txt2
-rw-r--r--src/plugins/platforms/minimalegl/CMakeLists.txt2
-rw-r--r--src/plugins/platforms/xcb/CMakeLists.txt14
-rw-r--r--src/plugins/platformthemes/gtk3/CMakeLists.txt4
-rw-r--r--src/plugins/printsupport/cups/CMakeLists.txt2
-rw-r--r--src/plugins/sqldrivers/configure.cmake6
-rw-r--r--src/plugins/sqldrivers/odbc/CMakeLists.txt2
-rw-r--r--src/plugins/sqldrivers/psql/CMakeLists.txt2
-rw-r--r--src/printsupport/configure.cmake2
-rw-r--r--src/widgets/configure.cmake2
-rwxr-xr-xutil/cmake/configurejson2cmake.py13
-rw-r--r--util/cmake/helper.py6
49 files changed, 264 insertions, 99 deletions
diff --git a/cmake/FindPCRE2.cmake b/cmake/FindPCRE2.cmake
index 7e45c963d7..3977532124 100644
--- a/cmake/FindPCRE2.cmake
+++ b/cmake/FindPCRE2.cmake
@@ -5,7 +5,7 @@ find_path(PCRE2_INCLUDE_DIRS pcre2.h)
if (PCRE2_LIBRARIES STREQUAL "PCRE2_LIBRARIES-NOTFOUND" OR PCRE2_INCLUDE_DIRS STREQUAL "PCRE2_INCLUDE_DIRS-NOTFOUND")
set(PCRE2_FOUND 0)
else()
- add_library(PCRE2 INTERFACE)
+ add_library(PCRE2 INTERFACE IMPORTED)
target_link_libraries(PCRE2 INTERFACE ${PCRE2_LIBRARIES})
target_include_directories(PCRE2 INTERFACE ${PCRE2_INCLUDE_DIRS})
set(PCRE2_FOUND 1)
diff --git a/cmake/FindPPS.cmake b/cmake/FindPPS.cmake
index b1e418f227..c3360fa82c 100644
--- a/cmake/FindPPS.cmake
+++ b/cmake/FindPPS.cmake
@@ -11,7 +11,7 @@ find_package_handle_standard_args(PPS DEFAULT_MSG PPS_INCLUDE_DIR PPS_LIBRARY)
mark_as_advanced(PPS_INCLUDE_DIR PPS_LIBRARY)
if(PPS_FOUND)
- add_library(__PPS IMPORTED)
+ add_library(__PPS INTERFACE IMPORTED)
target_link_libraries(__PPS INTERFACE ${PPS_LIBRARY})
target_include_directories(__PPS INTERFACE ${PPS_INCLUDE_DIR})
diff --git a/cmake/FindSlog2.cmake b/cmake/FindSlog2.cmake
index 8ff00e4157..dfb6635a39 100644
--- a/cmake/FindSlog2.cmake
+++ b/cmake/FindSlog2.cmake
@@ -11,7 +11,7 @@ find_package_handle_standard_args(Slog2 DEFAULT_MSG Slog2_INCLUDE_DIR Slog2_LIBR
mark_as_advanced(Slog2_INCLUDE_DIR Slog2_LIBRARY)
if(Slog2_FOUND)
- add_library(__Slog2 IMPORTED)
+ add_library(__Slog2 INTERFACE IMPORTED)
target_link_libraries(__Slog2 INTERFACE ${Slog2_LIBRARY})
target_include_directories(__Slog2 INTERFACE ${Slog2_INCLUDE_DIR})
diff --git a/cmake/FindWrapDoubleConversion.cmake b/cmake/FindWrapDoubleConversion.cmake
index 749965a7b8..cfb70a0981 100644
--- a/cmake/FindWrapDoubleConversion.cmake
+++ b/cmake/FindWrapDoubleConversion.cmake
@@ -1,9 +1,10 @@
include(CheckCXXSourceCompiles)
-add_library(WrapDoubleConversion INTERFACE)
+add_library(WrapDoubleConversion INTERFACE IMPORTED)
find_package(double-conversion)
if (double-conversion_FOUND)
+ include(FeatureSummary)
set_package_properties(double-conversion PROPERTIES TYPE REQUIRED)
target_link_libraries(WrapDoubleConversion INTERFACE double-conversion::double-conversion)
set(WrapDoubleConversion_FOUND 1)
diff --git a/cmake/FindWrapOpenGL.cmake b/cmake/FindWrapOpenGL.cmake
index c97ba0e466..b3c60ba953 100644
--- a/cmake/FindWrapOpenGL.cmake
+++ b/cmake/FindWrapOpenGL.cmake
@@ -6,7 +6,7 @@ if(TARGET WrapOpenGL)
return()
endif()
-add_library(WrapOpenGL INTERFACE)
+add_library(WrapOpenGL INTERFACE IMPORTED)
if(QT_FEATURE_opengles2)
find_package(GLESv2)
@@ -16,3 +16,5 @@ else()
target_link_libraries(WrapOpenGL INTERFACE OpenGL::GL)
endif()
set(WrapOpenGL_FOUND ON)
+
+set_property(TARGET WrapOpenGL PROPERTY IMPORTED_GLOBAL TRUE)
diff --git a/cmake/FindWrapRt.cmake b/cmake/FindWrapRt.cmake
index dee41e0617..ef5475c53d 100644
--- a/cmake/FindWrapRt.cmake
+++ b/cmake/FindWrapRt.cmake
@@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
cmake_pop_check_state()
-add_library(WrapRt INTERFACE)
+add_library(WrapRt INTERFACE IMPORTED)
if (LIBRT_FOUND)
target_link_libraries(WrapRt INTERFACE "${LIBRT}")
endif()
diff --git a/cmake/FindZSTD.cmake b/cmake/FindZSTD.cmake
index 040e8c1642..4f4590d357 100644
--- a/cmake/FindZSTD.cmake
+++ b/cmake/FindZSTD.cmake
@@ -43,6 +43,7 @@ endif()
mark_as_advanced(ZSTD_INCLUDE_DIRS ZSTD_LIBRARIES)
+include(FeatureSummary)
set_package_properties(ZSTD PROPERTIES
URL "https://github.com/facebook/zstd"
DESCRIPTION "ZSTD compression library")
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index 613dc49242..d50d1e2c2b 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -95,3 +95,12 @@ install(FILES
install(DIRECTORY cmake/3rdparty
DESTINATION "${config_install_dir}"
)
+
+# Install our custom Find modules, which will be used by the find_dependency() calls
+# inside the generated ModuleDependencies cmake files.
+install(DIRECTORY cmake/
+ DESTINATION "${config_install_dir}"
+ FILES_MATCHING PATTERN "Find*.cmake"
+ PATTERN "tests" EXCLUDE
+ PATTERN "3rdparty" EXCLUDE
+)
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 0057190360..f5775f2b1f 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -1365,3 +1365,59 @@ endfunction()
function(add_qt_docs qdocFile)
# TODO
endfunction()
+
+macro(qt_find_package)
+ # Get the target names we expect to be provided by the package.
+ cmake_parse_arguments(arg "" "" "PROVIDED_TARGETS;COMPONENTS" ${ARGN})
+
+ # Get the version if specified.
+ set(package_version "")
+ if(${ARGC} GREATER_EQUAL 2)
+ if(${ARGV1} MATCHES "^[0-9\.]+$")
+ set(package_version "${ARGV1}")
+ endif()
+ endif()
+
+ if(arg_COMPONENTS)
+ # Re-append components to forward them.
+ list(APPEND arg_UNPARSED_ARGUMENTS "COMPONENTS;${arg_COMPONENTS}")
+ endif()
+
+ # Call original function without our custom arguments.
+ find_package(${arg_UNPARSED_ARGUMENTS})
+
+ if(${ARGV0}_FOUND AND arg_PROVIDED_TARGETS)
+ # If package was found, associate each target with its package name. This will be used
+ # later when creating Config files for Qt libraries, to generate correct find_dependency()
+ # calls. Also make the provided targets global, so that the properties can be read in
+ # all scopes.
+ foreach(qt_find_package_target_name ${arg_PROVIDED_TARGETS})
+ if(TARGET ${qt_find_package_target_name})
+ set_target_properties(${qt_find_package_target_name}
+ PROPERTIES INTERFACE_QT_PACKAGE_NAME ${ARGV0})
+ if(package_version)
+ set_target_properties(${qt_find_package_target_name}
+ PROPERTIES INTERFACE_QT_PACKAGE_VERSION ${ARGV1})
+ endif()
+
+ if(arg_COMPONENTS)
+ set_target_properties(${qt_find_package_target_name}
+ PROPERTIES
+ INTERFACE_QT_PACKAGE_COMPONENTS ${arg_COMPONENTS})
+ endif()
+
+ get_property(is_global TARGET ${qt_find_package_target_name} PROPERTY
+ IMPORTED_GLOBAL)
+ if(NOT is_global)
+ set_property(TARGET ${qt_find_package_target_name} PROPERTY
+ IMPORTED_GLOBAL TRUE)
+ endif()
+ else()
+ message(FATAL_ERROR
+ "Error while trying to mark target '${qt_find_package_target_name}' as part"
+ " of the ${ARGV0} package. Provided target name does not exist.")
+ endif()
+
+ endforeach()
+ endif()
+endmacro()
diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in
index e9eec7ae94..9a0f0c368c 100644
--- a/cmake/QtModuleConfig.cmake.in
+++ b/cmake/QtModuleConfig.cmake.in
@@ -5,6 +5,11 @@ include(CMakeFindDependencyMacro)
get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_import_prefix "${_import_prefix}" REALPATH)
+# Find required dependencies, if any.
+if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
+endif()
+
# note: target_deps example: "Qt5Core\;5.12.0;Qt5Gui\;5.12.0"
set(_target_deps "@target_deps@")
foreach(_target_dep ${_target_deps})
diff --git a/cmake/QtModuleDependencies.cmake.in b/cmake/QtModuleDependencies.cmake.in
new file mode 100644
index 0000000000..7ff02df894
--- /dev/null
+++ b/cmake/QtModuleDependencies.cmake.in
@@ -0,0 +1,34 @@
+# Save old module path, and append a new path that points to the copied over Find modules
+# so that find_dependency() can find the third party packages.
+set(old_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}")
+list(APPEND CMAKE_MODULE_PATH "${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@")
+list(APPEND CMAKE_MODULE_PATH "${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@/3rdparty/extra-cmake-modules/find-modules")
+
+# note: _third_party_deps example: "ICU\\;1.0\\;i18n uc data;ZLIB\\;\\;"
+set(_third_party_deps "@third_party_deps@")
+
+foreach(_target_dep ${_third_party_deps})
+ list(GET _target_dep 0 pkg)
+ list(GET _target_dep 1 version)
+ list(GET _target_dep 2 components)
+ set(find_package_args "${pkg}")
+ if(version)
+ list(APPEND find_package_args "${version}")
+ endif()
+
+ if(components)
+ list(APPEND find_package_args "COMPONENTS" ${components})
+ endif()
+
+ if (NOT ${pkg}_FOUND)
+ find_dependency(${find_package_args})
+ endif()
+
+ if (NOT ${pkg}_FOUND)
+ set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
+ return()
+ endif()
+endforeach()
+
+# Restore old module path.
+set(CMAKE_MODULE_PATH "${old_CMAKE_MODULE_PATH}")
diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake
index e63bcc0538..10dd5bfbb1 100644
--- a/cmake/QtPostProcess.cmake
+++ b/cmake/QtPostProcess.cmake
@@ -16,7 +16,10 @@ function(qt_internal_create_depends_files)
message("Generating depends files for ${QT_KNOWN_MODULES}...")
foreach (target ${QT_KNOWN_MODULES})
get_target_property(depends "${target}" LINK_LIBRARIES)
+ get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
set(qtdeps "")
+ set(third_party_deps "")
+ set(third_party_deps_seen "")
foreach (dep ${depends})
# Normalize module by stripping leading "Qt::" and trailing "Private"
if (dep MATCHES "Qt::(.*)")
@@ -32,6 +35,37 @@ function(qt_internal_create_depends_files)
endif()
endforeach()
+ # If we are doing a non-static Qt build, we only want to propagate public dependencies.
+ # If we are doing a static Qt build, we need to propagate all dependencies.
+ set(depends_var "public_depends")
+ if(NOT QT_BUILD_SHARED_LIBS)
+ set(depends_var "depends")
+ endif()
+
+ foreach(dep ${${depends_var}})
+ # Gather third party packages that should be found when using the Qt module.
+ if(TARGET ${dep})
+ list(FIND third_party_deps_seen ${dep} dep_seen)
+
+ get_target_property(package_name ${dep} INTERFACE_QT_PACKAGE_NAME)
+ if(dep_seen EQUAL -1 AND package_name)
+ list(APPEND third_party_deps_seen ${dep})
+ get_target_property(package_version ${dep} INTERFACE_QT_PACKAGE_VERSION)
+ if(NOT package_version)
+ set(package_version "")
+ endif()
+
+ get_target_property(package_components ${dep} INTERFACE_QT_PACKAGE_COMPONENTS)
+ if(NOT package_components)
+ set(package_components "")
+ endif()
+
+ list(APPEND third_party_deps
+ "${package_name}\;${package_version}\;${package_components}")
+ endif()
+ endif()
+ endforeach()
+
if (DEFINED qtdeps)
list(REMOVE_DUPLICATES qtdeps)
endif()
@@ -40,7 +74,26 @@ function(qt_internal_create_depends_files)
if (${hasModuleHeaders})
qt_internal_write_depends_file("${target}" ${qtdeps})
endif()
+
+ if(third_party_deps)
+ # Configure and install dependencies file.
+ configure_file(
+ "${QT_CMAKE_DIR}/QtModuleDependencies.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
+ @ONLY
+ )
+
+ set(config_install_dir "${INSTALL_LIBDIR}/cmake/${INSTALL_CMAKE_NAMESPACE}${target}")
+
+ install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Dependencies.cmake"
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+ endif()
endforeach()
+
+
endfunction()
qt_internal_create_depends_files()
diff --git a/configure.cmake b/configure.cmake
index cd03d9af01..39a85a3f25 100644
--- a/configure.cmake
+++ b/configure.cmake
@@ -6,11 +6,11 @@
#### Libraries
-find_package(ZLIB)
+qt_find_package(ZLIB PROVIDED_TARGETS ZLIB::ZLIB)
set_package_properties(ZLIB PROPERTIES TYPE OPTIONAL)
-find_package(ZSTD)
+qt_find_package(ZSTD PROVIDED_TARGETS ZSTD::ZSTD)
set_package_properties(ZSTD PROPERTIES TYPE OPTIONAL)
-find_package(Libudev)
+qt_find_package(Libudev PROVIDED_TARGETS PkgConfig::Libudev)
set_package_properties(Libudev PROPERTIES TYPE OPTIONAL)
diff --git a/examples/widgets/graphicsview/boxes/CMakeLists.txt b/examples/widgets/graphicsview/boxes/CMakeLists.txt
index 10ff8b5b47..af2891ffb1 100644
--- a/examples/widgets/graphicsview/boxes/CMakeLists.txt
+++ b/examples/widgets/graphicsview/boxes/CMakeLists.txt
@@ -1,7 +1,6 @@
# Generated from boxes.pro.
-find_package(WrapOpenGL)
-
+qt_find_package(WrapOpenGL PROVIDED_TARGETS WrapOpenGL) # special case
#####################################################################
## boxes Binary:
#####################################################################
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 37e89a3648..5aee60e7e1 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -1,8 +1,8 @@
# Generated from corelib.pro.
# special case:
-find_package(Threads)
-find_package(WrapDoubleConversion REQUIRED)
+qt_find_package(Threads PROVIDED_TARGETS Threads::Threads)
+qt_find_package(WrapDoubleConversion REQUIRED PROVIDED_TARGETS WrapDoubleConversion)
if (NOT WrapDoubleConversion_FOUND)
message(FATAL_ERROR "Your C library does not provide \
diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake
index 10d2ea60de..e9794dc2a4 100644
--- a/src/corelib/configure.cmake
+++ b/src/corelib/configure.cmake
@@ -10,23 +10,23 @@ set_property(CACHE INPUT_iconv PROPERTY STRINGS undefined no yes posix sun gnu)
#### Libraries
-find_package(GLIB2)
+qt_find_package(GLIB2 PROVIDED_TARGETS GLIB2::GLIB2)
set_package_properties(GLIB2 PROPERTIES TYPE OPTIONAL)
-find_package(ICU COMPONENTS i18n uc data)
+qt_find_package(ICU COMPONENTS i18n uc data PROVIDED_TARGETS ICU::i18n ICU::uc ICU::data)
set_package_properties(ICU PROPERTIES TYPE OPTIONAL)
-find_package(Libsystemd)
+qt_find_package(Libsystemd)
set_package_properties(Libsystemd PROPERTIES TYPE OPTIONAL)
-find_package(Atomic)
+qt_find_package(Atomic PROVIDED_TARGETS Atomic)
set_package_properties(Atomic PROPERTIES TYPE OPTIONAL)
-find_package(WrapRt)
+qt_find_package(WrapRt PROVIDED_TARGETS WrapRt)
set_package_properties(WrapRt PROPERTIES TYPE OPTIONAL)
-find_package(LTTngUST)
+qt_find_package(LTTngUST)
set_package_properties(LTTngUST PROPERTIES TYPE OPTIONAL)
-find_package(PCRE2)
+qt_find_package(PCRE2 PROVIDED_TARGETS PCRE2)
set_package_properties(PCRE2 PROPERTIES TYPE REQUIRED)
-find_package(PPS)
+qt_find_package(PPS)
set_package_properties(PPS PROPERTIES TYPE OPTIONAL)
-find_package(Slog2)
+qt_find_package(Slog2)
set_package_properties(Slog2 PROPERTIES TYPE OPTIONAL)
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index fb60ac2781..1ddee1692d 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -427,7 +427,7 @@ extend_target(Gui CONDITION QT_FEATURE_draganddrop
# here (where the feature is available).
# DO NOT MOVE THIS TO THE BEGINNING OF THE FILE, the feature variables are not
# available until the add_qt_module call.
-find_package(WrapOpenGL) # special case
+qt_find_package(WrapOpenGL PROVIDED_TARGETS WrapOpenGL) # special case
extend_target(Gui CONDITION QT_FEATURE_opengl
SOURCES
diff --git a/src/gui/configure.cmake b/src/gui/configure.cmake
index b11e06bdb4..3d155e2065 100644
--- a/src/gui/configure.cmake
+++ b/src/gui/configure.cmake
@@ -22,45 +22,45 @@ set_property(CACHE INPUT_xcb PROPERTY STRINGS undefined no yes qt system)
#### Libraries
-find_package(ATSPI2)
+qt_find_package(ATSPI2 PROVIDED_TARGETS PkgConfig::ATSPI2)
set_package_properties(ATSPI2 PROPERTIES TYPE OPTIONAL)
-find_package(Libdrm)
+qt_find_package(Libdrm PROVIDED_TARGETS Libdrm::Libdrm)
set_package_properties(Libdrm PROPERTIES TYPE OPTIONAL)
-find_package(EGL)
+qt_find_package(EGL)
set_package_properties(EGL PROPERTIES TYPE OPTIONAL)
-find_package(Freetype)
+qt_find_package(Freetype PROVIDED_TARGETS Freetype::Freetype)
set_package_properties(Freetype PROPERTIES TYPE REQUIRED)
-find_package(Fontconfig)
+qt_find_package(Fontconfig PROVIDED_TARGETS Fontconfig::Fontconfig)
set_package_properties(Fontconfig PROPERTIES TYPE OPTIONAL)
-find_package(gbm)
+qt_find_package(gbm PROVIDED_TARGETS gbm::gbm)
set_package_properties(gbm PROPERTIES TYPE OPTIONAL)
-find_package(harfbuzz)
+qt_find_package(harfbuzz PROVIDED_TARGETS harfbuzz::harfbuzz)
set_package_properties(harfbuzz PROPERTIES TYPE OPTIONAL)
-find_package(Libinput)
+qt_find_package(Libinput PROVIDED_TARGETS Libinput::Libinput)
set_package_properties(Libinput PROPERTIES TYPE OPTIONAL)
-find_package(JPEG)
+qt_find_package(JPEG)
set_package_properties(JPEG PROPERTIES TYPE OPTIONAL)
-find_package(PNG)
+qt_find_package(PNG PROVIDED_TARGETS PNG::PNG)
set_package_properties(PNG PROPERTIES TYPE OPTIONAL)
-find_package(Mtdev)
+qt_find_package(Mtdev PROVIDED_TARGETS PkgConfig::Mtdev)
set_package_properties(Mtdev PROPERTIES TYPE OPTIONAL)
-find_package(OpenGL)
+qt_find_package(OpenGL)
set_package_properties(OpenGL PROPERTIES TYPE OPTIONAL)
-find_package(GLESv2)
+qt_find_package(GLESv2)
set_package_properties(GLESv2 PROPERTIES TYPE OPTIONAL)
-find_package(Tslib)
+qt_find_package(Tslib PROVIDED_TARGETS PkgConfig::Tslib)
set_package_properties(Tslib PROPERTIES TYPE OPTIONAL)
-find_package(Vulkan)
+qt_find_package(Vulkan)
set_package_properties(Vulkan PROPERTIES TYPE OPTIONAL)
-find_package(Wayland)
+qt_find_package(Wayland)
set_package_properties(Wayland PROPERTIES TYPE OPTIONAL)
-find_package(X11)
+qt_find_package(X11)
set_package_properties(X11 PROPERTIES TYPE OPTIONAL)
-find_package(XCB 1.9)
+qt_find_package(XCB 1.9 PROVIDED_TARGETS XCB::XCB)
set_package_properties(XCB PROPERTIES TYPE OPTIONAL)
-find_package(X11_XCB)
+qt_find_package(X11_XCB PROVIDED_TARGETS X11::XCB)
set_package_properties(X11_XCB PROPERTIES TYPE OPTIONAL)
-find_package(XKB 0.4.1)
+qt_find_package(XKB 0.4.1 PROVIDED_TARGETS XKB::XKB)
set_package_properties(XKB PROPERTIES TYPE OPTIONAL)
diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt
index 02d31fc468..380ed8e946 100644
--- a/src/network/CMakeLists.txt
+++ b/src/network/CMakeLists.txt
@@ -227,7 +227,7 @@ extend_target(Network CONDITION QT_FEATURE_libproxy AND NOT APPLE_OSX AND (UNIX
kernel/qnetworkproxy_libproxy.cpp
LIBRARIES
${CMAKE_DL_LIBS}
- LibProxy::LibProxy
+ PkgConfig::Libproxy
)
extend_target(Network CONDITION NOT APPLE_OSX AND NOT QT_FEATURE_libproxy AND (UNIX OR WINRT)
diff --git a/src/network/configure.cmake b/src/network/configure.cmake
index 0bb54a6f7d..c765f59c5d 100644
--- a/src/network/configure.cmake
+++ b/src/network/configure.cmake
@@ -6,9 +6,9 @@
#### Libraries
-find_package(Libproxy)
+qt_find_package(Libproxy PROVIDED_TARGETS PkgConfig::Libproxy)
set_package_properties(Libproxy PROPERTIES TYPE OPTIONAL)
-find_package(OpenSSL)
+qt_find_package(OpenSSL)
set_package_properties(OpenSSL PROPERTIES TYPE OPTIONAL)
diff --git a/src/platformsupport/eglconvenience/CMakeLists.txt b/src/platformsupport/eglconvenience/CMakeLists.txt
index 2cbc02073c..f2db6c746e 100644
--- a/src/platformsupport/eglconvenience/CMakeLists.txt
+++ b/src/platformsupport/eglconvenience/CMakeLists.txt
@@ -1,4 +1,4 @@
-find_package(EGL) # special case
+qt_find_package(EGL) # special case
#####################################################################
## EglSupport Module:
diff --git a/src/platformsupport/eventdispatchers/CMakeLists.txt b/src/platformsupport/eventdispatchers/CMakeLists.txt
index ba0d71f03b..4037204f60 100644
--- a/src/platformsupport/eventdispatchers/CMakeLists.txt
+++ b/src/platformsupport/eventdispatchers/CMakeLists.txt
@@ -1,4 +1,4 @@
-find_package(GLIB2) # special case
+qt_find_package(GLIB2) # special case
set_package_properties(GLib PROPERTIES TYPE OPTIONAL) # special case
#####################################################################
diff --git a/src/platformsupport/fontdatabases/CMakeLists.txt b/src/platformsupport/fontdatabases/CMakeLists.txt
index be1047eb13..7a0ef39b25 100644
--- a/src/platformsupport/fontdatabases/CMakeLists.txt
+++ b/src/platformsupport/fontdatabases/CMakeLists.txt
@@ -1,5 +1,5 @@
-find_package(Freetype) # special case
-find_package(Fontconfig) # special case
+qt_find_package(Freetype) # special case
+qt_find_package(Fontconfig) # special case
#####################################################################
## FontDatabaseSupport Module:
diff --git a/src/platformsupport/glxconvenience/CMakeLists.txt b/src/platformsupport/glxconvenience/CMakeLists.txt
index 6bc3e1629e..8480a35125 100644
--- a/src/platformsupport/glxconvenience/CMakeLists.txt
+++ b/src/platformsupport/glxconvenience/CMakeLists.txt
@@ -1,5 +1,5 @@
-find_package(X11) # special case
-find_package(OpenGL) # special case
+qt_find_package(X11) # special case
+qt_find_package(OpenGL) # special case
#####################################################################
## GlxSupport Module:
diff --git a/src/platformsupport/input/CMakeLists.txt b/src/platformsupport/input/CMakeLists.txt
index 1ab85ce239..5ecbbbbe30 100644
--- a/src/platformsupport/input/CMakeLists.txt
+++ b/src/platformsupport/input/CMakeLists.txt
@@ -1,9 +1,9 @@
# Generated from input.pro.
-find_package(Libinput) # special case
-find_package(XKB) # special case
-find_package(Tslib) # special case
-find_package(Mtdev) # special case
+qt_find_package(Libinput) # special case
+qt_find_package(XKB) # special case
+qt_find_package(Tslib) # special case
+qt_find_package(Mtdev) # special case
#####################################################################
## InputSupport Module:
diff --git a/src/platformsupport/kmsconvenience/CMakeLists.txt b/src/platformsupport/kmsconvenience/CMakeLists.txt
index cf006fbeed..1f9f4fbf36 100644
--- a/src/platformsupport/kmsconvenience/CMakeLists.txt
+++ b/src/platformsupport/kmsconvenience/CMakeLists.txt
@@ -1,4 +1,4 @@
-find_package(Libdrm) # special case
+qt_find_package(Libdrm) # special case
#####################################################################
## KmsSupport Module:
diff --git a/src/platformsupport/linuxaccessibility/CMakeLists.txt b/src/platformsupport/linuxaccessibility/CMakeLists.txt
index 5478c9f773..81914f7cd8 100644
--- a/src/platformsupport/linuxaccessibility/CMakeLists.txt
+++ b/src/platformsupport/linuxaccessibility/CMakeLists.txt
@@ -1,4 +1,4 @@
-find_package(ATSPI2 REQUIRED) # special case
+qt_find_package(ATSPI2 REQUIRED) # special case
#####################################################################
## LinuxAccessibilitySupport Module:
diff --git a/src/platformsupport/vkconvenience/CMakeLists.txt b/src/platformsupport/vkconvenience/CMakeLists.txt
index 106f78fb3d..659ee0cdbd 100644
--- a/src/platformsupport/vkconvenience/CMakeLists.txt
+++ b/src/platformsupport/vkconvenience/CMakeLists.txt
@@ -1,4 +1,4 @@
-find_package(Vulkan) # special case
+qt_find_package(Vulkan) # special case
#####################################################################
## VulkanSupport Module:
diff --git a/src/plugins/generic/tslib/CMakeLists.txt b/src/plugins/generic/tslib/CMakeLists.txt
index b46217d845..b4f0c9ab04 100644
--- a/src/plugins/generic/tslib/CMakeLists.txt
+++ b/src/plugins/generic/tslib/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from tslib.pro.
-find_package(Tslib) # special case
+qt_find_package(Tslib) # special case
#####################################################################
## qtslibplugin Plugin:
diff --git a/src/plugins/imageformats/jpeg/CMakeLists.txt b/src/plugins/imageformats/jpeg/CMakeLists.txt
index f70c72b992..39c45bc2fe 100644
--- a/src/plugins/imageformats/jpeg/CMakeLists.txt
+++ b/src/plugins/imageformats/jpeg/CMakeLists.txt
@@ -4,7 +4,7 @@
## qjpeg Plugin:
#####################################################################
-find_package(JPEG)
+qt_find_package(JPEG) # special case
add_qt_plugin(qjpeg
TYPE imageformats
diff --git a/src/plugins/platforminputcontexts/compose/CMakeLists.txt b/src/plugins/platforminputcontexts/compose/CMakeLists.txt
index eaa3ac8f73..e903d56d74 100644
--- a/src/plugins/platforminputcontexts/compose/CMakeLists.txt
+++ b/src/plugins/platforminputcontexts/compose/CMakeLists.txt
@@ -4,7 +4,7 @@
## composeplatforminputcontextplugin Plugin:
#####################################################################
-find_package(XKB) # special case
+qt_find_package(XKB) # special case
pkg_get_variable(PKG_X11_PREFIX x11 prefix) # special case
diff --git a/src/plugins/platforms/cocoa/CMakeLists.txt b/src/plugins/platforms/cocoa/CMakeLists.txt
index 0b08d49390..9a6902356e 100644
--- a/src/plugins/platforms/cocoa/CMakeLists.txt
+++ b/src/plugins/platforms/cocoa/CMakeLists.txt
@@ -1,8 +1,8 @@
# Generated from cocoa.pro.
# special case:
-find_package(Cups)
-find_package(WrapOpenGL)
+qt_find_package(Cups PROVIDED_TARGETS Cups::Cups)
+qt_find_package(WrapOpenGL PROVIDED_TARGETS WrapOpenGL)
#####################################################################
## qcocoa Plugin:
diff --git a/src/plugins/platforms/eglfs/CMakeLists.txt b/src/plugins/platforms/eglfs/CMakeLists.txt
index 5a4639ddd3..b69f06a499 100644
--- a/src/plugins/platforms/eglfs/CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/CMakeLists.txt
@@ -1,5 +1,5 @@
-find_package(EGL)
-find_package(WrapOpenGL)
+qt_find_package(EGL) # special case
+qt_find_package(WrapOpenGL PROVIDED_TARGETS WrapOpenGL) # special case
#####################################################################
## EglFSDeviceIntegration Module:
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/CMakeLists.txt b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/CMakeLists.txt
index 09a9560f80..214b13be2e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from eglfs_kms.pro.
-find_package(gbm)
-find_package(Libdrm)
+qt_find_package(gbm)
+qt_find_package(Libdrm)
#####################################################################
## qeglfs-kms-integration Plugin:
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/CMakeLists.txt b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/CMakeLists.txt
index 9dc5d84523..526c75a882 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from eglfs_kms_egldevice.pro.
-find_package(Libdrm)
+qt_find_package(Libdrm)
#####################################################################
## qeglfs-kms-egldevice-integration Plugin:
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt
index f077ceae4a..96cabe9f1e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from eglfs_kms_support.pro.
-find_package(Libdrm)
+qt_find_package(Libdrm)
#####################################################################
## EglFsKmsSupport Module:
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/CMakeLists.txt b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/CMakeLists.txt
index aaa4da9cb3..f4487a7747 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/CMakeLists.txt
@@ -1,8 +1,8 @@
# Generated from eglfs_x11.pro.
-find_package(XCB)
-find_package(X11)
-find_package(X11_XCB)
+qt_find_package(XCB)
+qt_find_package(X11)
+qt_find_package(X11_XCB)
#####################################################################
## qeglfs-x11-integration Plugin:
diff --git a/src/plugins/platforms/minimal/CMakeLists.txt b/src/plugins/platforms/minimal/CMakeLists.txt
index 0c3e44e2f1..203a9e3920 100644
--- a/src/plugins/platforms/minimal/CMakeLists.txt
+++ b/src/plugins/platforms/minimal/CMakeLists.txt
@@ -1,4 +1,4 @@
-find_package(Freetype) # special case
+qt_find_package(Freetype) # special case
#####################################################################
## qminimal Plugin:
diff --git a/src/plugins/platforms/minimalegl/CMakeLists.txt b/src/plugins/platforms/minimalegl/CMakeLists.txt
index f42925f632..6fc52355c8 100644
--- a/src/plugins/platforms/minimalegl/CMakeLists.txt
+++ b/src/plugins/platforms/minimalegl/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from minimalegl.pro.
-find_package(WrapOpenGL)
+qt_find_package(WrapOpenGL PROVIDED_TARGETS WrapOpenGL) # special case
#####################################################################
## qminimalegl Plugin:
diff --git a/src/plugins/platforms/xcb/CMakeLists.txt b/src/plugins/platforms/xcb/CMakeLists.txt
index 646d9f1976..413599e6c5 100644
--- a/src/plugins/platforms/xcb/CMakeLists.txt
+++ b/src/plugins/platforms/xcb/CMakeLists.txt
@@ -1,13 +1,13 @@
# Generated from xcb_qpa_lib.pro.
# special case:
-find_package(X11_XCB)
-find_package(X11)
-find_package(XCB)
-find_package(XKB)
-find_package(PkgConfig)
-find_package(Freetype)
-find_package(GLIB2)
+qt_find_package(X11_XCB)
+qt_find_package(X11)
+qt_find_package(XCB)
+qt_find_package(XKB)
+qt_find_package(PkgConfig)
+qt_find_package(Freetype)
+qt_find_package(GLIB2)
pkg_check_modules(XKB_COMMON_X11 xkbcommon-x11>=0.4.1 IMPORTED_TARGET) # special case
diff --git a/src/plugins/platformthemes/gtk3/CMakeLists.txt b/src/plugins/platformthemes/gtk3/CMakeLists.txt
index 18bf562970..af11ddb80a 100644
--- a/src/plugins/platformthemes/gtk3/CMakeLists.txt
+++ b/src/plugins/platformthemes/gtk3/CMakeLists.txt
@@ -1,7 +1,7 @@
# Generated from gtk3.pro.
-find_package(GTK3)
-find_package(X11)
+qt_find_package(GTK3)
+qt_find_package(X11)
#####################################################################
## qgtk3 Plugin:
diff --git a/src/plugins/printsupport/cups/CMakeLists.txt b/src/plugins/printsupport/cups/CMakeLists.txt
index d36a5e7be5..7adf3e72ea 100644
--- a/src/plugins/printsupport/cups/CMakeLists.txt
+++ b/src/plugins/printsupport/cups/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from cups.pro.
-find_package(Cups)
+qt_find_package(Cups PROVIDED_TARGETS Cups::Cups) # special case
#####################################################################
## cupsprintersupport Plugin:
diff --git a/src/plugins/sqldrivers/configure.cmake b/src/plugins/sqldrivers/configure.cmake
index 41a66197d1..9f0b0dfc7e 100644
--- a/src/plugins/sqldrivers/configure.cmake
+++ b/src/plugins/sqldrivers/configure.cmake
@@ -6,11 +6,11 @@
#### Libraries
-find_package(PostgreSQL)
+qt_find_package(PostgreSQL PROVIDED_TARGETS PostgreSQL::PostgreSQL)
set_package_properties(PostgreSQL PROPERTIES TYPE OPTIONAL)
-find_package(ODBC)
+qt_find_package(ODBC PROVIDED_TARGETS ODBC::ODBC)
set_package_properties(ODBC PROPERTIES TYPE OPTIONAL)
-find_package(SQLite3)
+qt_find_package(SQLite3)
set_package_properties(SQLite3 PROPERTIES TYPE OPTIONAL)
diff --git a/src/plugins/sqldrivers/odbc/CMakeLists.txt b/src/plugins/sqldrivers/odbc/CMakeLists.txt
index c3c52f526c..4cfbe3b307 100644
--- a/src/plugins/sqldrivers/odbc/CMakeLists.txt
+++ b/src/plugins/sqldrivers/odbc/CMakeLists.txt
@@ -1,4 +1,4 @@
-find_package(ODBC) # special case
+qt_find_package(ODBC) # special case
#####################################################################
## qsqlodbc Plugin:
diff --git a/src/plugins/sqldrivers/psql/CMakeLists.txt b/src/plugins/sqldrivers/psql/CMakeLists.txt
index dfbeaba6de..7b854c365f 100644
--- a/src/plugins/sqldrivers/psql/CMakeLists.txt
+++ b/src/plugins/sqldrivers/psql/CMakeLists.txt
@@ -1,7 +1,7 @@
# FIXME cmake FindPostgreSQL is more exhaustive than the check we have for libpq-fe.h
# it also checks for catalog/pg_type.h which is a more internal include, we should
# add a way to tell cmake FindPostgreSQL to optionally only look for the libpq-fe.h one
-find_package(PostgreSQL) # special case
+qt_find_package(PostgreSQL) # special case
#####################################################################
## qsqlpsql Plugin:
diff --git a/src/printsupport/configure.cmake b/src/printsupport/configure.cmake
index 40aab5d9f7..bede6a503b 100644
--- a/src/printsupport/configure.cmake
+++ b/src/printsupport/configure.cmake
@@ -6,7 +6,7 @@
#### Libraries
-find_package(Cups)
+qt_find_package(Cups PROVIDED_TARGETS Cups::Cups)
set_package_properties(Cups PROPERTIES TYPE OPTIONAL)
diff --git a/src/widgets/configure.cmake b/src/widgets/configure.cmake
index fead6b60b5..a67e12646c 100644
--- a/src/widgets/configure.cmake
+++ b/src/widgets/configure.cmake
@@ -6,7 +6,7 @@
#### Libraries
-find_package(GTK3)
+qt_find_package(GTK3)
set_package_properties(GTK3 PROPERTIES TYPE OPTIONAL)
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py
index fe853bb910..15cd9bab47 100755
--- a/util/cmake/configurejson2cmake.py
+++ b/util/cmake/configurejson2cmake.py
@@ -33,7 +33,7 @@ import re
import sys
from typing import Set, Union, List, Dict
-from helper import map_qt_library, featureName, substitute_platform
+from helper import map_qt_library, featureName, substitute_platform, qmake_library_to_cmake_target_mapping
knownTests = set() # type: Set[str]
@@ -68,7 +68,6 @@ def map_library(lib: str) -> Union[str, LibraryMapping, List[str]]:
'libinput': 'Libinput',
'libjpeg': 'JPEG',
'libpng': 'PNG',
- 'libpng': 'PNG',
'libproxy': 'Libproxy',
'librt': 'WrapRt',
'libudev': 'Libudev',
@@ -260,10 +259,16 @@ def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set):
isRequired = True
extra.remove("REQUIRED")
+ # If we have a mapping from a qmake library to a CMake target name,
+ # encode that in the qt_find_package call().
+ cmake_target_name = qmake_library_to_cmake_target_mapping.get(lib, None)
+ if cmake_target_name:
+ extra += ['PROVIDED_TARGETS', cmake_target_name]
+
if extra:
- cm_fh.write('find_package({} {})\n'.format(newlib, ' '.join(extra)))
+ cm_fh.write('qt_find_package({} {})\n'.format(newlib, ' '.join(extra)))
else:
- cm_fh.write('find_package({})\n'.format(newlib))
+ cm_fh.write('qt_find_package({})\n'.format(newlib))
cm_fh.write('set_package_properties({} PROPERTIES TYPE {})\n'
.format(newlib, 'REQUIRED' if isRequired else 'OPTIONAL')
diff --git a/util/cmake/helper.py b/util/cmake/helper.py
index 13c1677b52..1e13a5a1f3 100644
--- a/util/cmake/helper.py
+++ b/util/cmake/helper.py
@@ -211,7 +211,7 @@ def substitute_platform(platform: str) -> str:
return platform_mapping.get(platform, platform)
-libray_mapping = {
+qmake_library_to_cmake_target_mapping = {
'atspi': 'PkgConfig::ATSPI2',
'cups': 'Cups::Cups',
'drm': 'Libdrm::Libdrm',
@@ -228,7 +228,7 @@ libray_mapping = {
'libdl': '${CMAKE_DL_LIBS}',
'libinput': 'Libinput::Libinput',
'libpng' : 'PNG::PNG',
- 'libproxy': 'LibProxy::LibProxy',
+ 'libproxy': 'PkgConfig::Libproxy',
'librt': 'WrapRt',
'libudev': 'PkgConfig::Libudev',
'mtdev': 'PkgConfig::Mtdev',
@@ -269,4 +269,4 @@ def substitute_libs(lib: str) -> str:
if lib.endswith('/nolink'):
lib = lib[:-7]
libpostfix = '_nolink'
- return libray_mapping.get(lib, lib) + libpostfix
+ return qmake_library_to_cmake_target_mapping.get(lib, lib) + libpostfix