diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2019-02-11 13:13:43 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-02-12 14:01:26 +0000 |
commit | f1b688bc7c33d93993945e25b9d3aa4cc7215c5f (patch) | |
tree | 828f2eff390cfa165a9775c38b59e196278ce2ae | |
parent | 988162eaf8b2aeae61f820382021116bf4ee391d (diff) |
Fix qt_config_compile_test when cross-compiling
When we do
qt_config_compile_test(egl_x11
LABEL "EGL on X11"
LIBRARIES X11::X11
...
)
then check_cxx_source_compiles() aborts if the provided targets do not
exist (we map LIBRARIES to CMAKE_REQUIRED_LIBRARIES). However we just
want the test to fail. Therefore this patch verifies the presence of the
targets.
Change-Id: Ibd7c1b50d585339af0ca0de58bc5c9cd64d65d6d
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
-rw-r--r-- | cmake/QtFeature.cmake | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index 79663c17a3..4a8449405e 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -387,10 +387,24 @@ endfunction() function(qt_config_compile_test name) cmake_parse_arguments(arg "" "LABEL" "LIBRARIES;CODE" ${ARGN}) - 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}") + 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() + 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}") + endif() set(TEST_${name} "${HAVE_${name}}" CACHE INTERNAL "${arg_LABEL}") endfunction() |