1 set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm) 2 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") 3 4 get_property(LLVM_EXPORTS GLOBAL PROPERTY LLVM_EXPORTS) 5 export(TARGETS ${LLVM_EXPORTS} 6 FILE ${llvm_cmake_builddir}/LLVMExports.cmake) 7 8 get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS) 9 10 foreach(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})") 14 endforeach(lib) 15 16 # Generate LLVMConfig.cmake for the build tree. 17 set(LLVM_CONFIG_CODE " 18 # LLVM_BUILD_* values available only from LLVM build tree. 19 set(LLVM_BUILD_BINARY_DIR \"${LLVM_BINARY_DIR}\") 20 set(LLVM_BUILD_LIBRARY_DIR \"${LLVM_LIBRARY_DIR}\") 21 set(LLVM_BUILD_MAIN_INCLUDE_DIR \"${LLVM_MAIN_INCLUDE_DIR}\") 22 set(LLVM_BUILD_MAIN_SRC_DIR \"${LLVM_MAIN_SRC_DIR}\") 23 ") 24 set(LLVM_CONFIG_INCLUDE_DIRS 25 "${LLVM_MAIN_INCLUDE_DIR}" 26 "${LLVM_INCLUDE_DIR}" 27 ) 28 set(LLVM_CONFIG_LIBRARY_DIRS 29 "${LLVM_LIBRARY_DIR}" 30 ) 31 set(LLVM_CONFIG_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 32 set(LLVM_CONFIG_BINARY_DIR "${LLVM_BINARY_DIR}") 33 set(LLVM_CONFIG_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}") 34 set(LLVM_CONFIG_EXPORTS_FILE "${llvm_cmake_builddir}/LLVMExports.cmake") 35 configure_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. 43 file(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. 51 set(LLVM_CONFIG_CODE " 52 # Compute the installation prefix from this LLVMConfig.cmake file location. 53 get_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. 56 string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}") 57 foreach(p ${_count}) 58 set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE} 59 get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)") 60 endforeach(p) 61 set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include") 62 set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}") 63 set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") 64 set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}") 65 set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin") 66 set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake") 67 configure_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. 73 configure_file( 74 LLVMConfigVersion.cmake.in 75 ${llvm_cmake_builddir}/LLVMConfigVersion.cmake 76 @ONLY) 77 78 if (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) 96 endif() 97