Home | History | Annotate | Download | only in modules
      1 set(LLVM_INSTALL_PACKAGE_DIR share/llvm/cmake)
      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_TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
     33 set(LLVM_CONFIG_EXPORTS_FILE "${llvm_cmake_builddir}/LLVMExports.cmake")
     34 configure_file(
     35   LLVMConfig.cmake.in
     36   ${llvm_cmake_builddir}/LLVMConfig.cmake
     37   @ONLY)
     38 
     39 # For compatibility with projects that include(LLVMConfig)
     40 # via CMAKE_MODULE_PATH, place API modules next to it.
     41 # This should be removed in the future.
     42 file(COPY .
     43   DESTINATION ${llvm_cmake_builddir}
     44   FILES_MATCHING PATTERN *.cmake
     45   PATTERN .svn EXCLUDE
     46   PATTERN CMakeFiles EXCLUDE
     47   )
     48 
     49 # Generate LLVMConfig.cmake for the install tree.
     50 set(LLVM_CONFIG_CODE "
     51 # Compute the installation prefix from this LLVMConfig.cmake file location.
     52 get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
     53 # Construct the proper number of get_filename_component(... PATH)
     54 # calls to compute the installation prefix.
     55 string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}")
     56 foreach(p ${_count})
     57   set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
     58 get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
     59 endforeach(p)
     60 set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
     61 set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}")
     62 set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
     63 set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin")
     64 set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake")
     65 configure_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.
     71 configure_file(
     72   LLVMConfigVersion.cmake.in
     73   ${llvm_cmake_builddir}/LLVMConfigVersion.cmake
     74   @ONLY)
     75 
     76 if (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)
     95 endif()
     96