[MLIR] Fix Standalone dialect test to work in out-of-tree builds
authorKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Wed, 2 Jun 2021 17:21:17 +0000 (17:21 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Wed, 2 Jun 2021 17:24:46 +0000 (17:24 +0000)
When LLVM and MLIR are built as subprojects (via add_subdirectory),
the CMake configuration that indicates where the MLIR libraries are is
not necessarily in the same cmake/ directory as LLVM's configuration.
This patch removes that assumption about where MLIRConfig.cmake is
located.

(As an additional none, the %llvm_lib_dir substitution was never
defined, and so find_package(MLIR) in the build was succeeding for
other reasons.)

Reviewed By: stephenneuendorffer

Differential Revision: https://reviews.llvm.org/D103276

mlir/test/CMakeLists.txt
mlir/test/Examples/standalone/lit.local.cfg
mlir/test/Examples/standalone/test.toy
mlir/test/lit.site.cfg.py.in

index fabcf7a..5ae61e9 100644 (file)
@@ -17,6 +17,11 @@ llvm_canonicalize_cmake_booleans(
   MLIR_ENABLE_VULKAN_RUNNER
   )
 
+# Passed to lit.site.cfg.py.so that the out of tree Standalone dialect test
+# can find MLIR's CMake configuration
+set(MLIR_CMAKE_DIR
+  "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir")
+
 # Passed to lit.site.cfg.py.in to set up the path where to find the libraries
 # for linalg integration tests.
 set(MLIR_DIALECT_LINALG_INTEGRATION_TEST_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
index 1744d78..2ec53bd 100644 (file)
@@ -2,3 +2,5 @@ config.substitutions.append(("%cmake", config.host_cmake))
 config.substitutions.append(("%host_cxx", config.host_cxx))
 config.substitutions.append(("%host_cc", config.host_cc))
 config.substitutions.append(("%enable_libcxx", config.enable_libcxx))
+config.substitutions.append(
+    ("%mlir_cmake_dir", config.mlir_cmake_dir))
index 0f9d0cc..dd22e45 100644 (file)
@@ -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=%llvm_lib_dir/cmake/mlir ; %cmake --build . --target check-standalone | tee %t | FileCheck %s
+# 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: 3
 # UNSUPPORTED: windows, android
index dbf5eec..06d6e73 100644 (file)
@@ -34,6 +34,7 @@ config.mlir_src_root = "@MLIR_SOURCE_DIR@"
 config.mlir_obj_root = "@MLIR_BINARY_DIR@"
 config.mlir_runner_utils_dir = "@MLIR_RUNNER_UTILS_DIR@"
 config.mlir_tools_dir = "@MLIR_TOOLS_DIR@"
+config.mlir_cmake_dir = "@MLIR_CMAKE_DIR@"
 config.linalg_test_lib_dir = "@MLIR_DIALECT_LINALG_INTEGRATION_TEST_LIB_DIR@"
 config.build_examples = @LLVM_BUILD_EXAMPLES@
 config.run_cuda_tests = @MLIR_ENABLE_CUDA_CONVERSIONS@