1 # Keep this in sync with llvm/cmake/CMakeLists.txt!
3 # this simplifies things down the road, by not requiring to distinguish
4 # between in-tree and out of tree builds
5 set(LLVM_BINARY_DIR ${LLVM_INSTALL_ROOT})
8 set(LLVM_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
9 set(POLLY_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/polly")
10 if (CMAKE_CONFIGURATION_TYPES)
11 set(POLLY_EXPORTS_FILE_NAME "PollyExports-$<LOWER_CASE:$<CONFIG>>.cmake")
13 # avoid conflicts in the build-tree when changing configuration
14 set(POLLY_EXPORTS_FILE_NAME "PollyExports-all.cmake")
17 set(POLLY_CONFIG_EXPORTED_TARGETS Polly ${ISL_TARGET})
19 # LLVMPolly is a dummy target on Win
20 list(APPEND POLLY_CONFIG_EXPORTED_TARGETS LLVMPolly)
22 if (POLLY_ENABLE_GPGPU_CODEGEN)
23 list(APPEND POLLY_CONFIG_EXPORTED_TARGETS PollyPPCG)
26 # Get the target type for every exported target
27 foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
28 get_target_property(tgt_type ${tgt} TYPE)
29 string(REPLACE "_LIBRARY" "" tgt_type ${tgt_type})
30 set(POLLY_CONFIG_TARGET_${tgt}_TYPE ${tgt_type})
33 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
34 set(POLLY_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
36 # generate the import code for bundled/undbundled libisl versions
37 if (NOT POLLY_BUNDLED_ISL)
38 get_property(incl TARGET ISL PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
39 get_property(lib TARGET ISL PROPERTY INTERFACE_LINK_LIBRARIES)
40 get_property(opt TARGET ISL PROPERTY INTERFACE_COMPILE_OPTIONS)
42 add_library(ISL INTERFACE IMPORTED)
43 set_property(TARGET ISL APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${incl})
44 set_property(TARGET ISL APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${lib})
45 set_property(TARGET ISL APPEND PROPERTY INTERFACE_COMPILE_OPTIONS ${opt})")
48 if (NOT TARGET PollyISL)
49 add_library(PollyISL ${POLLY_CONFIG_TARGET_PollyISL_TYPE} IMPORTED)
53 # Generate PollyConfig.cmake for the build tree.
54 set(POLLY_CONFIG_CMAKE_DIR "${CMAKE_BINARY_DIR}/${POLLY_INSTALL_PACKAGE_DIR}")
55 set(POLLY_CONFIG_INCLUDE_DIRS
56 ${POLLY_SOURCE_DIR}/include
58 ${POLLY_BINARY_DIR}/include
60 set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_BINARY_DIR}/lib")
62 # set locations for imported targets
63 foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
64 get_target_property(tgt_type ${tgt} TYPE)
65 if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
67 "set_target_properties(${tgt} PROPERTIES
68 IMPORTED_LOCATION_$<UPPER_CASE:$<CONFIG>> $<TARGET_FILE:${tgt}>)
73 # PollyConfig holds the target definitions and general settings, PollyExports
74 # the imported locations
76 ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
77 ${POLLY_CONFIG_CMAKE_DIR}/PollyConfig.cmake
81 OUTPUT ${POLLY_CONFIG_CMAKE_DIR}/${POLLY_EXPORTS_FILE_NAME}
82 CONTENT "${POLLY_EXPORTS}")
85 # Generate PollyConfig.cmake for the install tree.
87 set(POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
88 set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
89 set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
90 set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
91 if (POLLY_BUNDLED_ISL)
92 set(POLLY_CONFIG_INCLUDE_DIRS
93 "${POLLY_INSTALL_PREFIX}/include"
94 "${POLLY_INSTALL_PREFIX}/include/polly"
97 set(POLLY_CONFIG_INCLUDE_DIRS
98 "${POLLY_INSTALL_PREFIX}/include"
103 # set locations for imported targets. The path is constructed to be relative to
105 foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
106 get_target_property(tgt_type ${tgt} TYPE)
107 if (tgt_type STREQUAL "EXECUTABLE")
108 set(tgt_prefix "bin/")
110 set(tgt_prefix "lib/")
113 set(tgt_path "${CMAKE_INSTALL_PREFIX}/${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>")
114 file(RELATIVE_PATH tgt_path ${POLLY_CONFIG_CMAKE_DIR} ${tgt_path})
116 if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
118 "set_target_properties(${tgt} PROPERTIES
119 IMPORTED_LOCATION_$<UPPER_CASE:$<CONFIG>> \${CMAKE_CURRENT_LIST_DIR}/${tgt_path})
125 ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
126 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake
129 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}
130 CONTENT "${POLLY_EXPORTS}")
132 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
135 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake"
136 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}"
137 DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}")