diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake --- a/mlir/cmake/modules/AddMLIRPython.cmake +++ b/mlir/cmake/modules/AddMLIRPython.cmake @@ -59,7 +59,7 @@ # way to do this: https://gitlab.kitware.com/cmake/cmake/-/issues/19261 # Note that ROOT_DIR and FILE_DEPENDS are not exported because they are # only relevant to in-tree uses. - EXPORT_PROPERTIES "mlir_python_SOURCES_TYPE;mlir_python_DEST_PREFIX;mlir_python_DEST_PREFIX;mlir_python_SOURCES;mlir_python_DEPENDS" + EXPORT_PROPERTIES "mlir_python_SOURCES_TYPE;mlir_python_ROOT_DIR;mlir_python_DEST_PREFIX;mlir_python_SOURCES;mlir_python_DEPENDS" mlir_python_SOURCES_TYPE pure mlir_python_ROOT_DIR "${ARG_ROOT_DIR}" mlir_python_DEST_PREFIX "${ARG_DEST_PREFIX}" @@ -82,6 +82,7 @@ if(ARG_ADD_TO_PARENT) set_property(TARGET ${ARG_ADD_TO_PARENT} APPEND PROPERTY mlir_python_DEPENDS ${name}) endif() + set_property(GLOBAL APPEND PROPERTY MLIR_EXPORTS ${name}) # Install. if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY) @@ -125,7 +126,7 @@ # way to do this: https://gitlab.kitware.com/cmake/cmake/-/issues/19261 # Note that ROOT_DIR and FILE_DEPENDS are not exported because they are # only relevant to in-tree uses. - EXPORT_PROPERTIES "mlir_python_SOURCES_TYPE;mlir_python_EXTENSION_MODULE_NAME;mlir_python_CPP_SOURCES;mlir_python_PRIVATE_LINK_LIBS;mlir_python_EMBED_CAPI_LINK_LIBS;mlir_python_DEPENDS" + EXPORT_PROPERTIES "mlir_python_SOURCES_TYPE;mlir_python_ROOT_DIR;mlir_python_EXTENSION_MODULE_NAME;mlir_python_CPP_SOURCES;mlir_python_PRIVATE_LINK_LIBS;mlir_python_EMBED_CAPI_LINK_LIBS;mlir_python_DEPENDS" mlir_python_SOURCES_TYPE extension mlir_python_ROOT_DIR "${ARG_ROOT_DIR}" mlir_python_EXTENSION_MODULE_NAME "${ARG_MODULE_NAME}" @@ -152,6 +153,7 @@ set_property(TARGET ${ARG_ADD_TO_PARENT} APPEND PROPERTY mlir_python_DEPENDS ${name}) endif() + set_property(GLOBAL APPEND PROPERTY MLIR_EXPORTS ${name}) # Install. if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY) _mlir_python_install_sources( @@ -205,19 +207,9 @@ # Helper to process an individual target. function(_process_target modules_target sources_target) get_target_property(_source_type ${sources_target} mlir_python_SOURCES_TYPE) - - # The root directory differs based on whether it is IMPORTED (installed - # dep). - get_target_property(_is_imported ${sources_target} IMPORTED) - if(NOT _is_imported) - # In-tree. - get_target_property(_python_root_dir ${sources_target} mlir_python_ROOT_DIR) - else() - # Imported. - # Note: We only populate a single directory in - # INTERFACE_INCLUDE_DIRECTORIES, so we can get away with just using it - # as a single value. - get_target_property(_python_root_dir ${sources_target} INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(_python_root_dir ${sources_target} mlir_python_ROOT_DIR) + if(NOT _python_root_dir) + message(FATAL_ERROR " Target ${sources_target} lacks mlir_python_ROOT_DIR property") endif() if(_source_type STREQUAL "pure") diff --git a/mlir/examples/standalone/test/python/smoketest.py b/mlir/examples/standalone/test/python/smoketest.py --- a/mlir/examples/standalone/test/python/smoketest.py +++ b/mlir/examples/standalone/test/python/smoketest.py @@ -9,9 +9,9 @@ with Context(): standalone_d.register_dialect() module = Module.parse(""" - %0 = constant 2 : i32 + %0 = arith.constant 2 : i32 %1 = standalone.foo %0 : i32 """) - # CHECK: %[[C:.*]] = constant 2 : i32 + # CHECK: %[[C:.*]] = arith.constant 2 : i32 # CHECK: standalone.foo %[[C]] : i32 print(str(module)) diff --git a/mlir/test/Examples/standalone/test.toy b/mlir/test/Examples/standalone/test.toy --- a/mlir/test/Examples/standalone/test.toy +++ b/mlir/test/Examples/standalone/test.toy @@ -1,4 +1,4 @@ # RUN: %cmake %mlir_src_root/examples/standalone -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR=%mlir_cmake_dir ; %cmake --build . --target check-standalone | tee %t | FileCheck %s -# CHECK: Passed: 4 +# CHECK: Passed: 5 # UNSUPPORTED: windows, android