1set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm) 2set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") 3 4get_property(LLVM_EXPORTS GLOBAL PROPERTY LLVM_EXPORTS) 5export(TARGETS ${LLVM_EXPORTS} 6 FILE ${llvm_cmake_builddir}/LLVMExports.cmake) 7 8get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS) 9 10foreach(lib ${LLVM_AVAILABLE_LIBS}) 11 get_property(llvm_lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib}) 12 set(all_llvm_lib_deps 13 "${all_llvm_lib_deps}\nset_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib} ${llvm_lib_deps})") 14endforeach(lib) 15 16# Generate LLVMConfig.cmake for the build tree. 17set(LLVM_CONFIG_CODE " 18# LLVM_BUILD_* values available only from LLVM build tree. 19set(LLVM_BUILD_BINARY_DIR \"${LLVM_BINARY_DIR}\") 20set(LLVM_BUILD_LIBRARY_DIR \"${LLVM_LIBRARY_DIR}\") 21set(LLVM_BUILD_MAIN_INCLUDE_DIR \"${LLVM_MAIN_INCLUDE_DIR}\") 22set(LLVM_BUILD_MAIN_SRC_DIR \"${LLVM_MAIN_SRC_DIR}\") 23") 24set(LLVM_CONFIG_INCLUDE_DIRS 25 "${LLVM_MAIN_INCLUDE_DIR}" 26 "${LLVM_INCLUDE_DIR}" 27 ) 28set(LLVM_CONFIG_LIBRARY_DIRS 29 "${LLVM_LIBRARY_DIR}" 30 ) 31set(LLVM_CONFIG_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 32set(LLVM_CONFIG_BINARY_DIR "${LLVM_BINARY_DIR}") 33set(LLVM_CONFIG_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") 34set(LLVM_CONFIG_EXPORTS_FILE "${llvm_cmake_builddir}/LLVMExports.cmake") 35configure_file( 36 LLVMConfig.cmake.in 37 ${llvm_cmake_builddir}/LLVMConfig.cmake 38 @ONLY) 39 40# For compatibility with projects that include(LLVMConfig) 41# via CMAKE_MODULE_PATH, place API modules next to it. 42# This should be removed in the future. 43file(COPY . 44 DESTINATION ${llvm_cmake_builddir} 45 FILES_MATCHING PATTERN *.cmake 46 PATTERN .svn EXCLUDE 47 PATTERN CMakeFiles EXCLUDE 48 ) 49 50# Generate LLVMConfig.cmake for the install tree. 51set(LLVM_CONFIG_CODE " 52# Compute the installation prefix from this LLVMConfig.cmake file location. 53get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") 54# Construct the proper number of get_filename_component(... PATH) 55# calls to compute the installation prefix. 56string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}") 57foreach(p ${_count}) 58 set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE} 59get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)") 60endforeach(p) 61set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include") 62set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}") 63set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") 64set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}") 65set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin") 66set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake") 67configure_file( 68 LLVMConfig.cmake.in 69 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake 70 @ONLY) 71 72# Generate LLVMConfigVersion.cmake for build and install tree. 73configure_file( 74 LLVMConfigVersion.cmake.in 75 ${llvm_cmake_builddir}/LLVMConfigVersion.cmake 76 @ONLY) 77 78if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) 79 install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}) 80 81 install(FILES 82 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake 83 ${llvm_cmake_builddir}/LLVMConfigVersion.cmake 84 LLVM-Config.cmake 85 DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}) 86 87 install(DIRECTORY . 88 DESTINATION ${LLVM_INSTALL_PACKAGE_DIR} 89 FILES_MATCHING PATTERN *.cmake 90 PATTERN .svn EXCLUDE 91 PATTERN LLVMConfig.cmake EXCLUDE 92 PATTERN LLVMConfigVersion.cmake EXCLUDE 93 PATTERN LLVM-Config.cmake EXCLUDE 94 PATTERN GetHostTriple.cmake EXCLUDE 95 PATTERN CheckAtomic.cmake EXCLUDE) 96endif() 97