6518bcc167
This change introduces new behavior to error out when configuring user projects if the CMake version used is too old for Qt to work with. The main motivator is the requirement of new CMake features to ensure object libraries are placed in the proper place on the link line in static builds. The minimum CMake version is computed based on whether Qt was configured as shared or static libraries. At the moment the required versions for building and using Qt are the same. The minimum versions are defined in qtbase/.cmake.conf in the following variables QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_SHARED QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_STATIC QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_SHARED QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_STATIC Qt Packagers can disable the version check when configuring Qt by setting QT_FORCE_MIN_CMAKE_VERSION_FOR_BUILDING_QT and QT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT. In this case it is the packagers responsibility to ensure such a Qt works correctly with the specified CMake version. User projects can also set QT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT to disable the version check. Then it's the project's developer responsibility to ensure such a Qt works correctly. No official support is provided for these cases. Implementation notes. The versions required to build Qt are stored in QtBuildInternalsExtra.cmake whereas the versions required to use Qt are stored in a new QtConfigExtras.cmake. Also the policy range variables stored in QtBuildInternalsExtra.cmake are now regular variables instead of cache variables, to properly allow overrides per-repository. Some renaming of functions and variables was done for a bit more clarity and easier grep-ability. Pick-to: 6.2 Task-number: QTBUG-95018 Change-Id: I4279f2e10b6d3977319237ba21e2f4ed676aa48b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
137 lines
6.1 KiB
CMake
137 lines
6.1 KiB
CMake
@PACKAGE_INIT@
|
|
|
|
cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_version@)
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@ConfigExtras.cmake")
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicCMakeVersionHelpers.cmake")
|
|
__qt_internal_require_suitable_cmake_version_for_using_qt()
|
|
|
|
get_filename_component(_qt_cmake_dir "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
|
|
set(_qt_@PROJECT_VERSION_MAJOR@_config_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
|
|
|
|
if (NOT QT_NO_CREATE_TARGETS)
|
|
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Targets.cmake")
|
|
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
|
|
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@VersionlessTargets.cmake")
|
|
endif()
|
|
else()
|
|
# For examples using `find_package(...)` inside their CMakeLists.txt files:
|
|
# Make CMake's AUTOGEN detect this Qt version properly
|
|
set_directory_properties(PROPERTIES
|
|
QT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
|
|
QT_VERSION_MINOR @PROJECT_VERSION_MINOR@
|
|
QT_VERSION_PATCH @PROJECT_VERSION_PATCH@)
|
|
endif()
|
|
|
|
if(NOT "${QT_HOST_PATH}" STREQUAL "")
|
|
find_package(Qt@PROJECT_VERSION_MAJOR@HostInfo
|
|
CONFIG
|
|
REQUIRED
|
|
PATHS "${QT_HOST_PATH}"
|
|
"${QT_HOST_PATH_CMAKE_DIR}"
|
|
NO_CMAKE_FIND_ROOT_PATH
|
|
NO_DEFAULT_PATH)
|
|
endif()
|
|
|
|
# if (NOT @INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS)
|
|
# set(@INSTALL_CMAKE_NAMESPACE@_NOT_FOUND_MESSAGE "The Qt package requires at least one component")
|
|
# set(@INSTALL_CMAKE_NAMESPACE@_FOUND False)
|
|
# return()
|
|
# endif()
|
|
|
|
get_filename_component(_qt_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
|
get_filename_component(_qt_import_prefix "${_qt_import_prefix}" REALPATH)
|
|
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}")
|
|
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/3rdparty/extra-cmake-modules/find-modules")
|
|
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/3rdparty/kwin")
|
|
|
|
if(APPLE AND (NOT CMAKE_SYSTEM_NAME OR CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
|
|
# Add module directory to pick up custom Info.plist template for macOS
|
|
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/macos")
|
|
elseif(APPLE AND CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
|
# Add module directory to pick up custom Info.plist template for iOS
|
|
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/ios")
|
|
endif()
|
|
|
|
set(QT_ADDITIONAL_PACKAGES_PREFIX_PATH "" CACHE STRING "Additional directories where find(Qt6 ...) components are searched")
|
|
file(TO_CMAKE_PATH "${QT_ADDITIONAL_PACKAGES_PREFIX_PATH}" _qt_additional_packages_prefix_path)
|
|
file(TO_CMAKE_PATH "$ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH}" _qt_additional_packages_prefix_path_env)
|
|
|
|
# Public helpers available to all Qt packages.
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtFeature.cmake")
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicFinalizerHelpers.cmake")
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicPluginHelpers.cmake")
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicTargetHelpers.cmake")
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicWalkLibsHelpers.cmake")
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicFindPackageHelpers.cmake")
|
|
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicDependencyHelpers.cmake")
|
|
|
|
if(NOT DEFINED QT_CMAKE_EXPORT_NAMESPACE)
|
|
set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
|
|
endif()
|
|
|
|
# Propagate sanitizer flags to both internal Qt builds and user projects.
|
|
# Allow opt-out in case if downstream projects handle it in a different way.
|
|
set(QT_CONFIGURED_SANITIZER_OPTIONS "@ECM_ENABLE_SANITIZERS@")
|
|
|
|
if(QT_CONFIGURED_SANITIZER_OPTIONS
|
|
AND NOT __qt_sanitizer_options_set
|
|
AND NOT QT_NO_ADD_SANITIZER_OPTIONS)
|
|
set(ECM_ENABLE_SANITIZERS "${QT_CONFIGURED_SANITIZER_OPTIONS}")
|
|
include(
|
|
"${CMAKE_CURRENT_LIST_DIR}/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake")
|
|
endif()
|
|
# Mark that the current directory scope has its sanitizer flags set.
|
|
set(__qt_sanitizer_options_set TRUE)
|
|
|
|
# Find required dependencies, if any.
|
|
include(CMakeFindDependencyMacro)
|
|
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Dependencies.cmake")
|
|
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Dependencies.cmake")
|
|
if(NOT @INSTALL_CMAKE_NAMESPACE@_DEPENDENCIES_FOUND)
|
|
set(@INSTALL_CMAKE_NAMESPACE@_FOUND FALSE)
|
|
message(FATAL_ERROR "Failed to find Qt Platform dependency: "
|
|
"${@INSTALL_CMAKE_NAMESPACE@_DEPENDENCY_NOT_FOUND_MESSAGE}")
|
|
endif()
|
|
endif()
|
|
|
|
set(__qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH")
|
|
if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
|
|
set(__qt_use_no_default_path_for_qt_packages "")
|
|
endif()
|
|
|
|
foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
|
|
find_package(@INSTALL_CMAKE_NAMESPACE@${module}
|
|
${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET}
|
|
${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_REQUIRED}
|
|
PATHS
|
|
${_qt_cmake_dir}
|
|
${_qt_additional_packages_prefix_path}
|
|
${_qt_additional_packages_prefix_path_env}
|
|
${QT_EXAMPLES_CMAKE_PREFIX_PATH}
|
|
${__qt_use_no_default_path_for_qt_packages}
|
|
)
|
|
if (NOT @INSTALL_CMAKE_NAMESPACE@${module}_FOUND)
|
|
string(CONFIGURE ${_qt5_module_location_template} _expected_module_location @ONLY)
|
|
|
|
if (@INSTALL_CMAKE_NAMESPACE@_FIND_REQUIRED_${module})
|
|
set(_Qt_NOTFOUND_MESSAGE "${_Qt_NOTFOUND_MESSAGE}Failed to find Qt component \"${module}\" config file at \"${_expected_module_location}\"\n")
|
|
elseif(NOT @INSTALL_CMAKE_NAMESPACE@_FIND_QUIETLY)
|
|
message(WARNING "Failed to find Qt component \"${module}\" config file at \"${_expected_module_location}\"")
|
|
endif()
|
|
|
|
unset(_expected_module_location)
|
|
endif()
|
|
endforeach()
|
|
|
|
if (_Qt_NOTFOUND_MESSAGE)
|
|
set(@INSTALL_CMAKE_NAMESPACE@_NOT_FOUND_MESSAGE "${_Qt_NOTFOUND_MESSAGE}")
|
|
set(@INSTALL_CMAKE_NAMESPACE@_FOUND False)
|
|
endif()
|
|
|
|
__qt_internal_defer_promote_targets_in_dir_scope_to_global()
|
|
if(CMAKE_VERSION VERSION_LESS 3.21)
|
|
__qt_internal_check_link_order_matters()
|
|
__qt_internal_check_cmp0099_available()
|
|
endif()
|