From 81096b44bb183772c979debca2ffd1f8b364bbc8 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 12 Mar 2021 14:53:23 +0100 Subject: 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 --- CMakeLists.txt | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 547865a9..eb092c7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() + + set(required FALSE) + if(dep IN_LIST required_deps) + set(required TRUE) + endif() + + set(error_reason "") 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(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(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") + + 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() -- cgit v1.2.3