Turn on IREE_BUILD_TORCH_MLIR_SUPPORT for standalone compiler-api build
Also fix the format.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c03fa1..261b43e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -451,7 +451,7 @@
# Add default external projects.
iree_add_llvm_external_project(mlir-iree-dialects MLIR_IREE_DIALECTS ${CMAKE_CURRENT_SOURCE_DIR}/llvm-external-projects/iree-dialects)
iree_add_llvm_external_project(mlir-hlo MLIR_HLO ${CMAKE_CURRENT_SOURCE_DIR}/third_party/mlir-hlo)
- if(${IREE_BUILD_TORCH_MLIR_SUPPORT})
+ if(IREE_BUILD_TORCH_MLIR_SUPPORT)
iree_add_llvm_external_project(torch-mlir-dialects TORCH_MLIR_DIALECTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/torch-mlir-dialects)
endif()
diff --git a/iree/compiler/InputConversion/TMTensor/BUILD b/iree/compiler/InputConversion/TMTensor/BUILD
index 7760a2e..7f030a4 100644
--- a/iree/compiler/InputConversion/TMTensor/BUILD
+++ b/iree/compiler/InputConversion/TMTensor/BUILD
@@ -15,7 +15,7 @@
iree_cmake_extra_content(
content = """
-if(NOT "${IREE_BUILD_TORCH_MLIR_SUPPORT}")
+if(NOT IREE_BUILD_TORCH_MLIR_SUPPORT)
iree_cc_library(
NAME TMTensor
)
diff --git a/iree/compiler/InputConversion/TMTensor/CMakeLists.txt b/iree/compiler/InputConversion/TMTensor/CMakeLists.txt
index 472853c..ae721c4 100644
--- a/iree/compiler/InputConversion/TMTensor/CMakeLists.txt
+++ b/iree/compiler/InputConversion/TMTensor/CMakeLists.txt
@@ -8,7 +8,7 @@
# To disable autogeneration for this file entirely, delete this header. #
################################################################################
-if(NOT "${IREE_BUILD_TORCH_MLIR_SUPPORT}")
+if(NOT IREE_BUILD_TORCH_MLIR_SUPPORT)
iree_cc_library(
NAME TMTensor
)
diff --git a/iree/compiler/InputConversion/TMTensor/test/BUILD b/iree/compiler/InputConversion/TMTensor/test/BUILD
index 1c4a38a..22a6384 100644
--- a/iree/compiler/InputConversion/TMTensor/test/BUILD
+++ b/iree/compiler/InputConversion/TMTensor/test/BUILD
@@ -18,7 +18,7 @@
iree_cmake_extra_content(
content = """
-if(NOT "${IREE_BUILD_TORCH_MLIR_SUPPORT}")
+if(NOT IREE_BUILD_TORCH_MLIR_SUPPORT)
return()
endif()
""",
diff --git a/iree/compiler/InputConversion/TMTensor/test/CMakeLists.txt b/iree/compiler/InputConversion/TMTensor/test/CMakeLists.txt
index 1586cdf..712b3a1 100644
--- a/iree/compiler/InputConversion/TMTensor/test/CMakeLists.txt
+++ b/iree/compiler/InputConversion/TMTensor/test/CMakeLists.txt
@@ -8,7 +8,7 @@
# To disable autogeneration for this file entirely, delete this header. #
################################################################################
-if(NOT "${IREE_BUILD_TORCH_MLIR_SUPPORT}")
+if(NOT IREE_BUILD_TORCH_MLIR_SUPPORT)
return()
endif()
diff --git a/iree/tools/CMakeLists.txt b/iree/tools/CMakeLists.txt
index 6c3acca..f69891c 100644
--- a/iree/tools/CMakeLists.txt
+++ b/iree/tools/CMakeLists.txt
@@ -302,7 +302,7 @@
PUBLIC
)
- if(${IREE_BUILD_TORCH_MLIR_SUPPORT})
+ if(IREE_BUILD_TORCH_MLIR_SUPPORT)
set(_OPTIONAL_INIT_TORCH_MLIR_DIALECT_LIB ::init_torch_mlir_dialects)
endif()
@@ -369,7 +369,7 @@
PUBLIC
)
- if(${IREE_BUILD_TORCH_MLIR_SUPPORT})
+ if(IREE_BUILD_TORCH_MLIR_SUPPORT)
iree_cc_library(
NAME
init_torch_mlir_dialects
diff --git a/llvm-external-projects/iree-compiler-api/CMakeLists.txt b/llvm-external-projects/iree-compiler-api/CMakeLists.txt
index 86cdf40..8d475b9 100644
--- a/llvm-external-projects/iree-compiler-api/CMakeLists.txt
+++ b/llvm-external-projects/iree-compiler-api/CMakeLists.txt
@@ -42,7 +42,8 @@
set(LLVM_MAIN_SRC_DIR "${IREE_COMPILER_API_SOURCE_DIR}/../../third_party/llvm-project/llvm")
set(LLVM_MAIN_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/llvm")
set(LLVM_EXTERNAL_MLIR_HLO_SOURCE_DIR "${IREE_COMPILER_API_SOURCE_DIR}/../../third_party/mlir-hlo")
- if(${IREE_BUILD_TORCH_MLIR_SUPPORT})
+ option(IREE_BUILD_TORCH_MLIR_SUPPORT "Builds support for compiling torch-mlir programs." ON)
+ if(IREE_BUILD_TORCH_MLIR_SUPPORT)
set(LLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR "${IREE_COMPILER_API_SOURCE_DIR}/../../third_party/torch-mlir-dialects")
endif()
# Resources generated on windows must have valid version numbers.
@@ -103,7 +104,7 @@
add_system_include_hack(${LLVM_MAIN_BINARY_DIR}/tools/iree-dialects/include)
add_system_include_hack(${LLVM_EXTERNAL_MLIR_HLO_SOURCE_DIR}/include)
add_system_include_hack(${LLVM_MAIN_BINARY_DIR}/tools/mlir-hlo/include)
-if(${IREE_BUILD_TORCH_MLIR_SUPPORT})
+if(IREE_BUILD_TORCH_MLIR_SUPPORT)
add_system_include_hack(${LLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR}/include)
add_system_include_hack(${LLVM_MAIN_BINARY_DIR}/tools/torch-mlir-dialects/include)
endif()
@@ -131,7 +132,7 @@
iree_set_llvm_cmake_options()
iree_add_llvm_external_project(mlir-iree-dialects MLIR_IREE_DIALECTS ${LLVM_EXTERNAL_MLIR_IREE_DIALECTS_SOURCE_DIR})
iree_add_llvm_external_project(mlir-hlo MLIR_HLO ${LLVM_EXTERNAL_MLIR_HLO_SOURCE_DIR})
- if(${IREE_BUILD_TORCH_MLIR_SUPPORT})
+ if(IREE_BUILD_TORCH_MLIR_SUPPORT)
iree_add_llvm_external_project(torch-mlir-dialects TORCH_MLIR_DIALECTS ${LLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR})
endif()
set(MLIR_ENABLE_BINDINGS_PYTHON ON)
diff --git a/llvm-external-projects/iree-compiler-api/lib/CAPI/CMakeLists.txt b/llvm-external-projects/iree-compiler-api/lib/CAPI/CMakeLists.txt
index 412ce7a..e257db0 100644
--- a/llvm-external-projects/iree-compiler-api/lib/CAPI/CMakeLists.txt
+++ b/llvm-external-projects/iree-compiler-api/lib/CAPI/CMakeLists.txt
@@ -45,10 +45,10 @@
${_OPTIONAL_LINK_LIBS}
)
-if(${IREE_BUILD_TORCH_MLIR_SUPPORT})
+if(IREE_BUILD_TORCH_MLIR_SUPPORT)
target_compile_definitions(obj.IREECompilerAPICompilerCAPI
PUBLIC
- -DIREE_HAVE_TORCH_MLIR_DIALECTS=1
+ IREE_HAVE_TORCH_MLIR_DIALECTS
)
endif()