annotate mlir/cmake/modules/CMakeLists.txt @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children 0572611fdcc8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 # Generate a list of CMake library targets so that other CMake projects can
anatofuz
parents:
diff changeset
2 # link against them. LLVM calls its version of this file LLVMExports.cmake, but
anatofuz
parents:
diff changeset
3 # the usual CMake convention seems to be ${Project}Targets.cmake.
anatofuz
parents:
diff changeset
4 set(MLIR_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
anatofuz
parents:
diff changeset
5 set(mlir_cmake_builddir "${CMAKE_BINARY_DIR}/${MLIR_INSTALL_PACKAGE_DIR}")
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 # Keep this in sync with llvm/cmake/CMakeLists.txt!
anatofuz
parents:
diff changeset
8 set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
anatofuz
parents:
diff changeset
9 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 get_property(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS)
anatofuz
parents:
diff changeset
12 export(TARGETS ${MLIR_EXPORTS} FILE ${mlir_cmake_builddir}/MlirTargets.cmake)
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 # Generate MlirConfig.cmake for the build tree.
anatofuz
parents:
diff changeset
15 set(MLIR_CONFIG_CMAKE_DIR "${mlir_cmake_builddir}")
anatofuz
parents:
diff changeset
16 set(MLIR_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
anatofuz
parents:
diff changeset
17 set(MLIR_CONFIG_EXPORTS_FILE "${mlir_cmake_builddir}/MlirTargets.cmake")
anatofuz
parents:
diff changeset
18 set(MLIR_CONFIG_INCLUDE_DIRS
anatofuz
parents:
diff changeset
19 "${MLIR_SOURCE_DIR}/include"
anatofuz
parents:
diff changeset
20 "${MLIR_BINARY_DIR}/include"
anatofuz
parents:
diff changeset
21 )
anatofuz
parents:
diff changeset
22 set(MLIR_CONFIG_CMAKE_DIR)
anatofuz
parents:
diff changeset
23 set(MLIR_CONFIG_LLVM_CMAKE_DIR)
anatofuz
parents:
diff changeset
24 set(MLIR_CONFIG_EXPORTS_FILE)
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 # Generate MlirConfig.cmake for the install tree.
anatofuz
parents:
diff changeset
27 set(MLIR_CONFIG_CODE "
anatofuz
parents:
diff changeset
28 # Compute the installation prefix from this LLVMConfig.cmake file location.
anatofuz
parents:
diff changeset
29 get_filename_component(MLIR_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
anatofuz
parents:
diff changeset
30 # Construct the proper number of get_filename_component(... PATH)
anatofuz
parents:
diff changeset
31 # calls to compute the installation prefix.
anatofuz
parents:
diff changeset
32 string(REGEX REPLACE "/" ";" _count "${MLIR_INSTALL_PACKAGE_DIR}")
anatofuz
parents:
diff changeset
33 foreach(p ${_count})
anatofuz
parents:
diff changeset
34 set(MLIR_CONFIG_CODE "${MLIR_CONFIG_CODE}
anatofuz
parents:
diff changeset
35 get_filename_component(MLIR_INSTALL_PREFIX \"\${MLIR_INSTALL_PREFIX}\" PATH)")
anatofuz
parents:
diff changeset
36 endforeach(p)
anatofuz
parents:
diff changeset
37 set(MLIR_CONFIG_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${MLIR_INSTALL_PACKAGE_DIR}")
anatofuz
parents:
diff changeset
38 set(MLIR_CONFIG_LLVM_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
anatofuz
parents:
diff changeset
39 set(MLIR_CONFIG_EXPORTS_FILE "\${MLIR_CMAKE_DIR}/MlirTargets.cmake")
anatofuz
parents:
diff changeset
40 set(MLIR_CONFIG_INCLUDE_DIRS
anatofuz
parents:
diff changeset
41 "\${MLIR_INSTALL_PREFIX}/include"
anatofuz
parents:
diff changeset
42 )
anatofuz
parents:
diff changeset
43 set(MLIR_CONFIG_CODE)
anatofuz
parents:
diff changeset
44 set(MLIR_CONFIG_CMAKE_DIR)
anatofuz
parents:
diff changeset
45 set(MLIR_CONFIG_EXPORTS_FILE)
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
anatofuz
parents:
diff changeset
48 # Not TOOLCHAIN ONLY, so install the MLIR parts as well
anatofuz
parents:
diff changeset
49 # Include the cmake files so other tools can use mlir-tblgen, etc.
anatofuz
parents:
diff changeset
50 get_property(mlir_has_exports GLOBAL PROPERTY MLIR_HAS_EXPORTS)
anatofuz
parents:
diff changeset
51 if(mlir_has_exports)
anatofuz
parents:
diff changeset
52 install(EXPORT MlirTargets DESTINATION ${MLIR_INSTALL_PACKAGE_DIR}
anatofuz
parents:
diff changeset
53 COMPONENT mlir-cmake-exports)
anatofuz
parents:
diff changeset
54 endif()
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 install(FILES #${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MlirConfig.cmake
anatofuz
parents:
diff changeset
57 ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIR.cmake
anatofuz
parents:
diff changeset
58 DESTINATION ${MLIR_INSTALL_PACKAGE_DIR}
anatofuz
parents:
diff changeset
59 COMPONENT mlir-cmake-exports)
anatofuz
parents:
diff changeset
60
anatofuz
parents:
diff changeset
61 if(NOT LLVM_ENABLE_IDE)
anatofuz
parents:
diff changeset
62 # Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
anatofuz
parents:
diff changeset
63 add_custom_target(mlir-cmake-exports)
anatofuz
parents:
diff changeset
64 add_llvm_install_targets(install-mlir-cmake-exports
anatofuz
parents:
diff changeset
65 COMPONENT mlir-cmake-exports)
anatofuz
parents:
diff changeset
66 endif()
anatofuz
parents:
diff changeset
67 endif()