llvm.org GIT mirror llvm / c2d8688
CMake: document how to incorporate LLVM into the cmake project of an external project. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110561 91177308-0d34-0410-b5e6-96231b3b80d8 Oscar Fuentes 9 years ago
1 changed file(s) with 33 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
353353
354354
355355
356

TODO

356

The most difficult part of adding LLVM to the build of a project

357 is to determine the set of LLVM libraries corresponding to the set
358 of required LLVM features. What follows is an example of how to
359 obtain this information:

360
361
362

                  
                
363 # A convenience variable:
364 set(LLVM_ROOT "" CACHE PATH "Root of LLVM install.")
365 # A bit of a sanity check:
366 if( NOT EXISTS ${LLVM_ROOT}/include/llvm )
367 message(FATAL_ERROR "LLVM_ROOT (${LLVM_ROOT}) is not a valid LLVM install")
368 endif()
369 # We incorporate the CMake features provided by LLVM:
370 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT}/share/llvm/cmake")
371 include(LLVM)
372 # Now set the header and library paths:
373 include_directories( ${LLVM_ROOT}/include )
374 link_directories( ${LLVM_ROOT}/lib )
375 # Let's suppose we want to build a JIT compiler with support for
376 # binary code (no interpreter):
377 llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native)
378 # Finally, we link the LLVM libraries to our executable:
379 target_link_libraries(mycompiler ${REQ_LLVM_LIBRARIES})
380
381
382
383

This assumes that LLVM_ROOT points to an install of LLVM. The

384 procedure works too for uninstalled builds although we need to take
385 care to add an include_directories for the location of the
386 headers on the LLVM source directory (if we are building
387 out-of-source.)

357388
358389
359390
382413
383414 Oscar Fuentes
384415 LLVM Compiler Infrastructure
385 Last modified: $Date: 2008-12-31 03:59:36 +0100 (Wed, 31 Dec 2008) $
416 Last modified: $Date: 2010-08-09 03:59:36 +0100 (Mon, 9 Aug 2010) $
386417
387418
388419