[LLVMdev] LLVM Cmake module?

Óscar Fuentes ofv at wanadoo.es
Wed Nov 3 12:01:03 PDT 2010

[Please CC the mailing list]

Eli Gottlieb <eligottlieb at gmail.com> writes:

> OK, I'm just going to paste in my CMakeLists.txt file.  Like I said,
> I'm building an LLVM install myself by untarring llvm, mkdir build in
> the root dir of the source, cd build/, cmake .., make.
>> cmake_minimum_required (VERSION 2.6)
>> project (libjllvm)
>> add_library(jllvm Analysis_wrap.c BitReader_wrap.c BitWriter_wrap.c
>> Core_wrap.c EnhancedDisassembly_wrap.c ExecutionEngine_wrap.c
>> LinkTimeOptimizer_wrap.c lto_wrap.c Target_wrap.c
>> Transforms/IPO_wrap.c Transforms/Scalar_wrap.c)
>> # A convenience variable:
>> set(LLVM_ROOT "/usr" CACHE /usr/ "Root of LLVM install.")
>> # A bit of a sanity check:
>> if( NOT EXISTS ${LLVM_ROOT}/include/llvm )
>> message(FATAL_ERROR "LLVM_ROOT (${LLVM_ROOT}) is not a valid LLVM
>> install")
>> endif()
>> # We incorporate the CMake features provided by LLVM:
>> "${LLVM_ROOT}/share/llvm/cmake")
>> include(LLVM)
>> # Now set the header and library paths:
>> include_directories( ${LLVM_ROOT}/include )
>> link_directories( ${LLVM_ROOT}/lib )
>> # Let's suppose we want to build a JIT compiler with support for
>> # binary code (no interpreter):
>> llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native core)
>> # Finally, we link the LLVM libraries to our executable:
>> target_link_libraries(jllvm ${REQ_LLVM_LIBRARIES})

Where is the failure? On the "if( NOT EXISTS ${LLVM_ROOT}/include/llvm )" ?

If that's the problem, is LLVM installed on /usr ? On my Kubuntu machine
CMAKE_INSTALL_PREFIX defaults to /usr/local.

Please describe exactly the problem, pasting error messages if

More information about the llvm-dev mailing list