Fwd: [PATCH] D29969: Use CMAKE_INSTALL_PREFIX for setting LLVM_INSTALL_PREFIX

Orion Poplawski via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 14 15:32:18 PST 2017


Not sure how to have gotten this to post to llvm-commits.


-------- Forwarded Message --------
Subject: [PATCH] D29969: Use CMAKE_INSTALL_PREFIX for setting LLVM_INSTALL_PREFIX
Date: Tue, 14 Feb 2017 23:29:35 +0000
From: Orion Poplawski via Phabricator <reviews at reviews.llvm.org>
Reply-To: reviews+D29969+public+7c679723af6e683b at reviews.llvm.org
To: orion at cora.nwra.com
CC: mgorny at gentoo.org

opoplawski created this revision.
Herald added a subscriber: mgorny.

Using -get_filename_component() to compute the install prefix is fragile and
subject to breakage in the presence of symbolic links.  We know the install
prefix via CMAKE_INSTALL_PREFIX, so use it.

This came out of part of my work testing parallel installable versions of
llvm/clang for Fedora, and looking to be able to have clang's CMakeLists.txt
be able to do:

  find_package(LLVM 3.9 REQUIRED)
  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")

to locate llvm.


Repository:
  rL LLVM

https://reviews.llvm.org/D29969

Files:
  cmake/modules/CMakeLists.txt


Index: cmake/modules/CMakeLists.txt
===================================================================
--- cmake/modules/CMakeLists.txt
+++ cmake/modules/CMakeLists.txt
@@ -75,15 +75,7 @@

 # Generate LLVMConfig.cmake for the install tree.
 set(LLVM_CONFIG_CODE "
-# Compute the installation prefix from this LLVMConfig.cmake file location.
-get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\"
PATH)")
-# Construct the proper number of get_filename_component(... PATH)
-# calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}")
-foreach(p ${_count})
-  set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
-get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
-endforeach(p)
+set(LLVM_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")")
 set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
 set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}")
 set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29969.88457.patch
Type: text/x-patch
Size: 1054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170214/576f615a/attachment.bin>


More information about the llvm-commits mailing list