comparison mlir/cmake/modules/MLIRDetectPythonEnv.cmake @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents
children c4bab56944e8
comparison
equal deleted inserted replaced
220:42394fc6a535 221:79ff65ed7e25
1 # Macros and functions related to detecting details of the Python environment.
2
3 # Detects a pybind11 package installed in the current python environment
4 # and sets variables to allow it to be found. This allows pybind11 to be
5 # installed via pip, which typically yields a much more recent version than
6 # the OS install, which will be available otherwise.
7 function(mlir_detect_pybind11_install)
8 if(pybind11_DIR)
9 message(STATUS "Using explicit pybind11 cmake directory: ${pybind11_DIR} (-Dpybind11_DIR to change)")
10 else()
11 message(STATUS "Checking for pybind11 in python path...")
12 execute_process(
13 COMMAND "${Python3_EXECUTABLE}"
14 -c "import pybind11;print(pybind11.get_cmake_dir(), end='')"
15 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
16 RESULT_VARIABLE STATUS
17 OUTPUT_VARIABLE PACKAGE_DIR
18 ERROR_QUIET)
19 if(NOT STATUS EQUAL "0")
20 message(STATUS "not found (install via 'pip install pybind11' or set pybind11_DIR)")
21 return()
22 endif()
23 message(STATUS "found (${PACKAGE_DIR})")
24 set(pybind11_DIR "${PACKAGE_DIR}" PARENT_SCOPE)
25 endif()
26 endfunction()