summaryrefslogtreecommitdiffstats
path: root/cmake/QtFeature.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-09-21 16:22:36 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-09-22 10:27:22 +0000
commitf35cc5090a3d78ee7f843625d2c19e472e031cc7 (patch)
treecea37a7e3d5e930e7b5aa70d27c2264ac43d723d /cmake/QtFeature.cmake
parent900df4812278f8c9cde915690a2be355307f09dd (diff)
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>
Diffstat (limited to 'cmake/QtFeature.cmake')
-rw-r--r--cmake/QtFeature.cmake40
1 files changed, 23 insertions, 17 deletions
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake
index edf2a95c65..4be4cd550c 100644
--- a/cmake/QtFeature.cmake
+++ b/cmake/QtFeature.cmake
@@ -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})
-
- 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()
+ cmake_parse_arguments(arg "" "LABEL;PROJECT_PATH" "LIBRARIES;CODE" ${ARGN})
+
+ 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()