PR #44589: Introduce MHLO_BUILD_EMBEDDED build option

Imported from GitHub PR https://github.com/tensorflow/tensorflow/pull/44589

This option allows to skip calling `find_package(MLIR)`, enabling to
embed MHLO into other project, e.g. IREE.
Copybara import of the project:

--
715299e594c95ce9d4f45dc154ba8a4acb196289 by Marius Brehler <marius.brehler@iml.fraunhofer.de>:

Introduce MHLO_BUILD_EMBEDDED build option

This option allows to skip calling `find_package(MLIR)`, enabling to
embed MHLO into other project, e.g. IREE.

--
6a9cd1adb69dfd27e4306566085c2edcb9e266bf by Marius Brehler <marius.brehler@iml.fraunhofer.de>:

Update tensorflow/compiler/mlir/hlo/CMakeLists.txt

Co-authored-by: Geoffrey Martin-Noble <gcmn@google.com>
PiperOrigin-RevId: 341046504
This commit is contained in:
Marius Brehler 2020-11-06 07:37:05 -08:00 committed by TensorFlow MLIR Team
parent af4c9774dc
commit f09db1fea0
1 changed files with 12 additions and 5 deletions

View File

@ -41,6 +41,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# Options and settings # Options and settings
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
option(MHLO_BUILD_EMBEDDED "Build MHLO as part of another project" OFF)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# MSVC defaults # MSVC defaults
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -57,11 +59,16 @@ endif()
# MLIR/LLVM Configuration # MLIR/LLVM Configuration
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
find_package(MLIR REQUIRED CONFIG) # Find MLIR to install if we are building standalone. If building as part of
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}") # another project, let it handle the MLIR dependency. The dependent project
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") # might use a bundled version of MLIR instead of installing, for instance.
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}") if(NOT MHLO_BUILD_EMBEDDED)
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") find_package(MLIR REQUIRED CONFIG)
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
endif()
if(LLVM_ENABLE_ZLIB) if(LLVM_ENABLE_ZLIB)
find_package(ZLIB) find_package(ZLIB)