[llvm] [mlir] [MLIR][Python] use `FetchContent_Declare` for nanobind and remove pybind (PR #161230)
Konrad Kleine via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 7 00:40:17 PDT 2025
kwk wrote:
Can you please change the logic to be `find_package` first and only if it doesn't find nanobind, you fetch use `FetchContent`? Simply get rid of the `REQUIRED` option to `find_package`.
```
cmake_minimum_required(VERSION 3.31)
project(myproject)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
# See this for how to find nanobind:
# https://nanobind.readthedocs.io/en/latest/building.html#finding-nanobind
execute_process(
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE nanobind_ROOT)
find_package(nanobind 2.9 CONFIG)
message(STATUS "nanobind_DIR: ${nanobind_DIR}")
if (${nanobind_DIR} STREQUAL "nanobind_DIR-NOTFOUND")
message(STATUS "nanobind not found Use FetchContent")
else()
message(STATUS "nanobind found")
endif()
```
https://github.com/llvm/llvm-project/pull/161230
More information about the llvm-commits
mailing list