annotate mlir/cmake/modules/CMakeLists.txt @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 79ff65ed7e25
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
1 include(LLVMDistributionSupport)
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
2
150
anatofuz
parents:
diff changeset
3 # Generate a list of CMake library targets so that other CMake projects can
anatofuz
parents:
diff changeset
4 # link against them. LLVM calls its version of this file LLVMExports.cmake, but
anatofuz
parents:
diff changeset
5 # the usual CMake convention seems to be ${Project}Targets.cmake.
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
6 set(MLIR_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir)
150
anatofuz
parents:
diff changeset
7 set(mlir_cmake_builddir "${CMAKE_BINARY_DIR}/${MLIR_INSTALL_PACKAGE_DIR}")
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 # Keep this in sync with llvm/cmake/CMakeLists.txt!
anatofuz
parents:
diff changeset
10 set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
anatofuz
parents:
diff changeset
11 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 get_property(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS)
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
14 export(TARGETS ${MLIR_EXPORTS} FILE ${mlir_cmake_builddir}/MLIRTargets.cmake)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
15
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
16 get_property(MLIR_ALL_LIBS GLOBAL PROPERTY MLIR_ALL_LIBS)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
17 get_property(MLIR_DIALECT_LIBS GLOBAL PROPERTY MLIR_DIALECT_LIBS)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
18 get_property(MLIR_CONVERSION_LIBS GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
19 get_property(MLIR_TRANSLATION_LIBS GLOBAL PROPERTY MLIR_TRANSLATION_LIBS)
150
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 # Generate MlirConfig.cmake for the build tree.
anatofuz
parents:
diff changeset
22 set(MLIR_CONFIG_CMAKE_DIR "${mlir_cmake_builddir}")
anatofuz
parents:
diff changeset
23 set(MLIR_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
24 set(MLIR_CONFIG_INCLUDE_EXPORTS "include(\"\${MLIR_CMAKE_DIR}/MLIRTargets.cmake\")")
150
anatofuz
parents:
diff changeset
25 set(MLIR_CONFIG_INCLUDE_DIRS
anatofuz
parents:
diff changeset
26 "${MLIR_SOURCE_DIR}/include"
anatofuz
parents:
diff changeset
27 "${MLIR_BINARY_DIR}/include"
anatofuz
parents:
diff changeset
28 )
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
29 configure_file(
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
30 ${CMAKE_CURRENT_SOURCE_DIR}/MLIRConfig.cmake.in
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
31 ${mlir_cmake_builddir}/MLIRConfig.cmake
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
32 @ONLY)
150
anatofuz
parents:
diff changeset
33 set(MLIR_CONFIG_CMAKE_DIR)
anatofuz
parents:
diff changeset
34 set(MLIR_CONFIG_LLVM_CMAKE_DIR)
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
35 set(MLIR_CONFIG_INCLUDE_DIRS)
150
anatofuz
parents:
diff changeset
36
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
37 # For compatibility with projects that include(MLIRConfig)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
38 # via CMAKE_MODULE_PATH, place API modules next to it.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
39 # This should be removed in the future.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
40 file(COPY .
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
41 DESTINATION ${mlir_cmake_builddir}
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
42 FILES_MATCHING PATTERN *.cmake
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
43 PATTERN CMakeFiles EXCLUDE
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
44 )
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
45
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
46 # Generate MLIRConfig.cmake for the install tree.
150
anatofuz
parents:
diff changeset
47 set(MLIR_CONFIG_CODE "
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
48 # Compute the installation prefix from this MLIRConfig.cmake file location.
150
anatofuz
parents:
diff changeset
49 get_filename_component(MLIR_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
anatofuz
parents:
diff changeset
50 # Construct the proper number of get_filename_component(... PATH)
anatofuz
parents:
diff changeset
51 # calls to compute the installation prefix.
anatofuz
parents:
diff changeset
52 string(REGEX REPLACE "/" ";" _count "${MLIR_INSTALL_PACKAGE_DIR}")
anatofuz
parents:
diff changeset
53 foreach(p ${_count})
anatofuz
parents:
diff changeset
54 set(MLIR_CONFIG_CODE "${MLIR_CONFIG_CODE}
anatofuz
parents:
diff changeset
55 get_filename_component(MLIR_INSTALL_PREFIX \"\${MLIR_INSTALL_PREFIX}\" PATH)")
anatofuz
parents:
diff changeset
56 endforeach(p)
anatofuz
parents:
diff changeset
57 set(MLIR_CONFIG_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${MLIR_INSTALL_PACKAGE_DIR}")
anatofuz
parents:
diff changeset
58 set(MLIR_CONFIG_LLVM_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
59 get_config_exports_includes(MLIR MLIR_CONFIG_INCLUDE_EXPORTS)
150
anatofuz
parents:
diff changeset
60 set(MLIR_CONFIG_INCLUDE_DIRS
anatofuz
parents:
diff changeset
61 "\${MLIR_INSTALL_PREFIX}/include"
anatofuz
parents:
diff changeset
62 )
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
63 configure_file(
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
64 ${CMAKE_CURRENT_SOURCE_DIR}/MLIRConfig.cmake.in
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
65 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfig.cmake
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
66 @ONLY)
150
anatofuz
parents:
diff changeset
67 set(MLIR_CONFIG_CODE)
anatofuz
parents:
diff changeset
68 set(MLIR_CONFIG_CMAKE_DIR)
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
69 set(MLIR_CONFIG_LLVM_CMAKE_DIR)
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
70 set(MLIR_CONFIG_INCLUDE_DIRS)
150
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
anatofuz
parents:
diff changeset
73 # Not TOOLCHAIN ONLY, so install the MLIR parts as well
anatofuz
parents:
diff changeset
74 # Include the cmake files so other tools can use mlir-tblgen, etc.
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
75 install_distribution_exports(MLIR)
150
anatofuz
parents:
diff changeset
76
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
77 install(FILES
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
78 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfig.cmake
150
anatofuz
parents:
diff changeset
79 ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIR.cmake
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
80 ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIRPython.cmake
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
81 ${CMAKE_CURRENT_SOURCE_DIR}/MLIRDetectPythonEnv.cmake
150
anatofuz
parents:
diff changeset
82 DESTINATION ${MLIR_INSTALL_PACKAGE_DIR}
anatofuz
parents:
diff changeset
83 COMPONENT mlir-cmake-exports)
anatofuz
parents:
diff changeset
84
anatofuz
parents:
diff changeset
85 if(NOT LLVM_ENABLE_IDE)
anatofuz
parents:
diff changeset
86 # Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
anatofuz
parents:
diff changeset
87 add_custom_target(mlir-cmake-exports)
anatofuz
parents:
diff changeset
88 add_llvm_install_targets(install-mlir-cmake-exports
anatofuz
parents:
diff changeset
89 COMPONENT mlir-cmake-exports)
anatofuz
parents:
diff changeset
90 endif()
anatofuz
parents:
diff changeset
91 endif()