1 include(GNUInstallPackageDir)
3 include(FindPrefixFromConfig)
5 # Generate a list of CMake library targets so that other CMake projects can
6 # link against them. LLVM calls its version of this file LLVMExports.cmake, but
7 # the usual CMake convention seems to be ${Project}Targets.cmake.
8 set(FLANG_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/flang" CACHE STRING
9 "Path for CMake subdirectory for Flang (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/flang')")
10 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
11 set(flang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/flang")
13 # Keep this in sync with llvm/cmake/CMakeLists.txt!
14 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
15 "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
16 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
17 string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}")
18 set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm")
20 get_property(FLANG_EXPORTS GLOBAL PROPERTY FLANG_EXPORTS)
21 export(TARGETS ${FLANG_EXPORTS} FILE ${flang_cmake_builddir}/FlangTargets.cmake)
23 # Generate FlangConfig.cmake for the build tree.
24 set(FLANG_CONFIG_CMAKE_DIR "${flang_cmake_builddir}")
25 set(FLANG_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
26 set(FLANG_CONFIG_INCLUDE_EXPORTS "include(\"${flang_cmake_builddir}/FlangTargets.cmake\")")
27 set(FLANG_CONFIG_INCLUDE_DIRS
28 "${FLANG_SOURCE_DIR}/include"
29 "${FLANG_BINARY_DIR}/include"
32 ${CMAKE_CURRENT_SOURCE_DIR}/FlangConfig.cmake.in
33 ${flang_cmake_builddir}/FlangConfig.cmake
36 ${CMAKE_CURRENT_SOURCE_DIR}/FlangConfigVersion.cmake.in
37 ${flang_cmake_builddir}/FlangConfigVersion.cmake
39 set(FLANG_CONFIG_CMAKE_DIR)
40 set(FLANG_CONFIG_LLVM_CMAKE_DIR)
42 # Generate FlangConfig.cmake for the install tree.
43 find_prefix_from_config(FLANG_CONFIG_CODE FLANG_INSTALL_PREFIX "${FLANG_INSTALL_PACKAGE_DIR}")
45 extend_path(FLANG_CONFIG_CMAKE_DIR "\${FLANG_INSTALL_PREFIX}" "${FLANG_INSTALL_PACKAGE_DIR}")
46 extend_path(FLANG_CONFIG_LLVM_CMAKE_DIR "\${FLANG_INSTALL_PREFIX}" "${LLVM_INSTALL_PACKAGE_DIR}")
47 get_config_exports_includes(Flang FLANG_CONFIG_INCLUDE_EXPORTS)
48 extend_path(FLANG_CONFIG_INCLUDE_DIRS "\${FLANG_INSTALL_PREFIX}" "${CMAKE_INSTALL_INCLUDEDIR}")
51 ${CMAKE_CURRENT_SOURCE_DIR}/FlangConfig.cmake.in
52 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/FlangConfig.cmake
55 ${CMAKE_CURRENT_SOURCE_DIR}/FlangConfigVersion.cmake.in
56 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/FlangConfigVersion.cmake
59 set(FLANG_CONFIG_CODE)
60 set(FLANG_CONFIG_CMAKE_DIR)
61 set(FLANG_CONFIG_EXPORTS_FILE)
63 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
64 install_distribution_exports(Flang)
67 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/FlangConfig.cmake
68 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/FlangConfigVersion.cmake
69 DESTINATION ${FLANG_INSTALL_PACKAGE_DIR}
70 COMPONENT flang-cmake-exports)
72 if(NOT LLVM_ENABLE_IDE)
73 # Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
74 add_custom_target(flang-cmake-exports)
75 add_llvm_install_targets(install-flang-cmake-exports
76 COMPONENT flang-cmake-exports)