onnxruntime/cmake/onnxruntime_pyop.cmake
Dmitri Smirnov d1b1cdc5c4
Replace GSL with GSL-LITE submodule and fix up refs (#1920)
Remove gsl subodule and replace with a local copy of gsl-lite
  Refactor for onnxruntime::make_unique
  gsl::span size and index are now size_t
  Remove lambda auto argument type detection.
  Remove constexpr from fail_fast in gsl due to Linux not being happy.
  Comment out std::stream support due to MacOS std lib broken.
  Move make_unique into include/core/common so it is accessible for server builds.
  Relax requirements for onnxruntime/test/providers/cpu/ml/write_scores_test.cc
  due to x86 build.
  Add ONNXRUNTIME_ROOT to Server Lib includes so gsl is recognized
2019-10-01 12:43:29 -07:00

59 lines
2.3 KiB
CMake

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
set(PYTHON_NOT_FOUND false)
exec_program("${PYTHON_EXECUTABLE}" # get python include path
ARGS "-c \"import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())\""
OUTPUT_VARIABLE PYTHON_INCLUDE_DIR
RETURN_VALUE PYTHON_NOT_FOUND)
if(${PYTHON_NOT_FOUND})
message(FATAL_ERROR "Cannot get Python include directory. Is distutils installed?")
else()
exec_program("${PYTHON_EXECUTABLE}" # get python library path
ARGS "-c \"
import os
import re
import sys
major = sys.version_info.major
minor = sys.version_info.minor
regex = re.compile('^(libpython|python)'+str(major)+'\.?'+str(minor)+'m?\.(so|lib|dylib)$')
pydir = os.path.abspath(os.path.join(os.path.dirname(sys.executable),'..'))
for r,d,fs in os.walk(pydir):
for f in fs:
if regex.match(f):
print (os.path.join(r,f))
sys.exit()
\"
"
OUTPUT_VARIABLE PYTHON_LIBRARIES)
endif(${PYTHON_NOT_FOUND})
exec_program("${PYTHON_EXECUTABLE}" # get numpy include path
ARGS "-c \"import numpy; print(numpy.get_include())\""
OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
RETURN_VALUE NUMPY_NOT_FOUND)
if(${NUMPY_NOT_FOUND})
message(FATAL_ERROR "Cannot get NumPy include directory: Is NumPy installed?")
endif(${NUMPY_NOT_FOUND})
message("PYTHON EXE: " ${PYTHON_EXECUTABLE})
message("PYTHON INC: " ${PYTHON_INCLUDE_DIR})
message("PYTHON LIB: " ${PYTHON_LIBRARIES})
message("NUMPY INC: " ${NUMPY_INCLUDE_DIR})
include_directories(${PYTHON_INCLUDE_DIR})
include_directories(${NUMPY_INCLUDE_DIR})
file(GLOB onnxruntime_pywrapper_srcs "${ONNXRUNTIME_ROOT}/core/language_interop_ops/pyop/pywrapper.cc")
add_library(onnxruntime_pywrapper SHARED ${onnxruntime_pywrapper_srcs})
if (WIN32)
set_target_properties(onnxruntime_pywrapper PROPERTIES LINK_FLAGS "/ignore:4199")
endif()
target_link_libraries(onnxruntime_pywrapper PUBLIC ${PYTHON_LIBRARIES})
file(GLOB onnxruntime_pyop_srcs "${ONNXRUNTIME_ROOT}/core/language_interop_ops/pyop/pyop.cc")
add_library(onnxruntime_pyop ${onnxruntime_pyop_srcs})
add_dependencies(onnxruntime_pyop onnxruntime_graph)
onnxruntime_add_include_to_target(onnxruntime_pyop onnxruntime_common onnxruntime_graph onnxruntime_framework onnx onnx_proto protobuf::libprotobuf)
target_include_directories(onnxruntime_pyop PRIVATE ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS})