Debian Codegraph @

third-party/tbb/cmake/python/test_launcher.cmake

raw
1 # Copyright (c) 2020-2025 Intel Corporation
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 if (POLICY CMP0148)
16 # CMake 3.27: The FindPythonInterp and FindPythonLibs modules are removed
17 cmake_policy(SET CMP0148 OLD)
18 endif()
19
20 find_package(PythonInterp 3.5 REQUIRED)
21
22 file(GLOB_RECURSE MODULES_LIST "${PYTHON_MODULE_BUILD_PATH}/*TBB.py*" )
23 list(LENGTH MODULES_LIST MODULES_COUNT)
24
25 if (MODULES_COUNT EQUAL 0)
26 message(FATAL_ERROR "Cannot find oneTBB Python module")
27 elseif (MODULES_COUNT GREATER 1)
28 message(WARNING "Found more than oneTBB Python modules, the only first found module will be tested")
29 endif()
30
31 list(GET MODULES_LIST 0 PYTHON_MODULE)
32 get_filename_component(PYTHON_MODULE_PATH ${PYTHON_MODULE} DIRECTORY)
33
34 execute_process(
35 COMMAND
36 ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${TBB_BINARIES_PATH}
37 ${PYTHON_EXECUTABLE} -m tbb test
38 WORKING_DIRECTORY ${PYTHON_MODULE_PATH}
39 RESULT_VARIABLE CMD_RESULT
40 )
41 if (CMD_RESULT)
42 message(FATAL_ERROR "Error while test execution: ${cmd} error_code: ${CMD_RESULT}")
43 endif()