[PATCH] D116555: [Polly][CMake] Make PollyConfig.cmake relocatable like other projects'
John Ericson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 7 13:01:20 PST 2022
Ericson2314 updated this revision to Diff 398221.
Ericson2314 added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116555/new/
https://reviews.llvm.org/D116555
Files:
polly/CMakeLists.txt
polly/cmake/CMakeLists.txt
polly/cmake/PollyConfig.cmake.in
Index: polly/cmake/PollyConfig.cmake.in
===================================================================
--- polly/cmake/PollyConfig.cmake.in
+++ polly/cmake/PollyConfig.cmake.in
@@ -1,5 +1,7 @@
# This file allows users to call find_package(Polly) and pick up our targets.
+ at POLLY_CONFIG_CODE@
+
find_package(LLVM REQUIRED CONFIG
HINTS "@POLLY_CONFIG_LLVM_CMAKE_DIR@")
Index: polly/cmake/CMakeLists.txt
===================================================================
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -1,5 +1,7 @@
# Keep this in sync with llvm/cmake/CMakeLists.txt!
+include(FindPrefixFromConfig)
+
set(LLVM_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
set(POLLY_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/polly")
if (CMAKE_CONFIGURATION_TYPES)
@@ -46,6 +48,7 @@
endif()
# Generate PollyConfig.cmake for the build tree.
+set(POLLY_CONFIG_CODE "")
set(POLLY_CONFIG_CMAKE_DIR "${CMAKE_BINARY_DIR}/${POLLY_INSTALL_PACKAGE_DIR}")
set(POLLY_CONFIG_INCLUDE_DIRS
${POLLY_SOURCE_DIR}/include
@@ -79,18 +82,18 @@
# Generate PollyConfig.cmake for the install tree.
unset(POLLY_EXPORTS)
-set(POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
-set(POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
-set(POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
-set(POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
+find_prefix_from_config(POLLY_CONFIG_CODE POLLY_INSTALL_PREFIX "${POLLY_INSTALL_PACKAGE_DIR}")
+set(POLLY_CONFIG_LLVM_CMAKE_DIR "\${POLLY_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
+set(POLLY_CONFIG_CMAKE_DIR "\${POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR}")
+set(POLLY_CONFIG_LIBRARY_DIRS "\${POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
if (POLLY_BUNDLED_ISL)
set(POLLY_CONFIG_INCLUDE_DIRS
- "${POLLY_INSTALL_PREFIX}/include"
- "${POLLY_INSTALL_PREFIX}/include/polly"
+ "\${POLLY_INSTALL_PREFIX}/include"
+ "\${POLLY_INSTALL_PREFIX}/include/polly"
)
else()
set(POLLY_CONFIG_INCLUDE_DIRS
- "${POLLY_INSTALL_PREFIX}/include"
+ "\${POLLY_INSTALL_PREFIX}/include"
${ISL_INCLUDE_DIRS}
)
endif()
Index: polly/CMakeLists.txt
===================================================================
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -48,10 +48,15 @@
set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(POLLY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
-# Add path for custom modules
-set(CMAKE_MODULE_PATH
- ${CMAKE_MODULE_PATH}
- "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
+if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
+ set(LLVM_COMMON_CMAKE_UTILS ${POLLY_SOURCE_DIR}/../cmake)
+endif()
+
+# Make sure that our source directory is on the current cmake module path so that
+# we can include cmake files from this directory.
+list(INSERT CMAKE_MODULE_PATH 0
+ "${POLLY_SOURCE_DIR}/cmake"
+ "${LLVM_COMMON_CMAKE_UTILS}/Modules"
)
include("polly_macros")
@@ -68,9 +73,6 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
endif ()
-# Add path for custom modules
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${POLLY_SOURCE_DIR}/cmake")
-
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
option(POLLY_ENABLE_GPGPU_CODEGEN "Enable GPGPU code generation feature" OFF)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116555.398221.patch
Type: text/x-patch
Size: 3331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220107/77a530e4/attachment.bin>
More information about the llvm-commits
mailing list