From 99837df6e3f9be2deed1f7107873bcb86e28246b Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Wed, 22 Jan 2025 11:36:58 -0800 Subject: [PATCH] Skip nanobind configure if MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES is set. --- mlir/cmake/modules/AddMLIRPython.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake index 815f65b106d94..018a81f1ad550 100644 --- a/mlir/cmake/modules/AddMLIRPython.cmake +++ b/mlir/cmake/modules/AddMLIRPython.cmake @@ -672,8 +672,11 @@ function(add_mlir_python_extension libname extname) ${ARG_SOURCES} ) - if (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL) - # Avoids warnings from upstream nanobind. + if (NOT MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES + AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL)) + # Avoid some warnings from upstream nanobind. + # If a superproject set MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES, let + # the super project handle compile options as it wishes. set(nanobind_target "nanobind-static") if (NOT TARGET ${nanobind_target}) # Get correct nanobind target name: nanobind-static-ft or something else @@ -702,7 +705,7 @@ function(add_mlir_python_extension libname extname) ${eh_rtti_enable} ) endif() - + if(APPLE) # NanobindAdaptors.h uses PyClassMethod_New to build `pure_subclass`es but nanobind # doesn't declare this API as undefined in its linker flags. So we need to declare it as such