configurejson2cmake: handle out-of-line config tests
Generate appropriate qt_config_compile_test() calls for config tests that have CMake projects. These are protected by an if(EXISTS) check so that configuration doesn't fail for repos where the config tests have not been ported yet. Adjust the qt_config_compile_test() function to use try_compile for projects specified via new PROJECT_PATH argument. Change-Id: I83c061e384f68688a654b782fd7a9bede282d1e3 Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
900df48122
commit
f35cc5090a
@ -471,26 +471,32 @@ function(qt_feature_copy_global_config_features_to_core target)
|
||||
endfunction()
|
||||
|
||||
function(qt_config_compile_test name)
|
||||
cmake_parse_arguments(arg "" "LABEL" "LIBRARIES;CODE" ${ARGN})
|
||||
cmake_parse_arguments(arg "" "LABEL;PROJECT_PATH" "LIBRARIES;CODE" ${ARGN})
|
||||
|
||||
foreach(library IN ITEMS ${arg_LIBRARIES})
|
||||
if(NOT TARGET "${library}")
|
||||
# If the dependency looks like a cmake target, then make this compile test
|
||||
# fail instead of cmake abort later via CMAKE_REQUIRED_LIBRARIES.
|
||||
string(FIND "${library}" "::" cmake_target_namespace_separator)
|
||||
if(NOT cmake_target_namespace_separator EQUAL -1)
|
||||
set(HAVE_${name} FALSE)
|
||||
break()
|
||||
if(arg_PROJECT_PATH)
|
||||
try_compile(HAVE_${name} "${CMAKE_BINARY_DIR}/config.tests/${name}" "${arg_PROJECT_PATH}"
|
||||
"${name}")
|
||||
else()
|
||||
foreach(library IN ITEMS ${arg_LIBRARIES})
|
||||
if(NOT TARGET "${library}")
|
||||
# If the dependency looks like a cmake target, then make this compile test
|
||||
# fail instead of cmake abort later via CMAKE_REQUIRED_LIBRARIES.
|
||||
string(FIND "${library}" "::" cmake_target_namespace_separator)
|
||||
if(NOT cmake_target_namespace_separator EQUAL -1)
|
||||
set(HAVE_${name} FALSE)
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if(NOT DEFINED HAVE_${name})
|
||||
set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${arg_LIBRARIES}")
|
||||
check_cxx_source_compiles("${arg_UNPARSED_ARGUMENTS} ${arg_CODE}" HAVE_${name})
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
|
||||
if(NOT DEFINED HAVE_${name})
|
||||
set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${arg_LIBRARIES}")
|
||||
check_cxx_source_compiles("${arg_UNPARSED_ARGUMENTS} ${arg_CODE}" HAVE_${name})
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(TEST_${name} "${HAVE_${name}}" CACHE INTERNAL "${arg_LABEL}")
|
||||
endfunction()
|
||||
|
||||
|
@ -516,7 +516,16 @@ def parseTest(ctx, test, data, cm_fh):
|
||||
details = data["test"]
|
||||
|
||||
if isinstance(details, str):
|
||||
print(f" XXXX UNHANDLED TEST SUB-TYPE {details} in test description")
|
||||
if not ctx['test_dir']:
|
||||
print(f" XXXX UNHANDLED TEST SUB-TYPE {details} in test description")
|
||||
return
|
||||
|
||||
cm_fh.write(f"""
|
||||
if(EXISTS "${{CMAKE_CURRENT_SOURCE_DIR}}/{ctx['test_dir']}/{data['test']}/CMakeLists.txt")
|
||||
qt_config_compile_test("{data['test']}"
|
||||
PROJECT_PATH "${{CMAKE_CURRENT_SOURCE_DIR}}/{ctx['test_dir']}/{data['test']}")
|
||||
endif()
|
||||
""")
|
||||
return
|
||||
|
||||
head = details.get("head", "")
|
||||
@ -975,6 +984,7 @@ def processSubconfigs(dir, ctx, data):
|
||||
|
||||
def processJson(dir, ctx, data):
|
||||
ctx["module"] = data.get("module", "global")
|
||||
ctx["test_dir"] = data.get("testDir", "")
|
||||
|
||||
ctx = processFiles(ctx, data)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user