2 cmake_minimum_required(VERSION 2.6.1)
5 set(PACKAGE_VERSION svn)
6 set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu")
8 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
9 message(FATAL_ERROR "In-source builds are not allowed.
10 CMake would overwrite the makefiles distributed with LLVM.
11 Please create a directory and run cmake from there, passing the path
12 to this source directory as the last argument.
13 This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
19 set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
20 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include)
21 set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
22 set(LLVM_TOOLS_BINARY_DIR ${LLVM_BINARY_DIR}/bin)
23 set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
41 # List of targets whose asmprinters need to be forced to link
42 # into executables on some platforms (i.e. Windows):
43 set(LLVM_ASMPRINTERS_FORCE_LINK X86 PowerPC)
46 set(LLVM_TARGETS_TO_BUILD X86
47 CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
49 set(LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS}
50 CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
53 option(LLVM_ENABLE_THREADS "Use threads if available." ON)
55 if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
56 set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
59 foreach(c ${LLVM_TARGETS_TO_BUILD})
60 list(FIND LLVM_ALL_TARGETS ${c} idx)
62 message(FATAL_ERROR "The target `${c}' does not exists.
63 It should be one of\n${LLVM_ALL_TARGETS}")
67 set(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm)
69 # Add path for custom modules
72 "${LLVM_MAIN_SRC_DIR}/cmake"
73 "${LLVM_MAIN_SRC_DIR}/cmake/modules"
84 set(LTDL_SHLIB_EXT ".dll")
86 # Maximum path length is 160 for non-unicode paths
92 set(LTDL_SHLIB_EXT ".so")
94 # FIXME: Maximum path length is currently set to 'safe' fixed value
97 MESSAGE(SEND_ERROR "Unable to determine platform")
101 if( EXISTS ${LLVM_TOOLS_BINARY_DIR}/llvm-config )
102 set(HAVE_LLVM_CONFIG 1)
103 endif( EXISTS ${LLVM_TOOLS_BINARY_DIR}/llvm-config )
107 option(LLVM_ENABLE_PIC "Build Position-Independent Code" OFF)
109 if( LLVM_ENABLE_PIC )
110 if( SUPPORTS_FPIC_FLAG )
111 message(STATUS "Building with -fPIC")
112 add_definitions(-fPIC)
113 else( SUPPORTS_FPIC_FLAG )
114 message(STATUS "Warning: -fPIC not supported.")
118 set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} )
119 set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
120 set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
122 # set(CMAKE_VERBOSE_MAKEFILE true)
124 add_definitions( -D__STDC_LIMIT_MACROS )
125 add_definitions( -D__STDC_CONSTANT_MACROS )
127 set(LLVM_PLO_FLAGS "" CACHE
128 STRING "Flags for creating partially linked objects.")
130 if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
131 # TODO: support other platforms and toolchains.
132 option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
133 if( LLVM_BUILD_32_BITS )
134 message(STATUS "Building 32 bits executables and libraries.")
135 add_definitions( -m32 )
136 list(APPEND CMAKE_EXE_LINKER_FLAGS -m32)
137 list(APPEND CMAKE_SHARED_LINKER_FLAGS -m32)
138 set( LLVM_PLO_FLAGS -melf_i386 ${LLVM_PLO_FLAGS} )
139 endif( LLVM_BUILD_32_BITS )
140 endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
143 add_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS )
144 add_definitions( -D_SCL_SECURE_NO_WARNINGS -DCRT_NONSTDC_NO_WARNINGS )
145 add_definitions( -D_SCL_SECURE_NO_DEPRECATE )
146 add_definitions( -wd4146 -wd4503 -wd4996 -wd4800 -wd4244 -wd4624 )
147 add_definitions( -wd4355 -wd4715 )
150 include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR})
153 include(AddPartiallyLinkedObject)
156 add_subdirectory(lib/Support)
157 add_subdirectory(lib/System)
159 # Everything else depends on Support and System:
160 set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} )
162 set(LLVM_TABLEGEN "tblgen" CACHE
163 STRING "Native TableGen executable. Saves building one when cross-compiling.")
165 add_subdirectory(utils/TableGen)
167 if( CMAKE_CROSSCOMPILING )
168 # This adds a dependency on target `tblgen', so must go after utils/TableGen
169 include( CrossCompileLLVM )
170 endif( CMAKE_CROSSCOMPILING )
172 add_subdirectory(include/llvm)
174 add_subdirectory(lib/VMCore)
175 add_subdirectory(lib/CodeGen)
176 add_subdirectory(lib/CodeGen/SelectionDAG)
177 add_subdirectory(lib/CodeGen/AsmPrinter)
178 add_subdirectory(lib/Bitcode/Reader)
179 add_subdirectory(lib/Bitcode/Writer)
180 add_subdirectory(lib/Transforms/Utils)
181 add_subdirectory(lib/Transforms/Instrumentation)
182 add_subdirectory(lib/Transforms/Scalar)
183 add_subdirectory(lib/Transforms/IPO)
184 add_subdirectory(lib/Transforms/Hello)
185 add_subdirectory(lib/Linker)
186 add_subdirectory(lib/Analysis)
187 add_subdirectory(lib/Analysis/IPA)
189 foreach(t ${LLVM_TARGETS_TO_BUILD})
190 message(STATUS "Targeting ${t}")
191 add_subdirectory(lib/Target/${t})
192 if( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt )
193 add_subdirectory(lib/Target/${t}/AsmPrinter)
194 endif( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt )
197 add_subdirectory(lib/ExecutionEngine)
198 add_subdirectory(lib/ExecutionEngine/Interpreter)
199 add_subdirectory(lib/ExecutionEngine/JIT)
200 add_subdirectory(lib/Target)
201 add_subdirectory(lib/AsmParser)
202 add_subdirectory(lib/Debugger)
203 add_subdirectory(lib/Archive)
205 add_subdirectory(tools)
207 add_subdirectory(examples)
209 install(DIRECTORY include
211 PATTERN ".svn" EXCLUDE
212 PATTERN "*.cmake" EXCLUDE
213 PATTERN "*.in" EXCLUDE
216 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include
220 # TODO: make and install documentation.