Do not error out on missing optional repository dependencies

Read the 'required' value from dependencies.yaml and store all required
dependencies of repository 'qtfoo' in a global property
QT_REQUIRED_DEPS_FOR_qtfoo.

Check this property in the top-level CMakeLists.txt and only print
informational messages instead of errors for optional dependencies.

Fixes: QTBUG-91144
Change-Id: I0e1b84a70221857cebba1b9a27456ad3667bfe3a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann
2021-03-12 14:53:23 +01:00
parent 174a511460
commit 81096b44bb
2 changed files with 52 additions and 21 deletions

View File

@@ -49,20 +49,35 @@ qt_internal_sort_module_dependencies("${BUILD_SUBMODULES}" BUILD_SUBMODULES
foreach(module IN LISTS BUILD_SUBMODULES)
# Check for unmet dependencies
if(NOT DEFINED BUILD_${module} OR BUILD_${module})
message(NOTICE "Check dependencies of '${module}'")
message(NOTICE "Checking dependencies of '${module}'")
get_property(required_deps GLOBAL PROPERTY QT_REQUIRED_DEPS_FOR_${module})
foreach(dep IN LISTS "${qt_module_dependency_map_prefix}${module}")
if (dep STREQUAL "qtbase")
# Always available skip
continue()
endif()
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${dep}/CMakeLists.txt")
message(FATAL_ERROR "Module '${module}' depends on '${dep}', but ${dep}'s \
CMakeLists.txt couldn't be found.\nNote: Use '-skip ${module}' to exclude it \
from build.\n")
set(required FALSE)
if(dep IN_LIST required_deps)
set(required TRUE)
endif()
if(DEFINED BUILD_${dep} AND NOT BUILD_${dep})
message(FATAL_ERROR "Module '${module}' depends on '${dep}', but '${dep}' \
will not be built.\nNote: Use '-skip ${module}' to exclude it from build.\n")
set(error_reason "")
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${dep}/CMakeLists.txt")
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 error_reason STREQUAL "")
if(required)
message(FATAL_ERROR "Module '${module}' depends on '${dep}', "
"but ${error_reason}.\n"
"Note: Use '-skip ${module}' to exclude it from the build.")
else()
message(NOTICE "Skipping optional dependency '${dep}' of '${module}', "
"because ${error_reason}.")
endif()
endif()
endforeach()
endif()