Mercurial > hg > CbC > CbC_llvm
diff mlir/cmake/modules/MLIRDetectPythonEnv.cmake @ 236:c4bab56944e8 llvm-original
LLVM 16
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:45:10 +0900 |
parents | 79ff65ed7e25 |
children | 1f2b6ac9f198 |
line wrap: on
line diff
--- a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake Wed Jul 21 10:27:27 2021 +0900 +++ b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake Wed Nov 09 17:45:10 2022 +0900 @@ -1,5 +1,44 @@ # Macros and functions related to detecting details of the Python environment. +# Finds and configures python packages needed to build MLIR Python bindings. +macro(mlir_configure_python_dev_packages) + if(CMAKE_VERSION VERSION_LESS "3.19.0") + message(SEND_ERROR + "Building MLIR Python bindings is known to rely on CMake features " + "that require at least version 3.19. Recommend upgrading to 3.19+ " + "for full support. Detected current version: ${CMAKE_VERSION}") + endif() + + if(MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH) + # Prime the search for python to see if there is a full development + # package. This seems to work around cmake bugs searching only for + # Development.Module in some environments. However, in other environments + # it may interfere with the subsequent search for Development.Module. + find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} + COMPONENTS Interpreter Development) + endif() + + # After CMake 3.18, we are able to limit the scope of the search to just + # Development.Module. Searching for Development will fail in situations where + # the Python libraries are not available. When possible, limit to just + # Development.Module. + # See https://pybind11.readthedocs.io/en/stable/compiling.html#findpython-mode + set(_python_development_component Development.Module) + + find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} + COMPONENTS Interpreter ${_python_development_component} NumPy REQUIRED) + unset(_python_development_component) + message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}") + message(STATUS "Found python libraries: ${Python3_LIBRARIES}") + message(STATUS "Found numpy v${Python3_NumPy_VERSION}: ${Python3_NumPy_INCLUDE_DIRS}") + mlir_detect_pybind11_install() + find_package(pybind11 2.8 CONFIG REQUIRED) + message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIR}") + message(STATUS "Python prefix = '${PYTHON_MODULE_PREFIX}', " + "suffix = '${PYTHON_MODULE_SUFFIX}', " + "extension = '${PYTHON_MODULE_EXTENSION}") +endmacro() + # Detects a pybind11 package installed in the current python environment # and sets variables to allow it to be found. This allows pybind11 to be # installed via pip, which typically yields a much more recent version than