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

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