CrucibleAddPythonTest.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
include_guard(GLOBAL) option(CRUCIBLE_ENABLE_PYTHON_TESTS "Run Python-based tests during ctest (requires Python 3)" ON) if(CRUCIBLE_ENABLE_PYTHON_TESTS) find_package(Python3 QUIET) endif() function(crucible_add_python_test TEST_NAME) if(NOT CRUCIBLE_ENABLE_PYTHON_TESTS) message(STATUS "Skipping Python test '${TEST_NAME}' (CRUCIBLE_ENABLE_PYTHON_TESTS is set to '${CRUCIBLE_ENABLE_PYTHON_TESTS}'") return() endif() if(NOT Python3_FOUND) message(STATUS "Skipping Python test '${TEST_NAME}' (no Python 3 available)") return() endif() cmake_parse_arguments(TEST "" "SCRIPT" "ARGUMENTS" ${ARGN}) add_test( NAME "${TEST_NAME}" COMMAND "${Python3_EXECUTABLE}" "${TEST_SCRIPT}" ${TEST_ARGUMENTS}) endfunction()