LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 12157 - llvmconfig.cmake.in make cmake installations not relocatable
Summary: llvmconfig.cmake.in make cmake installations not relocatable
Status: RESOLVED FIXED
Alias: None
Product: Build scripts
Classification: Unclassified
Component: cmake (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks: 15732
  Show dependency tree
 
Reported: 2012-03-01 21:08 PST by hume
Modified: 2015-03-03 16:52 PST (History)
6 users (show)

See Also:
Fixed By Commit(s):


Attachments
the patch (1.28 KB, application/octet-stream)
2012-06-29 11:57 PDT, hume
Details

Note You need to log in before you can comment on or make changes to this bug.
Description hume 2012-03-01 21:08:07 PST
the installed llvm package is not relocatable and has reference to the source tree, this problem maybe fixed using dynamic relative path calculations as follows:

line21:
set(LLVM_TOOLS_BINARY_DIR @LLVM_TOOLS_BINARY_DIR@)

should be replaced to 
set(LLVM_TOOLS_BINARY_DIR ${CMAKE_CURRENT_LIST_DIR}/../../bin)

line 34
set(LLVM_INSTALL_PREFIX @LLVM_INSTALL_PREFIX@)

to:

set(LLVM_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/../..)

line 136:

    "@LLVM_SOURCE_DIR@/cmake/modules")
to
    ${LLVM_INSTALL_PREFIX}/share/llvm/cmake)
Comment 1 hume 2012-03-01 21:37:09 PST
two typing mistakes, they should be instead as above
set(LLVM_TOOLS_BINARY_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../bin)

set(LLVM_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/../../..)
Comment 2 hume 2012-04-08 23:12:26 PDT
diff -Nur modules_orig/LLVMConfig.cmake.in modules/LLVMConfig.cmake.in
--- modules_orig/LLVMConfig.cmake.in	2011-07-30 07:52:01 +0800
+++ modules/LLVMConfig.cmake.in	2012-03-12 14:59:11 +0800
@@ -16,7 +16,7 @@
 
 set(TARGET_TRIPLE "@TARGET_TRIPLE@")
 
-set(LLVM_TOOLS_BINARY_DIR @LLVM_TOOLS_BINARY_DIR@)
+set(LLVM_TOOLS_BINARY_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../bin)
 
 set(LLVM_ENABLE_THREADS @LLVM_ENABLE_THREADS@)
 
@@ -29,7 +29,7 @@
 set(LLVM_ON_UNIX @LLVM_ON_UNIX@)
 set(LLVM_ON_WIN32 @LLVM_ON_WIN32@)
 
-set(LLVM_INSTALL_PREFIX @LLVM_INSTALL_PREFIX@)
+set(LLVM_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/../../..)
 set(LLVM_INCLUDE_DIRS ${LLVM_INSTALL_PREFIX}/include)
 set(LLVM_LIBRARY_DIRS ${LLVM_INSTALL_PREFIX}/lib)
 set(LLVM_DEFINITIONS "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS")
@@ -43,7 +43,7 @@
 if( NOT LLVMCONFIG_INCLUDED )
   set(CMAKE_MODULE_PATH
     ${CMAKE_MODULE_PATH}
-    "@LLVM_SOURCE_DIR@/cmake/modules")
+    "${LLVM_INSTALL_PREFIX}/share/llvm/cmake")
   include( LLVM-Config )
 endif()
Comment 3 hume 2012-04-08 23:16:16 PDT
the above patch should fix the problem, hope to see it merged in the codebase
Comment 4 hume 2012-06-29 11:57:58 PDT
Created attachment 8793 [details]
the patch

this patch resolved the relocatable problem more reasonabaly, and make the uninstall build really worked for clients.
Comment 5 hume 2012-06-29 12:01:00 PDT
LLVM_TOOLS_BINARY_DIR is correct for installations and should be correct for make build systems but will not work under MSVC builds or xcode Build because they are in a per configuration dir, it's not so easy to solve this.

the patch is tested under windows and msvc.
Comment 6 hume 2012-06-29 12:03:18 PDT
CMAKE_CURRENT_LIST_FILE variable is provide at least in cmake 2.6.4 version, so this should be enough?
Comment 7 Stephen Kelly 2014-02-04 05:26:52 PST
This can be closed when Brads patches are merged.
Comment 8 Alp Toker 2014-06-06 03:25:14 PDT
(In reply to comment #7)
> This can be closed when Brads patches are merged.

Where are Brad's patches? There's no reference to Brad or his patches in this thread.
Comment 9 Stephen Kelly 2014-06-06 07:33:24 PDT
r201048
r201049
r201050
r201053

I didn't test them though.
Comment 10 Chris Bieneman 2015-02-03 17:42:19 PST
I think these patches were all landed. Is there anything else to be done here?
Comment 11 Stephen Kelly 2015-02-03 17:45:48 PST
Nope, this is done. 

I didn't test it, but we can assume Brad is making use of them.
Comment 12 Stephen Kelly 2015-02-25 15:01:06 PST
Any reason to keep this bug report open?
Comment 13 Chris Bieneman 2015-03-03 16:52:16 PST
This should be all completed.