aboutsummaryrefslogtreecommitdiff
path: root/polly
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2022-01-01 20:18:27 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-07-25 21:02:53 +0000
commitac0d1d5c7b7e0d572e35e31e0b59be765ca42a48 (patch)
tree011a54e6042ee73873dc6922908d96474fd44ade /polly
parent8c626fc0c8a904c0040a36561edd9b62ac3b71b4 (diff)
downloadllvm-ac0d1d5c7b7e0d572e35e31e0b59be765ca42a48.zip
llvm-ac0d1d5c7b7e0d572e35e31e0b59be765ca42a48.tar.gz
llvm-ac0d1d5c7b7e0d572e35e31e0b59be765ca42a48.tar.bz2
[cmake] Support custom package install paths
Firstly, we we make an additional GNUInstallDirs-style variable. With NixOS, for example, this is crucial as we want those to go in `${dev}/lib/cmake` not `${out}/lib/cmake` as that would a cmake subdir of the "regular" libdir, which is installed even when no one needs to do any development. Secondly, we make *Config.cmake robust to absolute package install paths. We for NixOS will in fact be passing them absolute paths to make the `${dev}` vs `${out}` distinction mentioned above, and the GNUInstallDirs-style variables are suposed to support absolute paths in general so it's good practice besides the NixOS use-case. Thirdly, we make `${project}_INSTALL_PACKAGE_DIR` CACHE PATHs like other install dirs are. Reviewed By: sebastian-ne Differential Revision: https://reviews.llvm.org/D117973
Diffstat (limited to 'polly')
-rw-r--r--polly/cmake/CMakeLists.txt23
1 files changed, 15 insertions, 8 deletions
diff --git a/polly/cmake/CMakeLists.txt b/polly/cmake/CMakeLists.txt
index 7a0190b..4c528d5 100644
--- a/polly/cmake/CMakeLists.txt
+++ b/polly/cmake/CMakeLists.txt
@@ -1,10 +1,19 @@
# Keep this in sync with llvm/cmake/CMakeLists.txt!
+include(GNUInstallPackageDir)
include(ExtendPath)
include(FindPrefixFromConfig)
-set(LLVM_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
-set(POLLY_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/polly")
+set(POLLY_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/polly" CACHE STRING
+ "Path for CMake subdirectory for Polly (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/polly')")
+# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
+set(polly_cmake_builddir "${POLLY_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/polly")
+
+set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
+ "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
+# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
+set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+
if (CMAKE_CONFIGURATION_TYPES)
set(POLLY_EXPORTS_FILE_NAME "PollyExports-$<LOWER_CASE:$<CONFIG>>.cmake")
else()
@@ -28,9 +37,6 @@ foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
set(POLLY_CONFIG_TARGET_${tgt}_TYPE ${tgt_type})
endforeach()
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
-set(POLLY_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
-
# generate the import code for bundled/undbundled libisl versions
if (NOT POLLY_BUNDLED_ISL)
get_property(incl TARGET ISL PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
@@ -50,7 +56,8 @@ 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_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
+set(POLLY_CONFIG_CMAKE_DIR "${polly_cmake_builddir}")
set(POLLY_CONFIG_INCLUDE_DIRS
${POLLY_SOURCE_DIR}/include
${ISL_INCLUDE_DIRS}
@@ -73,11 +80,11 @@ endforeach(tgt)
# the imported locations
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
- ${POLLY_CONFIG_CMAKE_DIR}/PollyConfig.cmake
+ ${polly_cmake_builddir}/PollyConfig.cmake
@ONLY)
file(GENERATE
- OUTPUT ${POLLY_CONFIG_CMAKE_DIR}/${POLLY_EXPORTS_FILE_NAME}
+ OUTPUT ${polly_cmake_builddir}/${POLLY_EXPORTS_FILE_NAME}
CONTENT "${POLLY_EXPORTS}")