microsoft/onnxruntime-extensions

Public

mirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
3649db065d6cff05ee0f29e4a886b2b13fcf8d3e

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cmake/ext_python.cmake

47lines · modecode

1block(PROPAGATE Python3_FOUND)
2 set(Python3_FIND_REGISTRY NEVER)
3 # if we don't set this to NEVER (or possibly LAST) the builds of the wheel for different python versions will fail
4 # as it will find the system python version first and not the correct python version for the wheel.
5 set(Python3_FIND_FRAMEWORK NEVER)
6 find_package(Python3 COMPONENTS Interpreter Development.Module)
7endblock()
8
9if (NOT Python3_FOUND)
10 message(FATAL_ERROR "Python3 not found!")
11endif()
12
13file(GLOB TARGET_SRC_PYOPS "pyop/*.cc" "pyop/*.h" "shared/*.cc")
14if (WIN32)
15 list(APPEND TARGET_SRC_PYOPS "pyop/extensions_pydll.def")
16endif()
17
18add_library(extensions_pydll SHARED ${TARGET_SRC_PYOPS} ${shared_TARGET_LIB_SRC})
19standardize_output_folder(extensions_pydll)
20list(APPEND OCOS_COMPILE_DEFINITIONS PYTHON_OP_SUPPORT)
21target_compile_definitions(extensions_pydll PRIVATE ${OCOS_COMPILE_DEFINITIONS})
22
23message(STATUS "Fetch pybind11")
24include(pybind11)
25target_include_directories(extensions_pydll PRIVATE
26 ${pybind11_INCLUDE_DIRS}
27 $<TARGET_PROPERTY:Python3::Module,INTERFACE_INCLUDE_DIRECTORIES>
28 $<TARGET_PROPERTY:ocos_operators,INTERFACE_INCLUDE_DIRECTORIES>)
29
30target_compile_definitions(extensions_pydll PRIVATE
31 $<TARGET_PROPERTY:Python3::Module,INTERFACE_COMPILE_DEFINITIONS>)
32
33target_link_libraries(extensions_pydll PRIVATE Python3::Module ocos_operators)
34
35if(OCOS_PYTHON_MODULE_PATH)
36 get_filename_component(OCOS_PYTHON_MODULE_NAME ${OCOS_PYTHON_MODULE_PATH} NAME)
37 if(NOT WIN32)
38 set_target_properties(extensions_pydll PROPERTIES
39 LIBRARY_OUTPUT_NAME ${OCOS_PYTHON_MODULE_NAME}
40 PREFIX ""
41 SUFFIX "")
42 endif()
43
44 add_custom_command(TARGET extensions_pydll POST_BUILD
45 COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:extensions_pydll> ${OCOS_PYTHON_MODULE_PATH}
46 COMMENT "Copying $<TARGET_FILE:extensions_pydll> to ${OCOS_PYTHON_MODULE_PATH}")
47endif()
48