1# Copyright (c) 2020-2021 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 15find_package(PythonInterp 3.5 REQUIRED) 16 17set(PYTHON_BUILD_WORK_DIR .) 18 19add_custom_target( 20 python_copy 21 COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/tbb ${PYTHON_BUILD_WORK_DIR}/tbb 22 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/TBB.py ${PYTHON_BUILD_WORK_DIR} 23 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/setup.py ${PYTHON_BUILD_WORK_DIR} 24) 25 26# Python build requires path to TBB headers 27get_target_property(TBB_INCLUDES tbb INTERFACE_INCLUDE_DIRECTORIES) 28foreach(dir ${TBB_INCLUDES}) 29 if (${dir} MATCHES "<BUILD_INTERFACE:" OR TBB_FOUND) 30 set(TBB4PY_INCLUDE_STRING "-I${dir} ${TBB4PY_INCLUDE_STRING}") 31 endif() 32endforeach() 33string(STRIP "${TBB4PY_INCLUDE_STRING}" TBB4PY_INCLUDE_STRING) 34 35add_custom_target( 36 python_build 37 DEPENDS tbb python_copy 38 COMMAND 39 ${PYTHON_EXECUTABLE} ${PYTHON_BUILD_WORK_DIR}/setup.py 40 build -b${PYTHON_BUILD_WORK_DIR} 41 build_ext ${TBB4PY_INCLUDE_STRING} -L$<TARGET_FILE_DIR:TBB::tbb> 42 install --prefix ${PYTHON_BUILD_WORK_DIR}/build -f 43 COMMENT "Build and install to work directory the oneTBB Python module" 44) 45 46add_test(NAME python_test 47 COMMAND ${CMAKE_COMMAND} 48 -DTBB_BINARIES_PATH=$<TARGET_FILE_DIR:TBB::tbb> 49 -DPYTHON_MODULE_BUILD_PATH=${PYTHON_BUILD_WORK_DIR}/build 50 -P ${PROJECT_SOURCE_DIR}/cmake/python/test_launcher.cmake) 51 52install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON_BUILD_WORK_DIR}/build/ 53 DESTINATION . 54 COMPONENT tbb4py) 55 56if (UNIX AND NOT APPLE) 57 add_subdirectory(rml) 58 add_dependencies(python_build irml) 59endif() 60