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 set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} )
108 set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
109 set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
111 # set(CMAKE_VERBOSE_MAKEFILE true)
113 add_definitions( -D__STDC_LIMIT_MACROS )
114 add_definitions( -D__STDC_CONSTANT_MACROS )
116 set(LLVM_PLO_FLAGS "" CACHE
117 STRING "Flags for creating partially linked objects.")
119 if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
120 # TODO: support other platforms and toolchains.
121 option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
122 if( LLVM_BUILD_32_BITS )
123 message(STATUS "Building 32 bits executables and libraries.")
124 add_definitions( -m32 )
125 list(APPEND CMAKE_EXE_LINKER_FLAGS -m32)
126 list(APPEND CMAKE_SHARED_LINKER_FLAGS -m32)
127 set( LLVM_PLO_FLAGS -melf_i386 ${LLVM_PLO_FLAGS} )
128 endif( LLVM_BUILD_32_BITS )
129 endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
132 add_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS )
133 add_definitions( -D_SCL_SECURE_NO_WARNINGS -DCRT_NONSTDC_NO_WARNINGS )
134 add_definitions( -D_SCL_SECURE_NO_DEPRECATE )
135 add_definitions( -wd4146 -wd4503 -wd4996 -wd4800 -wd4244 -wd4624 )
136 add_definitions( -wd4355 -wd4715 )
139 include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR})
142 include(AddPartiallyLinkedObject)
145 add_subdirectory(lib/Support)
146 add_subdirectory(lib/System)
148 # Everything else depends on Support and System:
149 set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} )
151 set(LLVM_TABLEGEN "tblgen" CACHE
152 STRING "Native TableGen executable. Saves building one when cross-compiling.")
154 add_subdirectory(utils/TableGen)
156 if( CMAKE_CROSSCOMPILING )
157 # This adds a dependency on target `tblgen', so must go after utils/TableGen
158 include( CrossCompileLLVM )
159 endif( CMAKE_CROSSCOMPILING )
161 add_subdirectory(include/llvm)
163 add_subdirectory(lib/VMCore)
164 add_subdirectory(lib/CodeGen)
165 add_subdirectory(lib/CodeGen/SelectionDAG)
166 add_subdirectory(lib/CodeGen/AsmPrinter)
167 add_subdirectory(lib/Bitcode/Reader)
168 add_subdirectory(lib/Bitcode/Writer)
169 add_subdirectory(lib/Transforms/Utils)
170 add_subdirectory(lib/Transforms/Instrumentation)
171 add_subdirectory(lib/Transforms/Scalar)
172 add_subdirectory(lib/Transforms/IPO)
173 add_subdirectory(lib/Transforms/Hello)
174 add_subdirectory(lib/Linker)
175 add_subdirectory(lib/Analysis)
176 add_subdirectory(lib/Analysis/IPA)
178 foreach(t ${LLVM_TARGETS_TO_BUILD})
179 message(STATUS "Targeting ${t}")
180 add_subdirectory(lib/Target/${t})
181 if( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt )
182 add_subdirectory(lib/Target/${t}/AsmPrinter)
183 endif( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt )
186 add_subdirectory(lib/ExecutionEngine)
187 add_subdirectory(lib/ExecutionEngine/Interpreter)
188 add_subdirectory(lib/ExecutionEngine/JIT)
189 add_subdirectory(lib/Target)
190 add_subdirectory(lib/AsmParser)
191 add_subdirectory(lib/Debugger)
192 add_subdirectory(lib/Archive)
194 add_subdirectory(tools)
196 add_subdirectory(examples)
198 install(DIRECTORY include
200 PATTERN ".svn" EXCLUDE
201 PATTERN "*.cmake" EXCLUDE
202 PATTERN "*.in" EXCLUDE
205 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include
209 # TODO: make and install documentation.