summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/3rdpartyConfig.cmake.in13
-rw-r--r--cmake/QtBaseGlobalTargets.cmake1
-rw-r--r--cmake/QtBuild.cmake95
-rw-r--r--src/3rdparty/harfbuzz/CMakeLists.txt5
-rw-r--r--src/3rdparty/tinycbor/CMakeLists.txt6
-rw-r--r--src/corelib/CMakeLists.txt7
6 files changed, 124 insertions, 3 deletions
diff --git a/cmake/3rdpartyConfig.cmake.in b/cmake/3rdpartyConfig.cmake.in
new file mode 100644
index 0000000000..fe15a1efc6
--- /dev/null
+++ b/cmake/3rdpartyConfig.cmake.in
@@ -0,0 +1,13 @@
+@PACKAGE_INIT@
+
+get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_import_prefix "${_import_prefix}" REALPATH)
+
+set(old_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}")
+set(CMAKE_MODULE_PATH "${_import_prefix}" ${CMAKE_MODULE_PATH} )
+
+@3RDPARTY_ADDITIONAL_SETUP_CODE@
+
+set(CMAKE_MODULE_PATH "${old_CMAKE_MODULE_PATH}")
+
+include("${CMAKE_CURRENT_LIST_DIR}/@target@Targets.cmake")
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index d50d1e2c2b..67d20b775c 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -78,6 +78,7 @@ add_library(Qt::GlobalConfigPrivate ALIAS GlobalConfigPrivate)
install(TARGETS Platform GlobalConfig GlobalConfigPrivate EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets")
install(EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets" NAMESPACE ${INSTALL_CMAKE_EXPORT_NAMESPACE}:: DESTINATION "${config_install_dir}")
+export(EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets")
## Install some QtBase specific CMake files:
install(FILES
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index f5775f2b1f..ddf6389db1 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -712,6 +712,15 @@ function(add_qt_module target)
endif()
endforeach()
+ foreach(lib ${arg_LIBRARIES})
+ if (TARGET "${lib}")
+ get_target_property(_is_exported "${lib}" INTERFACE_QT_EXPORTED_LIBRARY)
+ if("${_is_exported}")
+ list(APPEND target_deps "${lib}\;${PROJECT_VERSION}")
+ endif()
+ endif()
+ endforeach()
+
configure_package_config_file(
"${QT_CMAKE_DIR}/QtModuleConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
@@ -801,7 +810,6 @@ function(qt_internal_check_directory_or_type name dir type default result_var)
endif()
endfunction()
-
# This is the main entry point for defining Qt plugins.
# A CMake target is created with the given target. The TYPE parameter is needed to place the
# plugin into the correct plugins/ sub-directory.
@@ -1222,6 +1230,13 @@ function(add_qt_simd_part target)
$<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>)
target_link_libraries("${target}" PRIVATE "${name}")
+
+ if(NOT BUILD_SHARED_LIBS)
+ install(
+ TARGETS ${name}
+ EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets"
+ )
+ endif()
else()
if(QT_CMAKE_DEBUG_EXTEND_TARGET)
message("add_qt_simd_part(${target} SIMD ${arg_SIMD} ...): Skipped")
@@ -1421,3 +1436,81 @@ macro(qt_find_package)
endforeach()
endif()
endmacro()
+
+# Creates a simple export set for the various Find* dependencies
+# which are needed when creating a static build of Qt.
+# This introduces a custom target property: INTERFACE_QT_EXPORTED_LIBRARY
+# This target property indicates that Qt modules / plugins using this 3rd party library
+# must add it to their list of dependencies when creating their own ${qtmodule}Config.cmake
+function(qt_install_static_target_export target)
+ if(BUILD_SHARED_LIBS)
+ return()
+ endif()
+
+ qt_parse_all_arguments(arg "qt_install_3rdparty_config_files" "" "EXPORT" "" ${ARGN})
+ # TODO mark EXPORT as required
+
+ set(config_install_dir "${INSTALL_LIBDIR}/cmake/${arg_EXPORT}")
+
+ set_target_properties(${target}
+ PROPERTIES
+ INTERFACE_QT_EXPORTED_LIBRARY 1)
+
+ install(
+ TARGETS ${target}
+ EXPORT ${arg_EXPORT}Targets
+ LIBRARY DESTINATION ${INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${INSTALL_LIBDIR})
+
+ install(
+ EXPORT ${arg_EXPORT}Targets
+ DESTINATION "${config_install_dir}"
+ )
+
+ export(EXPORT ${arg_EXPORT}Targets)
+endfunction()
+
+# Create a set of ${target}Config.cmake and ${target}Version.cmake for a
+# third-party library so that it can be found by client code linking statically.
+function(qt_install_3rdparty_config_files target)
+ if(BUILD_SHARED_LIBS)
+ return()
+ endif()
+
+ qt_parse_all_arguments(arg "qt_install_3rdparty_config_files" "" "EXPORT" "PACKAGES;ADDITIONAL_FILES" ${ARGN})
+ # TODO mark EXPORT as required
+
+ set(3RDPARTY_ADDITIONAL_SETUP_CODE)
+ foreach(package ${arg_PACKAGES})
+ list(APPEND 3RDPARTY_ADDITIONAL_SETUP_CODE "find_package(${package})\n")
+ endforeach()
+
+ set(config_install_dir "${INSTALL_LIBDIR}/cmake/${arg_EXPORT}")
+ configure_package_config_file(
+ "${PROJECT_SOURCE_DIR}/cmake/3rdpartyConfig.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/${target}Config.cmake"
+ INSTALL_DESTINATION "${config_install_dir}"
+ )
+
+ write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/${target}ConfigVersion.cmake"
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion
+ )
+
+ install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/${target}Config.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/${target}ConfigVersion.cmake"
+ ${arg_ADDITIONAL_FILES}
+ DESTINATION "${config_install_dir}"
+ COMPONENT Devel
+ )
+endfunction()
+
+# Call this function in 3rdparty find modules that ought to be installed alongside
+# Qt modules and must be found when linking statically.
+function(qt_install_3rdparty_library target)
+ qt_install_static_target_export(${target} EXPORT ${target})
+ qt_install_3rdparty_config_files(${target} EXPORT ${target} ${ARGN})
+endfunction()
+
diff --git a/src/3rdparty/harfbuzz/CMakeLists.txt b/src/3rdparty/harfbuzz/CMakeLists.txt
index 25a3b75d2f..3eaddbb2db 100644
--- a/src/3rdparty/harfbuzz/CMakeLists.txt
+++ b/src/3rdparty/harfbuzz/CMakeLists.txt
@@ -8,4 +8,7 @@ add_library(QtHarfBuzz STATIC
src/harfbuzz-open.c
src/harfbuzz-stream.c
)
-target_include_directories(QtHarfBuzz PUBLIC src)
+target_include_directories(QtHarfBuzz PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>)
+
+qt_install_3rdparty_library(QtHarfBuzz)
diff --git a/src/3rdparty/tinycbor/CMakeLists.txt b/src/3rdparty/tinycbor/CMakeLists.txt
index 3a1a760af9..d0c90165bf 100644
--- a/src/3rdparty/tinycbor/CMakeLists.txt
+++ b/src/3rdparty/tinycbor/CMakeLists.txt
@@ -1,2 +1,6 @@
add_library(tinycbor INTERFACE)
-target_include_directories(tinycbor INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
+target_include_directories(tinycbor
+ INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>)
+
+qt_install_3rdparty_library(tinycbor)
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 5aee60e7e1..ba75c4cdb4 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -268,6 +268,13 @@ target_include_directories(Core_qobject PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/ker
target_link_libraries(Core_qobject PRIVATE Qt::Platform Qt::GlobalConfig)
target_link_libraries(Core PRIVATE Core_qobject)
+if(NOT BUILD_SHARED_LIBS)
+ install(
+ TARGETS Core_qobject
+ EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets"
+ )
+endif()
+
set_property(TARGET Core APPEND PROPERTY
PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig.h")
set_property(TARGET Core APPEND PROPERTY