X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FCMake.html;h=ff8bf30d323b9b8a0e08488bd33e090e1a36b6d5;hb=8e3c17aabf558e19dcd63e159862022d31951d62;hp=e303d132b5902f29f54fa7b73d7393a565edced4;hpb=f287f01cd11bef94ff90433d2dfe27b78c0f9f4c;p=oota-llvm.git diff --git a/docs/CMake.html b/docs/CMake.html index e303d132b59..ff8bf30d323 100644 --- a/docs/CMake.html +++ b/docs/CMake.html @@ -2,13 +2,14 @@ "http://www.w3.org/TR/html4/strict.dtd">
+CMake is a cross-platform build-generator tool. CMake does not build the project, it generates @@ -56,12 +60,12 @@
We use here the command-line, non-interactive CMake interface
@@ -109,12 +113,12 @@This section explains basic aspects of CMake, mostly for explaining those options which you may need on your day-to-day @@ -141,7 +145,7 @@ text. Generator's names are case-sensitive. Example:
cmake -G "Visual Studio 8 2005" path/to/llvm/source/root
+cmake -G "Visual Studio 9 2008" path/to/llvm/source/root
For a given development platform there can be more than one @@ -157,12 +161,12 @@
Variables customize how the build will be generated. Options are boolean variables, with possible values ON/OFF. Options and @@ -191,14 +195,12 @@
cmake -DVARIABLE:TYPE=value path/to/llvm/source
Here are listed some of the CMake variables that are used often, along with a brief explanation and LLVM-specific notes. For full @@ -237,18 +239,18 @@
Testing is performed when the check target is built. For instance, if you are using makefiles, execute this command while on @@ -375,12 +397,12 @@
See this wiki page for generic instructions on how to cross-compile @@ -396,12 +418,12 @@
The most difficult part of adding LLVM to the build of a project is to determine the set of LLVM libraries corresponding to the set @@ -418,10 +440,11 @@ endif() # We incorporate the CMake features provided by LLVM: set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT}/share/llvm/cmake") - include(LLVM) + include(LLVMConfig) # Now set the header and library paths: - include_directories( ${LLVM_ROOT}/include ) - link_directories( ${LLVM_ROOT}/lib ) + include_directories( ${LLVM_INCLUDE_DIRS} ) + link_directories( ${LLVM_LIBRARY_DIRS} ) + add_definitions( ${LLVM_DEFINITIONS} ) # 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) @@ -436,20 +459,111 @@ headers on the LLVM source directory (if we are building out-of-source.)
-Alternativaly, you can utilize CMake's find_package + functionality. Here is an equivalent variant of snippet shown above:
+ ++ find_package(LLVM) + + if( NOT LLVM_FOUND ) + message(FATAL_ERROR "LLVM package can't be found. Set CMAKE_PREFIX_PATH variable to LLVM's installation prefix.") + endif() + include_directories( ${LLVM_INCLUDE_DIRS} ) + link_directories( ${LLVM_LIBRARY_DIRS} ) + + llvm_map_components_to_libraries(REQ_LLVM_LIBRARIES jit native) + + target_link_libraries(mycompiler ${REQ_LLVM_LIBRARIES}) ++
It is possible to develop LLVM passes against installed LLVM. + An example of project layout provided below:
+ ++ <project dir>/ + | + CMakeLists.txt + <pass name>/ + | + CMakeLists.txt + Pass.cpp + ... ++
Contents of <project dir>/CMakeLists.txt:
+ ++ find_package(LLVM) + + # Define add_llvm_* macro's. + include(AddLLVM) + + add_definitions(${LLVM_DEFINITIONS}) + include_directories(${LLVM_INCLUDE_DIRS}) + link_directories(${LLVM_LIBRARY_DIRS}) + + add_subdirectory(<pass name>) ++
Contents of <project dir>/<pass name>/CMakeLists.txt:
+ ++ add_llvm_loadable_module(LLVMPassname + Pass.cpp + ) ++
When you are done developing your pass, you may wish to integrate it
+ into LLVM source tree. You can achieve it in two easy steps:
+ 1. Copying <pass name> folder into <LLVM root>/lib/Transform directory.
+ 2. Adding "add_subdirectory(<pass name>)" line into <LLVM root>/lib/Transform/CMakeLists.txt
Notes for specific compilers and/or platforms.
+