aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/tests/CMakeLists.txt')
-rw-r--r--sources/shiboken6/tests/CMakeLists.txt33
1 files changed, 28 insertions, 5 deletions
diff --git a/sources/shiboken6/tests/CMakeLists.txt b/sources/shiboken6/tests/CMakeLists.txt
index 76b94d4c1..05f6e9e60 100644
--- a/sources/shiboken6/tests/CMakeLists.txt
+++ b/sources/shiboken6/tests/CMakeLists.txt
@@ -1,7 +1,10 @@
-cmake_minimum_required(VERSION 3.16)
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.18)
if(BUILD_TESTS)
- find_package(Qt${QT_MAJOR_VERSION}Test 5.12 REQUIRED)
+ find_package(Qt${QT_MAJOR_VERSION}Test 6.0 REQUIRED)
endif()
add_subdirectory(libminimal)
@@ -11,6 +14,8 @@ if(NOT DEFINED MINIMAL_TESTS)
add_subdirectory(libother)
endif()
+shiboken_get_debug_level(debug_level)
+
if(WIN32 OR DEFINED AVOID_PROTECTED_HACK)
message(STATUS "Tests will be generated avoiding the protected hack!")
set(GENERATOR_EXTRA_FLAGS --avoid-protected-hack)
@@ -18,6 +23,7 @@ else()
message(STATUS "Tests will be generated using the protected hack!")
set(GENERATOR_EXTRA_FLAGS )
endif()
+list(APPEND GENERATOR_EXTRA_FLAGS ${SHIBOKEN_GENERATOR_EXTRA_FLAGS} ${debug_level})
add_subdirectory(minimalbinding)
if(NOT DEFINED MINIMAL_TESTS)
@@ -39,7 +45,21 @@ list(SORT TEST_FILES)
set(test_blacklist "")
-find_package(PythonInterp REQUIRED)
+if(SHIBOKEN_IS_CROSS_BUILD)
+ # Python_EXECUTABLE will be empty when cross-building.
+ message(WARNING
+ "Running tests when cross-compiling is not supported because it would require running "
+ "a target python interpreter which might have a different architecture than the host."
+ )
+else()
+ find_package(
+ Python
+ ${USE_PYTHON_VERSION}
+ REQUIRED
+ COMPONENTS Interpreter Development
+ )
+endif()
+
if(NOT CTEST_TESTING_TIMEOUT)
set(CTEST_TESTING_TIMEOUT 60)
endif()
@@ -51,7 +71,7 @@ foreach(test_file ${TEST_FILES})
string(REGEX MATCH "/([^/]+)(binding|module)/([^/]+)_test.py" tmp ${test_file})
set(test_name "${CMAKE_MATCH_1}_${CMAKE_MATCH_3}")
list(FIND test_blacklist ${test_name} expect_fail)
- add_test(${test_name} ${PYTHON_EXECUTABLE} ${test_file})
+ add_test(${test_name} ${Python_EXECUTABLE} ${test_file})
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "BUILD_DIR=${BUILD_DIR}")
set_tests_properties(${test_name} PROPERTIES TIMEOUT ${CTEST_TESTING_TIMEOUT})
if (${expect_fail} GREATER -1)
@@ -59,7 +79,10 @@ foreach(test_file ${TEST_FILES})
endif()
endforeach()
-add_subdirectory(dumpcodemodel)
+# dumpcodemodel depends on apiextractor which is not cross-built.
+if(SHIBOKEN_BUILD_TOOLS)
+ add_subdirectory(dumpcodemodel)
+endif()
# FIXME Skipped until add an option to choose the generator
# add_subdirectory(test_generator)