[Bf-committers] CMake cannot find system-wide LLVM installation

IRIE Shinsuke irieshinsuke at yahoo.co.jp
Fri Nov 9 13:29:18 CET 2012


Thanks, Brecht.

However, the additional changes for dynamic linking are not working
because libLLVMAnalysis.so does not exist.  Most of all LLVM libraries
are contained in libLLVM-3.x.so, so LLVM_LIBRARY must be set such as
LLVM-3.1, instead.

Now I'm testing the following patch on Uubntu 12.10:

Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 52037)
+++ CMakeLists.txt	(working copy)
@@ -718,7 +718,7 @@
  	if(WITH_LLVM)
  		set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH	"Path to the LLVM installation")
  		set(LLVM_VERSION "3.0" CACHE STRING	"Version of LLVM to use")
-		set(LLVM_STATIC YES)
+		set(LLVM_STATIC YES CACHE BOOL	"Link LLVM libraries statically")
  		if(EXISTS "${LLVM_DIRECTORY}/bin/llvm-config")
  			set(LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config")
  		else()
@@ -733,9 +733,15 @@
  		execute_process(COMMAND ${LLVM_CONFIG} --libdir
  		                OUTPUT_VARIABLE LLVM_LIB_DIR
  		                OUTPUT_STRIP_TRAILING_WHITESPACE)
-		find_library(LLVM_LIBRARY
-		             NAMES LLVMAnalysis # first of a whole bunch of libs to get
-		             PATHS ${LLVM_LIB_DIR})
+		if(LLVM_STATIC)
+			find_library(LLVM_LIBRARY
+			             NAMES LLVMAnalysis # first of a whole bunch of libs to get
+			             PATHS ${LLVM_LIB_DIR})
+		else()
+			find_library(LLVM_LIBRARY
+			             NAMES LLVM-${LLVM_VERSION}
+			             PATHS ${LLVM_LIB_DIR})
+		endif()
  		message(STATUS "LLVM version  = ${LLVM_VERSION}")
  		message(STATUS "LLVM dir      = ${LLVM_DIRECTORY}")
  		message(STATUS "LLVM lib dir  = ${LLVM_LIB_DIR}")


So far it works fine for me.  I'm not sure if this patch works on the
other distros.

-- 
IRIE Shinsuke

12/11/09, Brecht Van Lommel wrote:
> Hi,
>
> I've committed the llvm-config patch now. Also changed it so it
> doesn't only look for static libLLVMAnalysis.a, but also dynamic libs.
> That might not be enough to make it work though.
>
> Brecht.
>
> On Thu, Nov 8, 2012 at 12:45 PM, IRIE Shinsuke <irieshinsuke at yahoo.co.jp> wrote:
>> Please fix this bug!  It's annoying that I have to set
>> LLVM_DIRECTORY=/usr every time I use cmake...
>>
>> It should be easy to fix.
>>
>> --
>> IRIE Shinsuke
>>
>> 12/11/05, IRIE Shinsuke wrote:
>>> Hi,
>>>
>>> I'm using system-wide LLVM installed in /usr on Ubuntu 12.10, but
>>> CMakeLists.txt cannot find it so I have to specify the directory
>>> explicitly by a command line option -DLLVM_DIRECTORY=/usr.
>>>
>>> The following patch should fix this bug:
>>>
>>> Index: blender/CMakeLists.txt
>>> ===================================================================
>>> --- blender/CMakeLists.txt      (revision 51867)
>>> +++ blender/CMakeLists.txt      (working copy)
>>> @@ -715,7 +715,7 @@
>>>                   set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH    "Path to the LLVM installation")
>>>                   set(LLVM_VERSION "3.0" CACHE STRING     "Version of LLVM to use")
>>>                   set(LLVM_STATIC YES)
>>> -               if(LLVM_DIRECTORY)
>>> +               if(EXISTS "${LLVM_DIRECTORY}/bin/llvm-config")
>>>                           set(LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config")
>>>                   else()
>>>                           set(LLVM_CONFIG llvm-config)
>>>
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers


More information about the Bf-committers mailing list