diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindPostgreSQL.cmake | 317 | ||||
-rw-r--r-- | cmake/FindWrapOpenSSL.cmake | 12 | ||||
-rw-r--r-- | cmake/QtAndroidHelpers.cmake | 124 | ||||
-rw-r--r-- | cmake/QtAutoDetect.cmake | 8 | ||||
-rw-r--r-- | cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 19 | ||||
-rw-r--r-- | cmake/QtCMakeVersionHelpers.cmake | 11 | ||||
-rw-r--r-- | cmake/QtHeadersClean.cmake | 4 | ||||
-rw-r--r-- | cmake/QtModuleHelpers.cmake | 2 | ||||
-rw-r--r-- | cmake/QtPlatformAndroid.cmake | 2 | ||||
-rw-r--r-- | cmake/QtPluginHelpers.cmake | 29 | ||||
-rw-r--r-- | cmake/QtPlugins.cmake.in | 27 | ||||
-rw-r--r-- | cmake/QtPostProcessHelpers.cmake | 11 | ||||
-rw-r--r-- | cmake/QtPrlHelpers.cmake | 2 | ||||
-rw-r--r-- | cmake/QtProcessConfigureArgs.cmake | 15 | ||||
-rw-r--r-- | cmake/QtTestHelpers.cmake | 12 | ||||
-rw-r--r-- | cmake/QtWrapperScriptHelpers.cmake | 2 | ||||
-rw-r--r-- | cmake/README.md | 36 |
17 files changed, 518 insertions, 115 deletions
diff --git a/cmake/FindPostgreSQL.cmake b/cmake/FindPostgreSQL.cmake new file mode 100644 index 0000000000..6e27f5d8f5 --- /dev/null +++ b/cmake/FindPostgreSQL.cmake @@ -0,0 +1,317 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindPostgreSQL +-------------- + +Find the PostgreSQL installation. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.14 + +This module defines :prop_tgt:`IMPORTED` target ``PostgreSQL::PostgreSQL`` +if PostgreSQL has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``PostgreSQL_FOUND`` + True if PostgreSQL is found. +``PostgreSQL_LIBRARIES`` + the PostgreSQL libraries needed for linking +``PostgreSQL_INCLUDE_DIRS`` + the directories of the PostgreSQL headers +``PostgreSQL_LIBRARY_DIRS`` + the link directories for PostgreSQL libraries +``PostgreSQL_VERSION_STRING`` + the version of PostgreSQL found +``PostgreSQL_TYPE_INCLUDE_DIR`` + the directories of the PostgreSQL server headers + +Components +^^^^^^^^^^ + +This module contains additional ``Server`` component, that forcibly checks +for the presence of server headers. Note that ``PostgreSQL_TYPE_INCLUDE_DIR`` +is set regardless of the presence of the ``Server`` component in find_package call. + +#]=======================================================================] + +# ---------------------------------------------------------------------------- +# History: +# This module is derived from the module originally found in the VTK source tree. +# +# ---------------------------------------------------------------------------- +# Note: +# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the +# version number of the implementation of PostgreSQL. +# In Windows the default installation of PostgreSQL uses that as part of the path. +# E.g C:\Program Files\PostgreSQL\8.4. +# Currently, the following version numbers are known to this module: +# "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" +# +# To use this variable just do something like this: +# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") +# before calling find_package(PostgreSQL) in your CMakeLists.txt file. +# This will mean that the versions you set here will be found first in the order +# specified before the default ones are searched. +# +# ---------------------------------------------------------------------------- +# You may need to manually set: +# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are. +# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are. +# If FindPostgreSQL.cmake cannot find the include files or the library files. +# +# ---------------------------------------------------------------------------- +# The following variables are set if PostgreSQL is found: +# PostgreSQL_FOUND - Set to true when PostgreSQL is found. +# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL +# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries +# PostgreSQL_LIBRARIES - The PostgreSQL libraries. +# +# The ``PostgreSQL::PostgreSQL`` imported target is also created. +# +# ---------------------------------------------------------------------------- +# If you have installed PostgreSQL in a non-standard location. +# (Please note that in the following comments, it is assumed that <Your Path> +# points to the root directory of the include directory of PostgreSQL.) +# Then you have three options. +# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and +# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is +# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path() +# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file +# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include") +# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have +# installed PostgreSQL, e.g. <Your Path>. +# +# ---------------------------------------------------------------------------- + +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20") + include("${CMAKE_ROOT}/Modules/FindPostgreSQL.cmake") + return() +endif() + +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + +set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include") +set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}") +set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.") +set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}") +set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4") + + +set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} + "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") + +# Define additional search paths for root directories. +set( PostgreSQL_ROOT_DIRECTORIES + ENV PostgreSQL_ROOT + ${PostgreSQL_ROOT} +) +foreach(suffix ${PostgreSQL_KNOWN_VERSIONS}) + if(WIN32) + list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES + "PostgreSQL/${suffix}/lib") + list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES + "PostgreSQL/${suffix}/include") + list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES + "PostgreSQL/${suffix}/include/server") + endif() + if(UNIX) + list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES + "postgresql${suffix}" + "pgsql-${suffix}/lib") + list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES + "postgresql${suffix}" + "postgresql/${suffix}" + "pgsql-${suffix}/include") + list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES + "postgresql${suffix}/server" + "postgresql/${suffix}/server" + "pgsql-${suffix}/include/server") + endif() +endforeach() + +# +# Look for an installation. +# +find_path(PostgreSQL_INCLUDE_DIR + NAMES libpq-fe.h + PATHS + # Look in other places. + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + pgsql + postgresql + include + ${PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES} + # Help the user find it if we cannot. + DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" +) + +find_path(PostgreSQL_TYPE_INCLUDE_DIR + NAMES catalog/pg_type.h + PATHS + # Look in other places. + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + postgresql + pgsql/server + postgresql/server + include/server + ${PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES} + # Help the user find it if we cannot. + DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" +) + +# The PostgreSQL library. +set (PostgreSQL_LIBRARY_TO_FIND pq) +# Setting some more prefixes for the library +set (PostgreSQL_LIB_PREFIX "") +if ( WIN32 ) + set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib") + set (PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND}) +endif() + +function(__postgresql_find_library _name) + find_library(${_name} + NAMES ${ARGN} + PATHS + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + lib + ${PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES} + # Help the user find it if we cannot. + DOC "The ${PostgreSQL_LIBRARY_DIR_MESSAGE}" + ) +endfunction() + +# For compatibility with versions prior to this multi-config search, honor +# any PostgreSQL_LIBRARY that is already specified and skip the search. +if(PostgreSQL_LIBRARY) + set(PostgreSQL_LIBRARIES "${PostgreSQL_LIBRARY}") + get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY}" PATH) +else() + __postgresql_find_library(PostgreSQL_LIBRARY_RELEASE ${PostgreSQL_LIBRARY_TO_FIND}) + __postgresql_find_library(PostgreSQL_LIBRARY_DEBUG ${PostgreSQL_LIBRARY_TO_FIND}d) + include(SelectLibraryConfigurations) + select_library_configurations(PostgreSQL) + mark_as_advanced(PostgreSQL_LIBRARY_RELEASE PostgreSQL_LIBRARY_DEBUG) + if(PostgreSQL_LIBRARY_RELEASE) + get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_RELEASE}" PATH) + elseif(PostgreSQL_LIBRARY_DEBUG) + get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_DEBUG}" PATH) + else() + set(PostgreSQL_LIBRARY_DIR "") + endif() +endif() + +if (PostgreSQL_INCLUDE_DIR) + # Some platforms include multiple pg_config.hs for multi-lib configurations + # This is a temporary workaround. A better solution would be to compile + # a dummy c file and extract the value of the symbol. + file(GLOB _PG_CONFIG_HEADERS "${PostgreSQL_INCLUDE_DIR}/pg_config*.h") + foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS}) + if(EXISTS "${_PG_CONFIG_HEADER}") + file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str + REGEX "^#define[\t ]+PG_VERSION_NUM[\t ]+.*") + if(pgsql_version_str) + string(REGEX REPLACE "^#define[\t ]+PG_VERSION_NUM[\t ]+([0-9]*).*" + "\\1" _PostgreSQL_VERSION_NUM "${pgsql_version_str}") + break() + endif() + endif() + endforeach() + if (_PostgreSQL_VERSION_NUM) + # 9.x and older encoding + if (_PostgreSQL_VERSION_NUM LESS 100000) + math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000") + math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000 / 100") + math(EXPR _PostgreSQL_patch_version "${_PostgreSQL_VERSION_NUM} % 100") + set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}.${_PostgreSQL_patch_version}") + unset(_PostgreSQL_major_version) + unset(_PostgreSQL_minor_version) + unset(_PostgreSQL_patch_version) + else () + math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000") + math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000") + set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}") + unset(_PostgreSQL_major_version) + unset(_PostgreSQL_minor_version) + endif () + else () + foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS}) + if(EXISTS "${_PG_CONFIG_HEADER}") + file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str + REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"") + if(pgsql_version_str) + string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*" + "\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}") + break() + endif() + endif() + endforeach() + endif () + unset(_PostgreSQL_VERSION_NUM) + unset(pgsql_version_str) +endif() + +if("Server" IN_LIST PostgreSQL_FIND_COMPONENTS) + set(PostgreSQL_Server_FOUND TRUE) + if(NOT PostgreSQL_TYPE_INCLUDE_DIR) + set(PostgreSQL_Server_FOUND FALSE) + endif() +endif() + +# Did we find anything? +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PostgreSQL + REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR + HANDLE_COMPONENTS + VERSION_VAR PostgreSQL_VERSION_STRING) +set(PostgreSQL_FOUND ${POSTGRESQL_FOUND}) + +function(__postgresql_import_library _target _var _config) + if(_config) + set(_config_suffix "_${_config}") + else() + set(_config_suffix "") + endif() + + set(_lib "${${_var}${_config_suffix}}") + if(EXISTS "${_lib}") + if(_config) + set_property(TARGET ${_target} APPEND PROPERTY + IMPORTED_CONFIGURATIONS ${_config}) + endif() + set_target_properties(${_target} PROPERTIES + IMPORTED_LOCATION${_config_suffix} "${_lib}") + endif() +endfunction() + +# Now try to get the include and library path. +if(PostgreSQL_FOUND) + set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR}) + if(PostgreSQL_TYPE_INCLUDE_DIR) + list(APPEND PostgreSQL_INCLUDE_DIRS ${PostgreSQL_TYPE_INCLUDE_DIR}) + endif() + set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR}) + if (NOT TARGET PostgreSQL::PostgreSQL) + add_library(PostgreSQL::PostgreSQL UNKNOWN IMPORTED) + set_target_properties(PostgreSQL::PostgreSQL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${PostgreSQL_INCLUDE_DIRS}") + __postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "") + __postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "RELEASE") + __postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "DEBUG") + endif () +endif() + +mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR) + +cmake_policy(POP) diff --git a/cmake/FindWrapOpenSSL.cmake b/cmake/FindWrapOpenSSL.cmake index 6e80862258..a09aa99518 100644 --- a/cmake/FindWrapOpenSSL.cmake +++ b/cmake/FindWrapOpenSSL.cmake @@ -11,6 +11,18 @@ set(WrapOpenSSL_FOUND OFF) find_package(WrapOpenSSLHeaders ${WrapOpenSSL_FIND_VERSION}) if(OpenSSL_FOUND) + if(WIN32) + get_target_property(libType OpenSSL::Crypto TYPE) + if(libType STREQUAL "ALIAS") + get_target_property(writableLib OpenSSL::Crypto ALIASED_TARGET) + else() + set(writableLib OpenSSL::Crypto) + endif() + set_property(TARGET ${writableLib} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Ws2_32 Crypt32) + unset(libType) + unset(writableLib) + endif() + set(WrapOpenSSL_FOUND ON) add_library(WrapOpenSSL::WrapOpenSSL INTERFACE IMPORTED) diff --git a/cmake/QtAndroidHelpers.cmake b/cmake/QtAndroidHelpers.cmake index 7e84c983a9..24233ac622 100644 --- a/cmake/QtAndroidHelpers.cmake +++ b/cmake/QtAndroidHelpers.cmake @@ -8,7 +8,7 @@ define_property(TARGET BRIEF_DOCS "Recorded install location for a Qt Module." FULL_DOCS - "Recorded install location for a Qt Module. Used by qt_android_dependencies()." + "Recorded install location for a Qt Module. Used by qt_internal_android_dependencies()." ) @@ -65,42 +65,36 @@ define_property(TARGET FULL_DOCS "Qt Module android permission list." ) -# Generate Qt Module -android-dependencies.xml required by the -# androiddeploytoolqt to successfully copy all the plugins and other dependent -# items into tha APK -function(qt_android_dependencies target) - get_target_property(target_type "${target}" TYPE) - if(target_type STREQUAL "INTERFACE_LIBRARY") - return() - endif() +define_property(TARGET + PROPERTY + QT_ANDROID_FEATURES + BRIEF_DOCS + "Qt Module android feature list." + FULL_DOCS + "Qt Module android feature list." +) + +function(qt_internal_android_dependencies_content target file_content_out) get_target_property(arg_JAR_DEPENDENCIES ${target} QT_ANDROID_JAR_DEPENDENCIES) get_target_property(arg_BUNDLED_JAR_DEPENDENCIES ${target} QT_ANDROID_BUNDLED_JAR_DEPENDENCIES) get_target_property(arg_LIB_DEPENDENCIES ${target} QT_ANDROID_LIB_DEPENDENCIES) get_target_property(arg_LIB_DEPENDENCY_REPLACEMENTS ${target} QT_ANDROID_LIB_DEPENDENCY_REPLACEMENTS) get_target_property(arg_BUNDLED_FILES ${target} QT_ANDROID_BUNDLED_FILES) get_target_property(arg_PERMISSIONS ${target} QT_ANDROID_PERMISSIONS) - get_target_property(module_plugins ${target} MODULE_PLUGIN_TYPES) + get_target_property(arg_FEATURES ${target} QT_ANDROID_FEATURES) - if ((NOT module_plugins) - AND (NOT arg_JAR_DEPENDENCIES) - AND (NOT arg_LIB_DEPENDENCY_REPLACEMENTS) - AND (NOT arg_LIB_DEPENDENCIES) + if ((NOT arg_JAR_DEPENDENCIES) AND (NOT arg_BUNDLED_JAR_DEPENDENCIES) + AND (NOT arg_LIB_DEPENDENCIES) + AND (NOT arg_LIB_DEPENDENCY_REPLACEMENTS) + AND (NOT arg_BUNDLED_FILES) AND (NOT arg_PERMISSIONS) - AND (NOT arg_BUNDLED_FILES)) + AND (NOT arg_FEATURES)) # None of the values were set, so there's nothing to do return() endif() - - get_target_property(target_output_name ${target} OUTPUT_NAME) - if (NOT target_output_name) - set(target_name ${target}) - else() - set(target_name ${target_output_name}) - endif() - # mimic qmake's section and string splitting from # mkspecs/feature/qt_android_deps.prf macro(section string delimiter first second) @@ -115,10 +109,7 @@ function(qt_android_dependencies target) endif() endmacro() - set(dependency_file "${QT_BUILD_DIR}/${INSTALL_LIBDIR}/${target_name}_${CMAKE_ANDROID_ARCH_ABI}-android-dependencies.xml") - - set(file_contents "<rules><dependencies>\n") - string(APPEND file_contents "<lib name=\"${target_name}_${CMAKE_ANDROID_ARCH_ABI}\"><depends>\n") + set(file_contents "") # Jar Dependencies if(arg_JAR_DEPENDENCIES) @@ -135,11 +126,11 @@ function(qt_android_dependencies target) # Bundled Jar Dependencies if(arg_BUNDLED_JAR_DEPENDENCIES) foreach(jar_bundle IN LISTS arg_BUNDLED_JAR_DEPENDENCIES) - section(${jar_bundle} ":" bundle_file init_calss) + section(${jar_bundle} ":" bundle_file init_class) if (init_class) set(init_class "initClass=\"${init_class}\"") endif() - file(TO_NATIVE_PATH ${jar_bundle} jar_bundle_native) + file(TO_NATIVE_PATH ${bundle_file} jar_bundle_native) string(APPEND file_contents "<jar bundling=\"1\" file=\"${jar_bundle_native}\" ${init_class} />\n") endforeach() endif() @@ -171,7 +162,6 @@ function(qt_android_dependencies target) endforeach() endif() - # Bundled files if(arg_BUNDLED_FILES) foreach(bundled_file IN LISTS arg_BUNDLED_FILES) @@ -180,13 +170,6 @@ function(qt_android_dependencies target) endforeach() endif() - # Module plugins - if(module_plugins) - foreach(plugin IN LISTS module_plugins) - string(APPEND file_contents "<bundled file=\"plugins/${plugin}\" />\n") - endforeach() - endif() - # Android Permissions if(arg_PERMISSIONS) foreach(permission IN LISTS arg_PERMISSIONS) @@ -194,13 +177,74 @@ function(qt_android_dependencies target) endforeach() endif() - string(APPEND file_contents "</depends></lib>") - string(APPEND file_contents "</dependencies></rules>\n") + # Android Features + if(arg_FEATURES) + foreach(feature IN LISTS arg_FEATURES) + string(APPEND file_contents "<feature name=\"${feature}\" />\n") + endforeach() + endif() + + set(${file_content_out} ${file_contents} PARENT_SCOPE) +endfunction() + +# Generate Qt Module -android-dependencies.xml required by the +# androiddeploytoolqt to successfully copy all the plugins and other dependent +# items into the APK +function(qt_internal_android_dependencies target) + get_target_property(target_type "${target}" TYPE) + if(target_type STREQUAL "INTERFACE_LIBRARY") + return() + endif() + + # Get plugins for the current module + get_target_property(module_plugin_types ${target} MODULE_PLUGIN_TYPES) + + # Get depends for the current module + qt_internal_android_dependencies_content(${target} file_contents) + + # Get plugins from the module's plugin types and get their dependencies + foreach(plugin ${QT_KNOWN_PLUGINS}) + get_target_property(iter_known_plugin_type ${plugin} QT_PLUGIN_TYPE) + foreach(plugin_type ${module_plugin_types}) + if (plugin_type STREQUAL iter_known_plugin_type) + qt_internal_android_dependencies_content(${plugin} plugin_file_contents) + string(APPEND file_contents ${plugin_file_contents}) + endif() + endforeach() + endforeach() + + if ((NOT module_plugin_types) + AND (NOT file_contents)) + # None of the values were set, so there's nothing to do + return() + endif() + + get_target_property(target_output_name ${target} OUTPUT_NAME) + if (NOT target_output_name) + set(target_name ${target}) + else() + set(target_name ${target_output_name}) + endif() + + string(PREPEND file_contents "<lib name=\"${target_name}_${CMAKE_ANDROID_ARCH_ABI}\"><depends>\n") + string(PREPEND file_contents "<rules><dependencies>\n") + + # Module plugins + if(module_plugin_types) + foreach(plugin IN LISTS module_plugin_types) + string(APPEND file_contents "<bundled file=\"plugins/${plugin}\" />\n") + endforeach() + endif() + + string(APPEND file_contents "</depends></lib>\n") + string(APPEND file_contents "</dependencies></rules>") + + qt_path_join(dependency_file "${QT_BUILD_DIR}" "${INSTALL_LIBDIR}" "${target_name}_${CMAKE_ANDROID_ARCH_ABI}-android-dependencies.xml") file(WRITE ${dependency_file} ${file_contents}) get_target_property(target_install_dir ${target} QT_ANDROID_MODULE_INSTALL_DIR) if (NOT target_install_dir) - message(SEND_ERROR "qt_android_dependencies: Target ${target} is either not a Qt Module or has no recorded install location") + message(SEND_ERROR "qt_internal_android_dependencies: Target ${target} is either not a Qt Module or has no recorded install location") return() endif() diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake index 4518078d8d..7a1845d74c 100644 --- a/cmake/QtAutoDetect.cmake +++ b/cmake/QtAutoDetect.cmake @@ -39,7 +39,7 @@ function(qt_auto_detect_android) if(DEFINED CMAKE_TOOLCHAIN_FILE AND NOT DEFINED QT_AUTODETECT_ANDROID) file(READ ${CMAKE_TOOLCHAIN_FILE} toolchain_file_content OFFSET 0 LIMIT 80) - string(FIND ${toolchain_file_content} "The Android Open Source Project" find_result REVERSE) + string(FIND "${toolchain_file_content}" "The Android Open Source Project" find_result REVERSE) if (NOT ${find_result} EQUAL -1) set(android_detected TRUE) else() @@ -268,11 +268,11 @@ function(qt_auto_detect_darwin) # macOS set(version "10.14") elseif(CMAKE_SYSTEM_NAME STREQUAL iOS) - set(version "12.0") + set(version "13.0") elseif(CMAKE_SYSTEM_NAME STREQUAL watchOS) - set(version "5.0") + set(version "6.0") elseif(CMAKE_SYSTEM_NAME STREQUAL tvOS) - set(version "12.0") + set(version "13.0") endif() if(version) set(CMAKE_OSX_DEPLOYMENT_TARGET "${version}" CACHE STRING "${description}") diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index 477f5d21e9..38dc92fff3 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -187,18 +187,19 @@ endmacro() # find all targets defined in $subdir by recursing through all added subdirectories # populates $qt_repo_targets with a ;-list of non-UTILITY targets macro(qt_build_internals_get_repo_targets subdir) + get_directory_property(_targets DIRECTORY "${subdir}" BUILDSYSTEM_TARGETS) + if(_targets) + foreach(_target IN LISTS _targets) + get_target_property(_type ${_target} TYPE) + if(NOT (${_type} STREQUAL "UTILITY" OR ${_type} STREQUAL "INTERFACE")) + list(APPEND qt_repo_targets "${_target}") + endif() + endforeach() + endif() + get_directory_property(_directories DIRECTORY "${subdir}" SUBDIRECTORIES) if (_directories) foreach(_directory IN LISTS _directories) - get_directory_property(_targets DIRECTORY "${_directory}" BUILDSYSTEM_TARGETS) - if (_targets) - foreach(_target IN LISTS _targets) - get_target_property(_type ${_target} TYPE) - if (NOT (${_type} STREQUAL "UTILITY" OR ${_type} STREQUAL "INTERFACE")) - list(APPEND qt_repo_targets "${_target}") - endif() - endforeach() - endif() qt_build_internals_get_repo_targets("${_directory}") endforeach() endif() diff --git a/cmake/QtCMakeVersionHelpers.cmake b/cmake/QtCMakeVersionHelpers.cmake index 955d9044cb..4d4113bb43 100644 --- a/cmake/QtCMakeVersionHelpers.cmake +++ b/cmake/QtCMakeVersionHelpers.cmake @@ -116,6 +116,17 @@ function(qt_internal_warn_about_unsuitable_cmake_versions) # https://gitlab.kitware.com/cmake/cmake/-/issues/21163 list(APPEND unsuitable_versions "3.18.2") + # Cyclic dependencies are created when mixing AUTOMOC/AUTOUIC with sources + # that have their SKIP_MOC or SKIP_UIC source file properties set to true. + # https://gitlab.kitware.com/cmake/cmake/-/issues/21977 + list(APPEND unsuitable_versions "3.20.0") + + # AUTOMOC can crash or hang when using a Qt that supports moc depfiles. + # Issues reported on Windows with Ninja and Makefiles, but it could be happening + # on other platforms too. + # https://gitlab.kitware.com/cmake/cmake/-/issues/22014 + list(APPEND unsuitable_versions "3.20.1") + foreach(unsuitable_version ${unsuitable_versions}) if(CMAKE_VERSION VERSION_EQUAL unsuitable_version) message(WARNING diff --git a/cmake/QtHeadersClean.cmake b/cmake/QtHeadersClean.cmake index 9cb11dddd1..8abb34ff9e 100644 --- a/cmake/QtHeadersClean.cmake +++ b/cmake/QtHeadersClean.cmake @@ -162,13 +162,15 @@ function(qt_internal_add_headers_clean_target foreach(header ${hclean_headers}) get_filename_component(input_path "${header}" ABSOLUTE) - set(artifact_path "header_${header}.o") + set(artifact_path "header_check/${header}.o") + get_filename_component(artifact_directory "${artifact_path}" DIRECTORY) set(comment_header_path "${CMAKE_CURRENT_SOURCE_DIR}/${header}") file(RELATIVE_PATH comment_header_path "${PROJECT_SOURCE_DIR}" "${comment_header_path}") add_custom_command( OUTPUT "${artifact_path}" COMMENT "headersclean: Checking header ${comment_header_path}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${artifact_directory}" COMMAND ${compiler_to_run} -c ${cxx_flags} "${target_compile_flags_joined_genex}" diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake index 26b27bbe63..7cbad31f11 100644 --- a/cmake/QtModuleHelpers.cmake +++ b/cmake/QtModuleHelpers.cmake @@ -562,7 +562,7 @@ set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})") if (ANDROID AND NOT arg_HEADER_MODULE) # Record install library location so it can be accessed by - # qt_android_dependencies without having to specify it again. + # qt_internal_android_dependencies without having to specify it again. set_target_properties(${target} PROPERTIES QT_ANDROID_MODULE_INSTALL_DIR ${INSTALL_LIBDIR}) endif() diff --git a/cmake/QtPlatformAndroid.cmake b/cmake/QtPlatformAndroid.cmake index 1bca423d9e..0cd2b127c8 100644 --- a/cmake/QtPlatformAndroid.cmake +++ b/cmake/QtPlatformAndroid.cmake @@ -33,7 +33,7 @@ function(qt_get_android_sdk_jar_for_api api out_jar_location) endfunction() # Minimum recommend android SDK api version -set(QT_ANDROID_API_VERSION "android-28") +set(QT_ANDROID_API_VERSION "android-29") # Locate android.jar set(QT_ANDROID_JAR "${ANDROID_SDK_ROOT}/platforms/${QT_ANDROID_API_VERSION}/android.jar") diff --git a/cmake/QtPluginHelpers.cmake b/cmake/QtPluginHelpers.cmake index 497ccc0e89..69de616335 100644 --- a/cmake/QtPluginHelpers.cmake +++ b/cmake/QtPluginHelpers.cmake @@ -150,11 +150,15 @@ function(qt_internal_add_plugin target) endif() endif() - add_dependencies(qt_plugins "${target}") + if(TARGET qt_plugins) + add_dependencies(qt_plugins "${target}") + endif() if(arg_TYPE STREQUAL "platforms") - add_dependencies(qpa_plugins "${target}") + if(TARGET qpa_plugins) + add_dependencies(qpa_plugins "${target}") + endif() - if(_default_plugin) + if(_default_plugin AND TARGET qpa_default_plugins) add_dependencies(qpa_default_plugins "${target}") endif() endif() @@ -288,20 +292,29 @@ function(qt_internal_add_plugin target) endif() qt_internal_add_linker_version_script(${target}) - qt_add_list_file_finalizer(qt_finalize_plugin ${target} "${install_directory}") + set(finalizer_extra_args "") + if(NOT arg_SKIP_INSTALL) + list(APPEND finalizer_extra_args INSTALL_PATH "${install_directory}") + endif() + qt_add_list_file_finalizer(qt_finalize_plugin ${target} ${finalizer_extra_args}) - qt_enable_separate_debug_info(${target} "${install_directory}") - qt_internal_install_pdb_files(${target} "${install_directory}") + if(NOT arg_SKIP_INSTALL) + qt_enable_separate_debug_info(${target} "${install_directory}") + qt_internal_install_pdb_files(${target} "${install_directory}") + endif() endfunction() -function(qt_finalize_plugin target install_directory) +function(qt_finalize_plugin target) + cmake_parse_arguments(arg "" "INSTALL_PATH" "" ${ARGN}) if(WIN32 AND BUILD_SHARED_LIBS) _qt_internal_generate_win32_rc_file("${target}") endif() # Generate .prl files for plugins of static Qt builds. if(NOT BUILD_SHARED_LIBS) - qt_generate_prl_file(${target} "${install_directory}") + if(arg_INSTALL_PATH) + qt_generate_prl_file(${target} "${arg_INSTALL_PATH}") + endif() endif() endfunction() diff --git a/cmake/QtPlugins.cmake.in b/cmake/QtPlugins.cmake.in index d6d5c829b2..0014a7358c 100644 --- a/cmake/QtPlugins.cmake.in +++ b/cmake/QtPlugins.cmake.in @@ -13,9 +13,6 @@ if(NOT @BUILD_SHARED_LIBS@) unset(_aliased_target) set(_default_plugins_are_enabled "$<NOT:$<STREQUAL:$<GENEX_EVAL:$<TARGET_PROPERTY:QT_DEFAULT_PLUGINS>>,0>>") - # Make sure to boolify the result of the expression, in case if the returned property value - # is empty. - set(_default_plugins_are_enabled_wrapped "$<BOOL:${_default_plugins_are_enabled}>") set(_manual_plugins_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_PLUGINS>>") set(_no_plugins_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_NO_PLUGINS>>") @@ -105,7 +102,7 @@ if(NOT @BUILD_SHARED_LIBS@) "${_plugin_is_in_type_whitelist}," "${_plugin_versionless_is_in_type_whitelist}," "$<AND:" - "${_default_plugins_are_enabled_wrapped}," + "${_default_plugins_are_enabled}," "${_plugin_is_default}," "${_plugin_is_not_blacklisted}" ">" @@ -119,15 +116,23 @@ if(NOT @BUILD_SHARED_LIBS@) set(_generated_qt_plugin_file_name "${CMAKE_CURRENT_BINARY_DIR}/qt_@QT_MODULE@_${target}.cpp") - set(_generated_qt_plugin_file_name_template "${_generated_qt_plugin_file_name}.in") set(_generated_qt_plugin_file_content "#include <QtPlugin>\nQ_IMPORT_PLUGIN(${_classname})") - # Generate a source file to import that plug-in. Has to be done with configure_file, - # because file(GENERATE) and target_sources has issues with scopes. - file(WRITE "${_generated_qt_plugin_file_name_template}" - "${_generated_qt_plugin_file_content}") - configure_file("${_generated_qt_plugin_file_name_template}" - "${_generated_qt_plugin_file_name}") + # Generate a source file to import that plug-in. Be careful not to + # update the timestamp of the generated file if we are not going to + # change anything. Otherwise we will trigger CMake's autogen to re-run + # and executables will then need to at least relink. + set(need_write TRUE) + if(EXISTS ${_generated_qt_plugin_file_name}) + file(READ ${_generated_qt_plugin_file_name} old_contents) + if(old_contents STREQUAL "${_generated_qt_plugin_file_content}") + set(need_write FALSE) + endif() + endif() + if(need_write) + file(WRITE "${_generated_qt_plugin_file_name}" + "${_generated_qt_plugin_file_content}") + endif() target_sources(${_module_target} INTERFACE "$<${_plugin_condition}:${_generated_qt_plugin_file_name}>") diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake index 37213f13a5..1a0dc02213 100644 --- a/cmake/QtPostProcessHelpers.cmake +++ b/cmake/QtPostProcessHelpers.cmake @@ -639,7 +639,7 @@ endfunction() function(qt_modules_process_android_dependencies) qt_internal_get_qt_repo_known_modules(repo_known_modules) foreach (target ${repo_known_modules}) - qt_android_dependencies(${target}) + qt_internal_android_dependencies(${target}) endforeach() endfunction() @@ -704,10 +704,15 @@ function(qt_internal_create_config_file_for_standalone_tests) endfunction() function(qt_internal_install_prl_files) - # Install prl files + # Get locations relative to QT_BUILD_DIR from which prl files should be installed. get_property(prl_install_dirs GLOBAL PROPERTY QT_PRL_INSTALL_DIRS) + + # Clear the list of install dirs so the previous values don't pollute the list of install dirs + # for the next repository in a top-level build. + set_property(GLOBAL PROPERTY QT_PRL_INSTALL_DIRS "") + foreach(prl_install_dir ${prl_install_dirs}) - qt_install(DIRECTORY "${PROJECT_BINARY_DIR}/${prl_install_dir}/" + qt_install(DIRECTORY "${QT_BUILD_DIR}/${prl_install_dir}/" DESTINATION ${prl_install_dir} FILES_MATCHING PATTERN "*.prl" ) diff --git a/cmake/QtPrlHelpers.cmake b/cmake/QtPrlHelpers.cmake index 566d311e74..0c0b7a2aec 100644 --- a/cmake/QtPrlHelpers.cmake +++ b/cmake/QtPrlHelpers.cmake @@ -188,7 +188,7 @@ function(qt_internal_walk_libs qt_merge_libs(rcc_objects ${lib_rcc_objects_${target}}) endif() else() - qt_merge_libs(libs "$<TARGET_FILE:${lib_target}>") + qt_merge_libs(libs "$<TARGET_LINKER_FILE:${lib_target}>") get_target_property(target_rcc_objects "${lib_target}" _qt_rcc_objects) if(target_rcc_objects) diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 228d2060da..431e6f3dcb 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -638,12 +638,13 @@ translate_string_input(qt_libinfix QT_LIBINFIX) translate_string_input(qreal QT_COORD_TYPE) translate_path_input(prefix CMAKE_INSTALL_PREFIX) translate_path_input(extprefix CMAKE_STAGING_PREFIX) -foreach(kind bin lib archdata libexec qml data doc translation sysconf examples tests) +foreach(kind bin lib archdata libexec qml data doc sysconf examples tests) string(TOUPPER ${kind} uc_kind) translate_path_input(${kind}dir INSTALL_${uc_kind}DIR) endforeach() translate_path_input(headerdir INSTALL_INCLUDEDIR) translate_path_input(plugindir INSTALL_PLUGINSDIR) +translate_path_input(translationdir INSTALL_TRANSLATIONSDIR) if(NOT "${INPUT_device}" STREQUAL "") push("-DQT_QMAKE_TARGET_MKSPEC=devices/${INPUT_device}") @@ -726,11 +727,6 @@ if("${INPUT_ltcg}" STREQUAL "yes") endforeach() endif() -if(NOT "${INPUT_opengl}" STREQUAL "") - drop_input(opengl) - push("-DINPUT_opengl=${INPUT_opengl}") -endif() - translate_list_input(device-option QT_QMAKE_DEVICE_OPTIONS) translate_list_input(defines QT_EXTRA_DEFINES) translate_list_input(fpaths QT_EXTRA_FRAMEWORKPATHS) @@ -738,13 +734,6 @@ translate_list_input(includes QT_EXTRA_INCLUDEPATHS) translate_list_input(lpaths QT_EXTRA_LIBDIRS) translate_list_input(rpaths QT_EXTRA_RPATHS) -foreach(feature ${commandline_known_features}) - qt_feature_normalize_name("${feature}" cmake_feature) - if(${feature} IN_LIST config_inputs) - translate_boolean_input(${feature} INPUT_${cmake_feature}) - endif() -endforeach() - foreach(input ${config_inputs}) qt_feature_normalize_name("${input}" cmake_input) push("-DINPUT_${cmake_input}=${INPUT_${input}}") diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake index 5222f8a08d..0f93dbf5a1 100644 --- a/cmake/QtTestHelpers.cmake +++ b/cmake/QtTestHelpers.cmake @@ -51,8 +51,10 @@ function(qt_internal_add_benchmark target) add_dependencies("${target}_benchmark" "${target}") - #Add benchmark to meta target. - add_dependencies("benchmark" "${target}_benchmark") + # Add benchmark to meta target if it exists. + if (TARGET benchmark) + add_dependencies("benchmark" "${target}_benchmark") + endif() endfunction() # Simple wrapper around qt_internal_add_executable for manual tests which insure that @@ -236,7 +238,6 @@ function(qt_internal_add_test name) set_property(TARGET "${name}" PROPERTY WIN32_EXECUTABLE FALSE) # QMLTest specifics - qt_internal_extend_target("${name}" CONDITION arg_QMLTEST PUBLIC_LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::QuickTest ) @@ -250,6 +251,11 @@ function(qt_internal_add_test name) DEFINES QUICK_TEST_SOURCE_DIR=":/" ) + + # Android requires Qt::Gui so add it by default for tests + qt_internal_extend_target("${name}" CONDITION ANDROID + PUBLIC_LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::Gui + ) endif() foreach(path IN LISTS arg_QML_IMPORTPATH) diff --git a/cmake/QtWrapperScriptHelpers.cmake b/cmake/QtWrapperScriptHelpers.cmake index 3f8fbca54f..15b0ca9eca 100644 --- a/cmake/QtWrapperScriptHelpers.cmake +++ b/cmake/QtWrapperScriptHelpers.cmake @@ -162,6 +162,4 @@ function(qt_internal_install_android_helper_scripts) qt_path_join(destination "${QT_INSTALL_DIR}" "${INSTALL_LIBEXECDIR}") qt_copy_or_install(PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR}/util/android/android_emulator_launcher.sh" DESTINATION "${destination}") - qt_copy_or_install(PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR}/util/android/android_cmakelist_patcher.sh" - DESTINATION "${destination}") endfunction() diff --git a/cmake/README.md b/cmake/README.md index eaaa781380..e7e600536f 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -1,20 +1,24 @@ -# Status +# Overview -Port is still on-going. +This document gives an overview of the Qt 6 build system. For a hands-on guide on how +to build Qt 6, see https://doc.qt.io/qt-6/build-sources.html and +https://wiki.qt.io/Building_Qt_6_from_Git -Note: -You need CMake 3.16.0 or later for most platforms (due to new AUTOMOC json feature). -You need CMake 3.17.0 to build Qt for iOS with the simulator_and_device feature. -You need CMake 3.17.0 + Ninja to build Qt in debug_and_release mode on Windows / Linux. -You need CMake 3.18.0 + Ninja to build Qt on macOS in debug_and_release mode when using frameworks. +# CMake Versions -# Intro +* You need CMake 3.16.0 or later for most platforms (due to new AUTOMOC json feature). +* You need CMake 3.17.0 to build Qt for iOS with the simulator_and_device feature. +* You need CMake 3.17.0 + Ninja to build Qt in debug_and_release mode on Windows / Linux. +* You need CMake 3.18.0 + Ninja to build Qt on macOS in debug_and_release mode when using frameworks. -The CMake update offers an opportunity to revisit some topics that came up during the last few -years. +# Changes to Qt 5 -* The Qt build system does not support building host tools during a cross-compilation run. You need - to build a Qt for your host machine first and then use the platform tools from that version. The +The build system of Qt 5 was done on top of qmake. Qt 6 is built with CMake. + +This offered an opportunity to revisit other areas of the build system, too: + +* The Qt 5 build system allowed to build host tools during a cross-compilation run. Qt 6 requires + you to build a Qt for your host machine first and then use the platform tools from that version. The decision to do this was reached independent of cmake: This does save resources on build machines as the host tools will only get built once. @@ -24,14 +28,10 @@ years. * There is less need for bootstrapping. Only moc and rcc (plus the lesser known tracegen and qfloat16-tables) are linking against the bootstrap Qt library. Everything else can link against - the full QtCore. This will include qmake. - Qmake is supported as a build system for applications *using* Qt going forward and will + the full QtCore. This does include qmake. + qmake is supported as a build system for applications *using* Qt going forward and will not go away anytime soon. -* We keep the qmake-based Qt build system working so that we do not interfere too much with ongoing - development. - - # Building against homebrew on macOS You may use brew to install dependencies needed to build QtBase. |