-
Notifications
You must be signed in to change notification settings - Fork 68
/
CMakeLists.txt
64 lines (58 loc) · 2.67 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Generate a list of CMake library targets so that other CMake projects can
# link against them. LLVM calls its version of this file LLVMExports.cmake, but
# the usual CMake convention is ${Project}Targets.cmake.
# This configuration has been partly adapted from MLIR project's
# (llvm-project:mlir/cmake/modules).
include(LLVMDistributionSupport)
set(MHLO_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir-hlo)
set(mhlo_cmake_builddir "${CMAKE_BINARY_DIR}/${MHLO_INSTALL_PACKAGE_DIR}")
# Keep this in sync with llvm/cmake/CMakeLists.txt!
set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
# Since we just use MLIR's cmake functions (add_mlir_library, etc.),
# MLIR_EXPORTS would have the necessary targets to export.
get_property(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS)
export(TARGETS ${MLIR_EXPORTS} FILE ${mhlo_cmake_builddir}/MHLOTargets.cmake)
# Generate MlirConfig.cmake for the build tree.
set(MHLO_CONFIG_CMAKE_DIR "${mhlo_cmake_builddir}")
set(MHLO_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
set(MHLO_CONFIG_INCLUDE_EXPORTS "include(\"\${MHLO_CMAKE_DIR}/MHLOTargets.cmake\")")
set(MHLO_CONFIG_INCLUDE_DIRS
"${MLIR_HLO_SOURCE_DIR}"
"${MLIR_HLO_MAIN_INCLUDE_DIR}"
"${MLIR_HLO_GEN_INCLUDE_DIR}"
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/MHLOConfig.cmake.in
${mhlo_cmake_builddir}/MHLOConfig.cmake
@ONLY)
# Unset the variables now that the file is configured.
set(MHLO_CONFIG_CMAKE_DIR)
set(MHLO_CONFIG_LLVM_CMAKE_DIR)
set(MHLO_CONFIG_INCLUDE_DIRS)
# Generate MHLOConfig.cmake for the install tree.
set(MHLO_CONFIG_CODE "
# Compute the installation prefix from this MHLOConfig.cmake file location.
get_filename_component(MHLO_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
# Construct the proper number of get_filename_component(... PATH)
# calls to compute the installation prefix.
string(REGEX REPLACE "/" ";" _count "${MHLO_INSTALL_PACKAGE_DIR}")
foreach(p ${_count})
set(MHLO_CONFIG_CODE "${MHLO_CONFIG_CODE}
get_filename_component(MHLO_INSTALL_PREFIX \"\${MHLO_INSTALL_PREFIX}\" PATH)")
endforeach(p)
set(MHLO_CONFIG_CMAKE_DIR "\${MHLO_INSTALL_PREFIX}/${MHLO_INSTALL_PACKAGE_DIR}")
set(MHLO_CONFIG_LLVM_CMAKE_DIR "\${MHLO_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
get_config_exports_includes(MHLO MHLO_CONFIG_INCLUDE_EXPORTS)
set(MHLO_CONFIG_INCLUDE_DIRS
"\${MHLO_INSTALL_PREFIX}"
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/MHLOConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MHLOConfig.cmake
@ONLY)
# Unset the variables now that the file is configured.
set(MHLO_CONFIG_CODE)
set(MHLO_CONFIG_CMAKE_DIR)
set(MHLO_CONFIG_LLVM_CMAKE_DIR)
set(MHLO_CONFIG_INCLUDE_DIRS)