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(CLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang) 5 set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}") 6 7 get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS) 8 export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake) 9 10 # Generate ClangConfig.cmake for the build tree. 11 set(CLANG_CONFIG_CMAKE_DIR "${clang_cmake_builddir}") 12 set(CLANG_CONFIG_EXPORTS_FILE "${clang_cmake_builddir}/ClangTargets.cmake") 13 configure_file( 14 ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in 15 ${clang_cmake_builddir}/ClangConfig.cmake 16 @ONLY) 17 set(CLANG_CONFIG_CMAKE_DIR) 18 set(CLANG_CONFIG_EXPORTS_FILE) 19 20 # Generate ClangConfig.cmake for the install tree. 21 set(CLANG_CONFIG_CODE " 22 # Compute the installation prefix from this LLVMConfig.cmake file location. 23 get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") 24 # Construct the proper number of get_filename_component(... PATH) 25 # calls to compute the installation prefix. 26 string(REGEX REPLACE "/" ";" _count "${CLANG_INSTALL_PACKAGE_DIR}") 27 foreach(p ${_count}) 28 set(CLANG_CONFIG_CODE "${CLANG_CONFIG_CODE} 29 get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" PATH)") 30 endforeach(p) 31 set(CLANG_CONFIG_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${CLANG_INSTALL_PACKAGE_DIR}") 32 set(CLANG_CONFIG_EXPORTS_FILE "\${CLANG_CMAKE_DIR}/ClangTargets.cmake") 33 configure_file( 34 ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in 35 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake 36 @ONLY) 37 set(CLANG_CONFIG_CODE) 38 set(CLANG_CONFIG_CMAKE_DIR) 39 set(CLANG_CONFIG_EXPORTS_FILE) 40 41 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) 42 install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}) 43 44 install(FILES 45 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake 46 DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}) 47 endif() 48