mirror of
git://code.qt.io/qt/qt5.git
synced 2025-12-21 07:28:21 +08:00
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:
@@ -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()
|
||||
|
||||
@@ -17,24 +17,34 @@ endfunction()
|
||||
# Each entry will be in the format dependency/sha1
|
||||
function(qt_internal_parse_dependencies depends_file out_dependencies)
|
||||
file(STRINGS "${depends_file}" lines)
|
||||
set(eof_marker "---EOF---")
|
||||
list(APPEND lines "${eof_marker}")
|
||||
set(required_default TRUE)
|
||||
set(dependencies "")
|
||||
set(dependency "")
|
||||
set(revision "")
|
||||
set(required "${required_default}")
|
||||
foreach(line IN LISTS lines)
|
||||
if(line STREQUAL "dependencies:")
|
||||
set(found_dependencies 1)
|
||||
elseif(found_dependencies)
|
||||
if(line MATCHES "^ ref: (.*)$")
|
||||
set(revision "${CMAKE_MATCH_1}")
|
||||
list(APPEND dependencies ${dependency}/${revision})
|
||||
set(dependency "")
|
||||
elseif (line MATCHES "^ (.*):$")
|
||||
if(dependency)
|
||||
if(line MATCHES "^ (.+):$" OR line STREQUAL "${eof_marker}")
|
||||
# Found a repo entry or end of file. Add the last seen dependency.
|
||||
if(NOT dependency STREQUAL "")
|
||||
if(revision STREQUAL "")
|
||||
message(FATAL_ERROR "Format error in ${depends_file} - ${dependency} does not specify revision!")
|
||||
endif()
|
||||
list(APPEND dependencies "${dependency}/${revision}/${required}")
|
||||
endif()
|
||||
# Remember the current dependency
|
||||
if(NOT line STREQUAL "${eof_marker}")
|
||||
set(dependency "${CMAKE_MATCH_1}")
|
||||
set(revision "")
|
||||
set(required "${required_default}")
|
||||
# dependencies are specified with relative path to this module
|
||||
string(REPLACE "../" "" dependency ${dependency})
|
||||
endif()
|
||||
elseif(line MATCHES "^ ref: (.+)$")
|
||||
set(revision "${CMAKE_MATCH_1}")
|
||||
elseif(line MATCHES "^ required: (.+)$")
|
||||
string(TOUPPER "${CMAKE_MATCH_1}" required)
|
||||
endif()
|
||||
endforeach()
|
||||
message(DEBUG "qt_internal_parse_dependencies for ${depends_file}: ${dependencies} ${revisions}")
|
||||
@@ -66,10 +76,16 @@ function(qt_internal_add_module_dependencies module ordered out_ordered out_has_
|
||||
endif()
|
||||
set(modules_dependencies "")
|
||||
foreach(dependency IN LISTS dependencies)
|
||||
string(FIND "${dependency}" "/" splitindex REVERSE)
|
||||
string(SUBSTRING "${dependency}" ${splitindex} -1 revision)
|
||||
string(SUBSTRING "${revision}" 1 -1 revision)
|
||||
string(SUBSTRING "${dependency}" 0 ${splitindex} dependency)
|
||||
if(dependency MATCHES "(.*)/([^/]+)/([^/]+)")
|
||||
set(dependency "${CMAKE_MATCH_1}")
|
||||
set(revision "${CMAKE_MATCH_2}")
|
||||
set(required "${CMAKE_MATCH_3}")
|
||||
if(required)
|
||||
set_property(GLOBAL APPEND PROPERTY QT_REQUIRED_DEPS_FOR_${module} ${dependency})
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Internal Error: wrong dependency format ${dependency}")
|
||||
endif()
|
||||
list(APPEND modules_dependencies "${dependency}")
|
||||
list(FIND ordered "${dependency}" dindex)
|
||||
if (dindex EQUAL -1)
|
||||
|
||||
Reference in New Issue
Block a user