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