1set(LLVM_INSTALL_PACKAGE_DIR share/llvm/cmake) 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_ENABLE_ASSERTIONS \"${LLVM_ENABLE_ASSERTIONS}\") 21set(LLVM_BUILD_LIBRARY_DIR \"${LLVM_LIBRARY_DIR}\") 22set(LLVM_BUILD_MAIN_INCLUDE_DIR \"${LLVM_MAIN_INCLUDE_DIR}\") 23set(LLVM_BUILD_MAIN_SRC_DIR \"${LLVM_MAIN_SRC_DIR}\") 24set(LLVM_BUILD_TOOLS_BINARY_DIR \"${LLVM_TOOLS_BINARY_DIR}\") 25") 26set(LLVM_CONFIG_INCLUDE_DIRS 27 "${LLVM_MAIN_INCLUDE_DIR}" 28 "${LLVM_INCLUDE_DIR}" 29 ) 30set(LLVM_CONFIG_LIBRARY_DIRS 31 "${LLVM_LIBRARY_DIR}" 32 ) 33set(LLVM_CONFIG_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_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") 63set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") 64set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake") 65configure_file( 66 LLVMConfig.cmake.in 67 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake 68 @ONLY) 69 70# Generate LLVMConfigVersion.cmake for build and install tree. 71configure_file( 72 LLVMConfigVersion.cmake.in 73 ${llvm_cmake_builddir}/LLVMConfigVersion.cmake 74 @ONLY) 75 76if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) 77 install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}) 78 79 install(FILES 80 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake 81 ${llvm_cmake_builddir}/LLVMConfigVersion.cmake 82 LLVM-Config.cmake 83 DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}) 84 85 install(DIRECTORY . 86 DESTINATION ${LLVM_INSTALL_PACKAGE_DIR} 87 FILES_MATCHING PATTERN *.cmake 88 PATTERN .svn EXCLUDE 89 PATTERN LLVMConfig.cmake EXCLUDE 90 PATTERN LLVMConfigVersion.cmake EXCLUDE 91 PATTERN LLVM-Config.cmake EXCLUDE 92 PATTERN GetHostTriple.cmake EXCLUDE 93 PATTERN VersionFromVCS.cmake EXCLUDE 94 PATTERN CheckAtomic.cmake EXCLUDE) 95endif() 96