diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 182 |
1 files changed, 93 insertions, 89 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 01fca842..b163500c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,116 +1,120 @@ -cmake_minimum_required(VERSION 3.15.0) +# The real minimum version will be checked by the qtbase project. +# 3.16 is the absolute minimum though. +cmake_minimum_required(VERSION 3.16...3.21) + +# set QT_SUPERBUILD early, so that qtbase/.cmake.conf can check it +set(QT_SUPERBUILD TRUE) + +# Include qtbase's .cmake.conf for access to QT_REPO_MODULE_VERSION +set(__qt6_qtbase_src_path "${CMAKE_CURRENT_SOURCE_DIR}/qtbase") +include("${__qt6_qtbase_src_path}/.cmake.conf") +include("${__qt6_qtbase_src_path}/cmake/QtBaseTopLevelHelpers.cmake") + +qt_internal_top_level_setup_autodetect() project(Qt - VERSION 6.0.0 + VERSION "${QT_REPO_MODULE_VERSION}" DESCRIPTION "Qt Libraries" HOMEPAGE_URL "https://qt.io/" LANGUAGES CXX C ASM ) -# Required so we can call ctest from the root build directory -enable_testing() - -set(qt_module_prop_prefix "__qt_prop_") -function(extract_git_submodules out_module_list) - set(current_module "") - set(module_list "") - file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules" lines) - foreach(line IN LISTS lines) - # Skip empty lines. - if(NOT line) - continue() - endif() - string(REGEX REPLACE "^\\[submodule \"([^\"]+)\"\\]$" "\\1" module "${line}") - if (NOT module STREQUAL line) - set(current_module "${module}") - list(APPEND module_list "${module}") - else() - string(REGEX REPLACE "^\t([^ =]+) *=.*$" "\\1" prop "${line}") - if (NOT prop STREQUAL line) - string(REGEX REPLACE "^[^=]+= *" "" value "${line}") - string(REPLACE " " ";" value "${value}") - set("${qt_module_prop_prefix}${current_module}_${prop}" "${value}" PARENT_SCOPE) - else() - message(FATAL_ERROR "Malformed line ${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules: ${line}") - endif() - endif() - endforeach() - set(${out_module_list} ${module_list} PARENT_SCOPE) -endfunction() +qt_internal_top_level_setup_after_project() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -if (NOT QT_BUILD_STANDALONE_TESTS) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/qtbase/cmake") -endif() +qt_internal_top_level_setup_cmake_module_path() +include(QtTopLevelHelpers) include(ECMOptionalAddSubdirectory) -include(TopologicalSort) -# Use the CMake config files from the binary dir -list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}") -# Also make sure the CMake config files do not recreate the already-existing targets -if (NOT QT_BUILD_STANDALONE_TESTS) - set(QT_NO_CREATE_TARGETS TRUE) +qt_internal_top_level_before_build_submodules() + +qt_internal_find_modules(known_submodules) +# Get submodule list if not already defined +if(NOT QT_BUILD_SUBMODULES) + if(DEFINED ENV{QT_BUILD_SUBMODULES}) + set(QT_BUILD_SUBMODULES "$ENV{QT_BUILD_SUBMODULES}") + else() + set(QT_BUILD_SUBMODULES "${known_submodules}") + endif() endif() -set(QT_SUPERBUILD TRUE) +set(QT_BUILD_SUBMODULES "${QT_BUILD_SUBMODULES}" CACHE STRING "Submodules to build") -# Get submodules list -extract_git_submodules(git_module_list) -foreach(module IN LISTS git_module_list) - # Prepare a list of dependencies to be fed into topological sort - set("${qt_module_prop_prefix}${module}_all_dependencies" - ${${qt_module_prop_prefix}${module}_depends} - ${${qt_module_prop_prefix}${module}_recommends} - ${${qt_module_prop_prefix}${module}_serialize} - ) +# Preliminary check if module should be skipped since -skip <module> or BUILD_<module> +# are provided. +set(explicitly_skipped_modules "") +foreach(module IN LISTS known_submodules) + if(DEFINED BUILD_${module} AND NOT BUILD_${module}) + list(APPEND explicitly_skipped_modules ${module}) + endif() endforeach() -# Sort by dependencies -topological_sort(git_module_list "${qt_module_prop_prefix}" "_all_dependencies") - -# Check for unknown modules -foreach(module IN LISTS git_module_list) - foreach(dep IN LISTS "${qt_module_prop_prefix}${module}_all_dependencies") - if (NOT dep IN_LIST git_module_list) - message(FATAL_ERROR "Module '${module}' depends on undeclared module '${dep}'") - endif() - endforeach() +foreach(module IN LISTS QT_BUILD_SUBMODULES) + if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${module}/CMakeLists.txt) + message(FATAL_ERROR + "Module '${module}' cannot be found. Please double-check the " + "spelling and try again. Or run\n" + "`./configure -init-submodules -submodules ${module}` " + "to clone the submodule and its dependencies.") + endif() endforeach() -# qtbase is always needed -list(REMOVE_ITEM git_module_list qtbase) -add_subdirectory(qtbase) +qt_internal_sort_module_dependencies("${QT_BUILD_SUBMODULES}" QT_BUILD_SUBMODULES + SKIP_MODULES ${explicitly_skipped_modules}) -if (NOT QT_BUILD_STANDALONE_TESTS) - list(APPEND CMAKE_PREFIX_PATH "${QtBase_BINARY_DIR}") -endif() +foreach(module IN LISTS QT_BUILD_SUBMODULES) + # Check for unmet dependencies + if(NOT DEFINED BUILD_${module} OR BUILD_${module}) + message(STATUS "Checking dependencies of submodule '${module}'") + get_property(required_deps GLOBAL PROPERTY QT_REQUIRED_DEPS_FOR_${module}) + get_property(dependencies GLOBAL PROPERTY QT_DEPS_FOR_${module}) + foreach(dep IN LISTS dependencies) + if (dep STREQUAL "qtbase") + # Always available skip + continue() + endif() -foreach(module IN LISTS git_module_list) - ecm_optional_add_subdirectory(${module}) -endforeach() + set(required FALSE) + if(dep IN_LIST required_deps) + set(required TRUE) + endif() -# Check for unmet dependencies -foreach(module IN LISTS git_module_list) - foreach(dep IN LISTS "${qt_module_prop_prefix}${module}_depends") - if (dep STREQUAL qtbase) - # Always available skip - continue() - endif() - if (DEFINED BUILD_${module} AND BUILD_${module}) + set(error_reason "") if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${dep}/CMakeLists.txt") - message(FATAL_ERROR "Module '${module} depends on '${dep}', but ${deps}'s CMakeLists.txt couldn't be found.\n") + set(error_reason "${dep}'s CMakeLists.txt couldn't be found") + elseif(DEFINED BUILD_${dep} AND NOT BUILD_${dep}) + set(error_reason "building '${dep}' was explicitly disabled") endif() - if(NOT BUILD_${dep}) - message(FATAL_ERROR "Module '${module} depends on '${dep}', but ${deps} will not be built.\n") + + if(NOT error_reason STREQUAL "") + if(required) + if(QT_INTERNAL_CALLED_FROM_CONFIGURE) + set(skip_argument "-skip ${module}") + else() + set(skip_argument "-DBUILD_${module}=OFF") + endif() + + message(FATAL_ERROR "Module '${module}' depends on '${dep}', " + "but ${error_reason}.\n" + "Note: Use '${skip_argument}' to exclude it from the build.") + else() + message(STATUS "Skipping optional dependency '${dep}' of '${module}', " + "because ${error_reason}.") + endif() endif() - endif() - endforeach() + endforeach() + endif() endforeach() - -if(NOT QT_BUILD_STANDALONE_TESTS) - # Display a summary of everything - include(QtBuildInformation) - qt_print_feature_summary() - qt_print_build_instructions() +if(NOT DEFINED CMAKE_MESSAGE_CONTEXT_SHOW) + set(CMAKE_MESSAGE_CONTEXT_SHOW TRUE) endif() + +foreach(module IN LISTS QT_BUILD_SUBMODULES) + message(STATUS "Configuring submodule '${module}'") + ecm_optional_add_subdirectory("${module}") + + qt_internal_top_level_after_add_subdirectory() +endforeach() + +qt_internal_top_level_end() |