1 # Keep this in sync with llvm/cmake/CMakeLists.txt!
3 include(GNUInstallPackageDir)
5 include(FindPrefixFromConfig)
7 set(POLLY_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/polly" CACHE STRING
8 "Path for CMake subdirectory for Polly (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/polly')")
9 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
10 set(polly_cmake_builddir "${POLLY_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/polly")
12 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
13 "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
14 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
15 string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}")
16 set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm")
18 if (CMAKE_CONFIGURATION_TYPES)
19 set(POLLY_EXPORTS_FILE_NAME "PollyExports-$<LOWER_CASE:$<CONFIG>>.cmake")
21 # avoid conflicts in the build-tree when changing configuration
22 set(POLLY_EXPORTS_FILE_NAME "PollyExports-all.cmake")
25 set(POLLY_CONFIG_EXPORTED_TARGETS Polly ${ISL_TARGET})
26 if (NOT (WIN32 OR CYGWIN) AND LLVM_ENABLE_PIC)
27 # LLVMPolly is a dummy target on Win or if PIC code is disabled.
28 list(APPEND POLLY_CONFIG_EXPORTED_TARGETS LLVMPolly)
31 # Get the target type for every exported target
32 foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
33 get_target_property(tgt_type ${tgt} TYPE)
34 string(REPLACE "_LIBRARY" "" tgt_type ${tgt_type})
35 set(POLLY_CONFIG_TARGET_${tgt}_TYPE ${tgt_type})
38 # generate the import code for bundled/undbundled libisl versions
39 if (NOT POLLY_BUNDLED_ISL)
40 get_property(incl TARGET ISL PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
41 get_property(lib TARGET ISL PROPERTY INTERFACE_LINK_LIBRARIES)
42 get_property(opt TARGET ISL PROPERTY INTERFACE_COMPILE_OPTIONS)
44 add_library(ISL INTERFACE IMPORTED)
45 set_property(TARGET ISL APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${incl})
46 set_property(TARGET ISL APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${lib})
47 set_property(TARGET ISL APPEND PROPERTY INTERFACE_COMPILE_OPTIONS ${opt})")
50 if (NOT TARGET PollyISL)
51 add_library(PollyISL ${POLLY_CONFIG_TARGET_PollyISL_TYPE} IMPORTED)
55 # Generate PollyConfig.cmake for the build tree.
56 set(POLLY_CONFIG_CODE "")
57 set(POLLY_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
58 set(POLLY_CONFIG_CMAKE_DIR "${polly_cmake_builddir}")
59 set(POLLY_CONFIG_INCLUDE_DIRS
60 ${POLLY_SOURCE_DIR}/include
62 ${POLLY_BINARY_DIR}/include
64 set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_BINARY_DIR}/lib")
66 # set locations for imported targets
67 foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
68 get_target_property(tgt_type ${tgt} TYPE)
69 if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
71 "set_target_properties(${tgt} PROPERTIES
72 IMPORTED_LOCATION$<$<NOT:$<CONFIG:>>:_$<UPPER_CASE:$<CONFIG>>> $<TARGET_FILE:${tgt}>)
77 # PollyConfig holds the target definitions and general settings, PollyExports
78 # the imported locations
80 ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
81 ${polly_cmake_builddir}/PollyConfig.cmake
84 ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfigVersion.cmake.in
85 ${polly_cmake_builddir}/PollyConfigVersion.cmake
89 OUTPUT ${polly_cmake_builddir}/${POLLY_EXPORTS_FILE_NAME}
90 CONTENT "${POLLY_EXPORTS}")
93 # Generate PollyConfig.cmake for the install tree.
95 find_prefix_from_config(POLLY_CONFIG_CODE POLLY_INSTALL_PREFIX "${POLLY_INSTALL_PACKAGE_DIR}")
96 extend_path(POLLY_CONFIG_LLVM_CMAKE_DIR "\${POLLY_INSTALL_PREFIX}" "${LLVM_INSTALL_PACKAGE_DIR}")
97 extend_path(POLLY_CONFIG_CMAKE_DIR "\${POLLY_INSTALL_PREFIX}" "${POLLY_INSTALL_PACKAGE_DIR}")
98 extend_path(POLLY_CONFIG_LIBRARY_DIRS "\${POLLY_INSTALL_PREFIX}" "lib${LLVM_LIBDIR_SUFFIX}")
99 extend_path(base_includedir "\${POLLY_INSTALL_PREFIX}" "${CMAKE_INSTALL_INCLUDEDIR}")
100 if (POLLY_BUNDLED_ISL)
101 set(POLLY_CONFIG_INCLUDE_DIRS
103 "${base_includedir}/polly"
106 set(POLLY_CONFIG_INCLUDE_DIRS
112 # Set locations for imported targets. The path is constructed to be relative to
115 # Include the config code of PollyConfig.cmake to define POLLY_INSTALL_PREFIX
116 # anew in case the export file is included alone rather than from that file.
118 "${POLLY_CONFIG_CODE}
121 foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
122 get_target_property(tgt_type ${tgt} TYPE)
123 if (tgt_type STREQUAL "EXECUTABLE")
124 set(tgt_prefix "${CMAKE_INSTALL_BINDIR}")
126 set(tgt_prefix "${CMAKE_INSTALL_LIBDIR}")
129 extend_path(tgt_path "\${POLLY_INSTALL_PREFIX}" "${tgt_prefix}/$<TARGET_FILE_NAME:${tgt}>")
131 if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY")
133 "set_target_properties(${tgt} PROPERTIES
134 IMPORTED_LOCATION$<$<NOT:$<CONFIG:>>:_$<UPPER_CASE:$<CONFIG>>> \"${tgt_path}\")
140 ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
141 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake
144 ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfigVersion.cmake.in
145 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfigVersion.cmake
148 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}
149 CONTENT "${POLLY_EXPORTS}")
151 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
154 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake"
155 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfigVersion.cmake"
156 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}"
157 DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}")