[Mlir-commits] [mlir] 23dc948 - [MLIR] Use `MLIR_INCLUDE_TESTS` to conditionally compile tests.

Alex Zinenko llvmlistbot at llvm.org
Mon May 18 09:47:45 PDT 2020


Author: Alexandre Rames
Date: 2020-05-18T18:47:37+02:00
New Revision: 23dc948d362018a8257d8288fe9beb0d27fc9b35

URL: https://github.com/llvm/llvm-project/commit/23dc948d362018a8257d8288fe9beb0d27fc9b35
DIFF: https://github.com/llvm/llvm-project/commit/23dc948d362018a8257d8288fe9beb0d27fc9b35.diff

LOG: [MLIR] Use `MLIR_INCLUDE_TESTS` to conditionally compile tests.

This is equivalent to what is done for other projects (e.g. clang).

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

Added: 
    

Modified: 
    mlir/CMakeLists.txt
    mlir/tools/mlir-opt/CMakeLists.txt
    mlir/tools/mlir-opt/mlir-opt.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 3671a97395d4..7c2c5978c44e 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -34,6 +34,10 @@ add_definitions(-DMLIR_CUDA_CONVERSIONS_ENABLED=${MLIR_CUDA_CONVERSIONS_ENABLED}
 set(MLIR_CUDA_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir CUDA runner")
 set(MLIR_VULKAN_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir Vulkan runner")
 
+option(MLIR_INCLUDE_TESTS
+       "Generate build targets for the MLIR unit tests."
+       ${LLVM_INCLUDE_TESTS})
+
 include_directories( "include")
 include_directories( ${MLIR_INCLUDE_DIR})
 
@@ -44,8 +48,11 @@ add_subdirectory(tools/mlir-tblgen)
 
 add_subdirectory(include/mlir)
 add_subdirectory(lib)
-add_subdirectory(unittests)
-add_subdirectory(test)
+if (MLIR_INCLUDE_TESTS)
+  add_definitions(-DMLIR_INCLUDE_TESTS)
+  add_subdirectory(unittests)
+  add_subdirectory(test)
+endif()
 # Tools needs to come late to ensure that MLIR_ALL_LIBS is populated.
 # Generally things after this point may depend on MLIR_ALL_LIBS or libMLIR.so.
 add_subdirectory(tools)

diff  --git a/mlir/tools/mlir-opt/CMakeLists.txt b/mlir/tools/mlir-opt/CMakeLists.txt
index 3e8ed0ebee7b..d509b23505d1 100644
--- a/mlir/tools/mlir-opt/CMakeLists.txt
+++ b/mlir/tools/mlir-opt/CMakeLists.txt
@@ -10,24 +10,30 @@ set(LLVM_LINK_COMPONENTS
   AsmParser
   )
 
+if(MLIR_INCLUDE_TESTS)
+  set(test_libs
+    MLIRAffineTransformsTestPasses
+    MLIRSPIRVTestPasses
+    MLIRTestDialect
+    MLIRTestIR
+    MLIRTestPass
+    MLIRTestTransforms
+    )
+endif()
+
 set(LIBS
   ${dialect_libs}
   ${conversion_libs}
+  ${test_libs}
   MLIRLoopAnalysis
-  MLIRAffineTransformsTestPasses
   MLIRAnalysis
   MLIRDialect
   MLIREDSC
   MLIROptLib
   MLIRParser
   MLIRPass
-  MLIRSPIRVTestPasses
   MLIRTransforms
   MLIRTransformUtils
-  MLIRTestDialect
-  MLIRTestIR
-  MLIRTestPass
-  MLIRTestTransforms
   MLIRSupport
   MLIRIR
   )

diff  --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp
index 218d6c03b4b8..69b1d8d57bc5 100644
--- a/mlir/tools/mlir-opt/mlir-opt.cpp
+++ b/mlir/tools/mlir-opt/mlir-opt.cpp
@@ -93,6 +93,7 @@ static cl::opt<bool> allowUnregisteredDialects(
     "allow-unregistered-dialect",
     cl::desc("Allow operation with no registered dialects"), cl::init(false));
 
+#ifdef MLIR_INCLUDE_TESTS
 void registerTestPasses() {
   registerConvertToTargetEnvPass();
   registerInliner();
@@ -131,6 +132,7 @@ void registerTestPasses() {
   registerTestVectorToSCFPass();
   registerVectorizerTestPass();
 }
+#endif
 
 static cl::opt<bool>
     showDialects("show-dialects",
@@ -140,7 +142,9 @@ static cl::opt<bool>
 int main(int argc, char **argv) {
   registerAllDialects();
   registerAllPasses();
+#ifdef MLIR_INCLUDE_TESTS
   registerTestPasses();
+#endif
   InitLLVM y(argc, argv);
 
   // Register any command line options.


        


More information about the Mlir-commits mailing list