CMake: Fix config tests not finding module-provided CMake packages

This amends commit 165e01d5d5.

Above commit broke the code that adds "${PROJECT_SOURCE_DIR}/cmake" to
CMAKE_MODULE_PATH.  The semicolon that separates entries of
CMAKE_MODULE_PATH must be escaped.  Otherwise, the semicolon separates
elements of the flags list.

Additionally, fix the QT_AVOID_CUSTOM_PLATFORM_MODULES code path which
lacked the addition of "${PROJECT_SOURCE_DIR}/cmake".

Pick-to: 6.2
Change-Id: I72f78cf066cabe6b0002dce1aa0294aa0dc9cbf0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2021-10-12 17:15:12 +02:00
parent 0098e0ca86
commit 8b09c9d690

View File

@ -801,14 +801,19 @@ function(qt_config_compile_test name)
# If the repo has its own cmake modules, include those in the module path, so that various
# find_package calls work.
if(EXISTS "${PROJECT_SOURCE_DIR}/cmake")
set(must_append_module_path_flag TRUE)
set(flags_copy "${flags}")
set(flags)
foreach(flag IN LISTS flags_copy)
if(flag MATCHES "^-DCMAKE_MODULE_PATH:STRING=")
set(flag "${flag};${PROJECT_SOURCE_DIR}/cmake")
set(must_append_module_path_flag FALSE)
set(flag "${flag}\\;${PROJECT_SOURCE_DIR}/cmake")
endif()
list(APPEND flags "${flag}")
endforeach()
if(must_append_module_path_flag)
list(APPEND flags "-DCMAKE_MODULE_PATH:STRING=${PROJECT_SOURCE_DIR}/cmake")
endif()
endif()
# Pass which packages need to be found.