173
|
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(FLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/flang)
|
|
5 set(flang_cmake_builddir "${CMAKE_BINARY_DIR}/${FLANG_INSTALL_PACKAGE_DIR}")
|
|
6
|
|
7 # Keep this in sync with llvm/cmake/CMakeLists.txt!
|
|
8 set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
|
|
9 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
|
|
10
|
|
11 get_property(FLANG_EXPORTS GLOBAL PROPERTY FLANG_EXPORTS)
|
|
12 export(TARGETS ${FLANG_EXPORTS} FILE ${flang_cmake_builddir}/FlangTargets.cmake)
|
|
13
|
|
14 # Generate FlangConfig.cmake for the build tree.
|
|
15 set(FLANG_CONFIG_CMAKE_DIR "${flang_cmake_builddir}")
|
|
16 set(FLANG_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
|
207
|
17 set(FLANG_CONFIG_INCLUDE_EXPORTS "include(\"${flang_cmake_builddir}/FlangTargets.cmake\")")
|
173
|
18 set(FLANG_CONFIG_INCLUDE_DIRS
|
|
19 "${FLANG_SOURCE_DIR}/include"
|
|
20 "${FLANG_BINARY_DIR}/include"
|
|
21 )
|
|
22 configure_file(
|
|
23 ${CMAKE_CURRENT_SOURCE_DIR}/FlangConfig.cmake.in
|
|
24 ${flang_cmake_builddir}/FlangConfig.cmake
|
|
25 @ONLY)
|
|
26 set(FLANG_CONFIG_CMAKE_DIR)
|
|
27 set(FLANG_CONFIG_LLVM_CMAKE_DIR)
|
|
28
|
|
29 # Generate FlangConfig.cmake for the install tree.
|
|
30 set(FLANG_CONFIG_CODE "
|
|
31 # Compute the installation prefix from this LLVMConfig.cmake file location.
|
|
32 get_filename_component(FLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
|
|
33 # Construct the proper number of get_filename_component(... PATH)
|
|
34 # calls to compute the installation prefix.
|
|
35 string(REGEX REPLACE "/" ";" _count "${FLANG_INSTALL_PACKAGE_DIR}")
|
|
36 foreach(p ${_count})
|
|
37 set(FLANG_CONFIG_CODE "${FLANG_CONFIG_CODE}
|
|
38 get_filename_component(FLANG_INSTALL_PREFIX \"\${FLANG_INSTALL_PREFIX}\" PATH)")
|
|
39 endforeach(p)
|
|
40
|
|
41 set(FLANG_CONFIG_CMAKE_DIR "\${FLANG_INSTALL_PREFIX}/${FLANG_INSTALL_PACKAGE_DIR}")
|
|
42 set(FLANG_CONFIG_LLVM_CMAKE_DIR "\${FLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
|
207
|
43 get_config_exports_includes(Flang FLANG_CONFIG_INCLUDE_EXPORTS)
|
173
|
44 set(FLANG_CONFIG_INCLUDE_DIRS "\${FLANG_INSTALL_PREFIX}/include")
|
|
45
|
|
46 configure_file(
|
|
47 ${CMAKE_CURRENT_SOURCE_DIR}/FlangConfig.cmake.in
|
|
48 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/FlangConfig.cmake
|
|
49 @ONLY)
|
|
50
|
|
51 set(FLANG_CONFIG_CODE)
|
|
52 set(FLANG_CONFIG_CMAKE_DIR)
|
|
53 set(FLANG_CONFIG_EXPORTS_FILE)
|
|
54
|
|
55 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
207
|
56 install_distribution_exports(Flang)
|
173
|
57
|
|
58 install(FILES
|
|
59 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/FlangConfig.cmake
|
|
60 DESTINATION ${FLANG_INSTALL_PACKAGE_DIR}
|
|
61 COMPONENT flang-cmake-exports)
|
|
62
|
|
63 if(NOT LLVM_ENABLE_IDE)
|
|
64 # Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
|
|
65 add_custom_target(flang-cmake-exports)
|
|
66 add_llvm_install_targets(install-flang-cmake-exports
|
|
67 COMPONENT flang-cmake-exports)
|
|
68 endif()
|
|
69 endif()
|