@@ -895,24 +895,8 @@ add_mlir_python_common_capi_library(MLIRPythonCAPI
895895################################################################################
896896
897897_flatten_mlir_python_targets(mlir_python_sources_deps MLIRPythonSources)
898- add_custom_target ("mlir-python-sources" DEPENDS ${mlir_python_sources_deps} )
899- if (NOT LLVM_ENABLE_IDE)
900- add_llvm_install_targets(install -mlir-python-sources
901- DEPENDS mlir-python-sources
902- COMPONENT mlir-python-sources
903- )
904- endif ()
905-
906- set (_mlir_python_stubgen_enabled ON )
907- # Stubgen doesn't work when cross-compiling (stubgen will run in the host interpreter and then fail
908- # to find the extension module for the host arch).
909- # Note: Stubgen requires some extra handling to work properly when sanitizers are enabled,
910- # so we skip running it in that case now.
911- if (CMAKE_CROSSCOMPILING OR (NOT LLVM_USE_SANITIZER STREQUAL "" ))
912- set (_mlir_python_stubgen_enabled OFF )
913- endif ()
914898
915- if (_mlir_python_stubgen_enabled )
899+ if (MLIR_PYTHON_STUBGEN_ENABLED )
916900 # _mlir stubgen
917901 # Note: All this needs to come before add_mlir_python_modules(MLIRPythonModules so that the install targets for the
918902 # generated type stubs get created.
@@ -965,6 +949,7 @@ if(_mlir_python_stubgen_enabled)
965949 ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR} /type_stubs"
966950 SOURCES "${_core_type_stub_sources} "
967951 )
952+ list (APPEND mlir_python_sources_deps MLIRPythonExtension.Core.type_stub_gen)
968953
969954 # _mlirPythonTestNanobind stubgen
970955
@@ -995,13 +980,21 @@ if(_mlir_python_stubgen_enabled)
995980 endif ()
996981endif ()
997982
983+ add_custom_target ("mlir-python-sources" DEPENDS ${mlir_python_sources_deps} )
984+ if (NOT LLVM_ENABLE_IDE)
985+ add_llvm_install_targets(install -mlir-python-sources
986+ DEPENDS mlir-python-sources
987+ COMPONENT mlir-python-sources
988+ )
989+ endif ()
990+
998991################################################################################
999992# The fully assembled package of modules.
1000993# This must come last.
1001994################################################################################
1002995
1003996set (_declared_sources MLIRPythonSources MLIRPythonExtension.RegisterEverything)
1004- if (_mlir_python_stubgen_enabled )
997+ if (MLIR_PYTHON_STUBGEN_ENABLED )
1005998 list (APPEND _declared_sources MLIRPythonExtension.Core.type_stub_gen)
1006999endif ()
10071000
@@ -1014,7 +1007,7 @@ add_mlir_python_modules(MLIRPythonModules
10141007 COMMON_CAPI_LINK_LIBS
10151008 MLIRPythonCAPI
10161009)
1017- if (_mlir_python_stubgen_enabled )
1010+ if (MLIR_PYTHON_STUBGEN_ENABLED )
10181011 add_dependencies (MLIRPythonModules "${_mlir_typestub_gen_target} " )
10191012 if (MLIR_INCLUDE_TESTS)
10201013 add_dependencies (MLIRPythonModules "${_mlirPythonTestNanobind_typestub_gen_target} " )
0 commit comments