1 # Keep this in sync with llvm/cmake/CMakeLists.txt!
3 set(LLVM_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
4 set(POLLY_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/polly")
5 if (CMAKE_CONFIGURATION_TYPES)
6 set(POLLY_EXPORTS_FILE_NAME "PollyExports-$<LOWER_CASE:$<CONFIG>>.cmake")
8 # avoid conflicts in the build-tree when changing configuration
9 set(POLLY_EXPORTS_FILE_NAME "PollyExports-all.cmake")
12 set(POLLY_CONFIG_EXPORTED_TARGETS Polly ${ISL_TARGET})
14 # LLVMPolly is a dummy target on Win
15 list(APPEND POLLY_CONFIG_EXPORTED_TARGETS LLVMPolly)
17 if (POLLY_ENABLE_GPGPU_CODEGEN)
18 list(APPEND POLLY_CONFIG_EXPORTED_TARGETS PollyPPCG)
21 # Get the target type for every exported target
22 foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
23 get_target_property(tgt_type ${tgt} TYPE)
24 string(REPLACE "_LIBRARY" "" tgt_type ${tgt_type})
25 set(POLLY_CONFIG_TARGET_${tgt}_TYPE ${tgt_type})
28 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
29 set(POLLY_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
31 # generate the import code for bundled/undbundled libisl versions
32 if (NOT POLLY_BUNDLED_ISL)
33 get_property(incl TARGET ISL PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
34 get_property(lib TARGET ISL PROPERTY INTERFACE_LINK_LIBRARIES)
35 get_property(opt TARGET ISL PROPERTY INTERFACE_COMPILE_OPTIONS)
37 add_library(ISL INTERFACE IMPORTED)
38 set_property(TARGET ISL APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${incl})
39 set_property(TARGET ISL APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${lib})
40 set_property(TARGET ISL APPEND PROPERTY INTERFACE_COMPILE_OPTIONS ${opt})")
43 if (NOT TARGET PollyISL)
44 add_library(PollyISL ${POLLY_CONFIG_TARGET_PollyISL_TYPE} IMPORTED)
48 # Generate PollyConfig.cmake for the build tree.
49 set(POLLY_CONFIG_CMAKE_DIR "${CMAKE_BINARY_DIR}/${POLLY_INSTALL_PACKAGE_DIR}")
50 set(POLLY_CONFIG_INCLUDE_DIRS
51 ${POLLY_SOURCE_DIR}/include
53 ${POLLY_BINARY_DIR}/include
55 set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_BINARY_DIR}/lib")
57 # set locations for imported targets
58 foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
59 get_target_property(tgt_type ${tgt} TYPE)
60 if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
62 "set_target_properties(${tgt} PROPERTIES
63 IMPORTED_LOCATION_$<UPPER_CASE:$<CONFIG>> $<TARGET_FILE:${tgt}>)
68 # PollyConfig holds the target definitions and general settings, PollyExports
69 # the imported locations
71 ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
72 ${POLLY_CONFIG_CMAKE_DIR}/PollyConfig.cmake
76 OUTPUT ${POLLY_CONFIG_CMAKE_DIR}/${POLLY_EXPORTS_FILE_NAME}
77 CONTENT "${POLLY_EXPORTS}")
80 # Generate PollyConfig.cmake for the install tree.
82 set(POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
83 set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
84 set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
85 set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
86 if (POLLY_BUNDLED_ISL)
87 set(POLLY_CONFIG_INCLUDE_DIRS
88 "${POLLY_INSTALL_PREFIX}/include"
89 "${POLLY_INSTALL_PREFIX}/include/polly"
92 set(POLLY_CONFIG_INCLUDE_DIRS
93 "${POLLY_INSTALL_PREFIX}/include"
98 # set locations for imported targets. The path is constructed to be relative to
100 foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
101 get_target_property(tgt_type ${tgt} TYPE)
102 if (tgt_type STREQUAL "EXECUTABLE")
103 set(tgt_prefix "bin/")
105 set(tgt_prefix "lib/")
108 set(tgt_path "${CMAKE_INSTALL_PREFIX}/${tgt_prefix}$<TARGET_FILE_NAME:${tgt}>")
109 file(RELATIVE_PATH tgt_path ${POLLY_CONFIG_CMAKE_DIR} ${tgt_path})
111 if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
113 "set_target_properties(${tgt} PROPERTIES
114 IMPORTED_LOCATION$<$<NOT:$<CONFIG:>>:_<UPPER_CASE:$<CONFIG>> \${CMAKE_CURRENT_LIST_DIR}/${tgt_path})
120 ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
121 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake
124 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}
125 CONTENT "${POLLY_EXPORTS}")
127 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
130 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake"
131 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}"
132 DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}")