blob: a4babed29fd81a3fc1b21d2dd88aa13455e614c8 [file] [log] [blame]
Oscar Fuentes34fc5172009-04-04 22:52:02 +00001# See docs/CMake.html for instructions about how to build LLVM with CMake.
2
Cedric Venet1d083f42008-10-30 21:22:00 +00003project(LLVM)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +00004cmake_minimum_required(VERSION 2.6.1)
5
6set(PACKAGE_NAME llvm)
Daniel Dunbare53cd1a2010-06-25 16:29:14 +00007set(PACKAGE_VERSION 2.8svn)
Chris Lattner8c46e852009-01-28 17:49:03 +00008set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
Oscar Fuentesf7e73b92008-10-25 03:49:35 +00009set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu")
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000010
Oscar Fuentes6326a0d2008-11-14 03:43:18 +000011if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
12 message(FATAL_ERROR "In-source builds are not allowed.
13CMake would overwrite the makefiles distributed with LLVM.
14Please create a directory and run cmake from there, passing the path
15to this source directory as the last argument.
16This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
17Please delete them.")
18endif()
19
Oscar Fuentes81a87552009-06-03 15:11:25 +000020string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
21
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000022set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Oscar Fuentes980e8422008-10-29 02:33:15 +000023set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000024set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
25set(LLVM_TOOLS_BINARY_DIR ${LLVM_BINARY_DIR}/bin)
26set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
Oscar Fuentesaf0f65f2009-06-12 02:49:53 +000027set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000028
Oscar Fuentes6761c5d2009-07-13 21:58:44 +000029if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
30 file(GLOB_RECURSE
31 tablegenned_files_on_include_dir
32 "${LLVM_MAIN_SRC_DIR}/include/llvm/*.gen")
33 file(GLOB_RECURSE
34 tablegenned_files_on_lib_dir
35 "${LLVM_MAIN_SRC_DIR}/lib/Target/*.inc")
36 if( tablegenned_files_on_include_dir OR tablegenned_files_on_lib_dir)
37 message(FATAL_ERROR "Apparently there is a previous in-source build,
38probably as the result of running `configure' and `make' on
39${LLVM_MAIN_SRC_DIR}.
40This may cause problems. The suspicious files are:
41${tablegenned_files_on_lib_dir}
42${tablegenned_files_on_include_dir}
43Please clean the source directory.")
44 endif()
45endif()
46
Oscar Fuentes4f21c132008-11-10 01:47:07 +000047set(LLVM_ALL_TARGETS
48 Alpha
49 ARM
Jakob Stoklund Olesen73b7bb72009-08-02 17:32:37 +000050 Blackfin
Oscar Fuentes4f21c132008-11-10 01:47:07 +000051 CBackend
52 CellSPU
53 CppBackend
Oscar Fuentes4f21c132008-11-10 01:47:07 +000054 Mips
Wesley Peckc84a9562010-03-05 15:15:55 +000055 MBlaze
Oscar Fuentes4f21c132008-11-10 01:47:07 +000056 MSIL
Richard Penningtona51984b2009-07-09 20:27:09 +000057 MSP430
Oscar Fuentes4f21c132008-11-10 01:47:07 +000058 PIC16
59 PowerPC
60 Sparc
Daniel Dunbar3f189a32009-07-20 00:24:17 +000061 SystemZ
Oscar Fuentes4f21c132008-11-10 01:47:07 +000062 X86
63 XCore
64 )
65
Oscar Fuentese1ad0872008-09-26 04:40:32 +000066if( MSVC )
67 set(LLVM_TARGETS_TO_BUILD X86
Oscar Fuentes4f21c132008-11-10 01:47:07 +000068 CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
Oscar Fuentese1ad0872008-09-26 04:40:32 +000069else( MSVC )
Oscar Fuentes4f21c132008-11-10 01:47:07 +000070 set(LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS}
71 CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
Oscar Fuentese1ad0872008-09-26 04:40:32 +000072endif( MSVC )
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000073
Oscar Fuentes8e3c1692009-11-12 06:48:09 +000074set(C_INCLUDE_DIRS "" CACHE STRING
75 "Colon separated list of directories clang will search for headers.")
76
Oscar Fuentesa9ff1392009-09-13 22:18:38 +000077set(LLVM_TARGET_ARCH "host"
78 CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.")
79
Oscar Fuentes4b442832008-11-18 23:45:21 +000080option(LLVM_ENABLE_THREADS "Use threads if available." ON)
81
Oscar Fuentes81a87552009-06-03 15:11:25 +000082if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
Oscar Fuentes76941b22009-06-04 09:26:16 +000083 option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF)
Oscar Fuentes81a87552009-06-03 15:11:25 +000084else()
Oscar Fuentes76941b22009-06-04 09:26:16 +000085 option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
Oscar Fuentes81a87552009-06-03 15:11:25 +000086endif()
87
Oscar Fuentes76941b22009-06-04 09:26:16 +000088if( LLVM_ENABLE_ASSERTIONS )
Oscar Fuentesaf109102009-07-05 18:43:52 +000089 # MSVC doesn't like _DEBUG on release builds. See PR 4379.
Oscar Fuentese8c81ea2009-07-05 23:58:20 +000090 if( NOT MSVC )
Oscar Fuentesaf109102009-07-05 18:43:52 +000091 add_definitions( -D_DEBUG )
92 endif()
Oscar Fuentes76941b22009-06-04 09:26:16 +000093 # On Release builds cmake automatically defines NDEBUG, so we
94 # explicitly undefine it:
95 if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
96 add_definitions( -UNDEBUG )
97 endif()
98else()
99 if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
100 add_definitions( -DNDEBUG )
101 endif()
Oscar Fuentes81a87552009-06-03 15:11:25 +0000102endif()
103
Oscar Fuentes4f21c132008-11-10 01:47:07 +0000104if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
105 set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
106endif()
107
Douglas Gregor1555a232009-06-16 20:12:29 +0000108set(LLVM_ENUM_TARGETS "")
Oscar Fuentes4f21c132008-11-10 01:47:07 +0000109foreach(c ${LLVM_TARGETS_TO_BUILD})
110 list(FIND LLVM_ALL_TARGETS ${c} idx)
111 if( idx LESS 0 )
Gabor Greif9befba82009-08-12 08:37:37 +0000112 message(FATAL_ERROR "The target `${c}' does not exist.
Oscar Fuentes4f21c132008-11-10 01:47:07 +0000113 It should be one of\n${LLVM_ALL_TARGETS}")
Douglas Gregor1555a232009-06-16 20:12:29 +0000114 else()
115 set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${c})\n")
Oscar Fuentes4f21c132008-11-10 01:47:07 +0000116 endif()
117endforeach(c)
118
Douglas Gregor1555a232009-06-16 20:12:29 +0000119# Produce llvm/Config/Targets.def
120configure_file(
121 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.def.in
122 ${LLVM_BINARY_DIR}/include/llvm/Config/Targets.def
123 )
124
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000125set(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm)
126
127# Add path for custom modules
128set(CMAKE_MODULE_PATH
129 ${CMAKE_MODULE_PATH}
130 "${LLVM_MAIN_SRC_DIR}/cmake"
131 "${LLVM_MAIN_SRC_DIR}/cmake/modules"
132 )
133
Oscar Fuentes9a0107d2009-04-04 22:41:07 +0000134include(AddLLVMDefinitions)
135
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000136if(WIN32)
Oscar Fuentes4fd38b82008-10-30 17:15:54 +0000137 if(CYGWIN)
138 set(LLVM_ON_WIN32 0)
139 set(LLVM_ON_UNIX 1)
140 else(CYGWIN)
141 set(LLVM_ON_WIN32 1)
142 set(LLVM_ON_UNIX 0)
143 endif(CYGWIN)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000144 set(LTDL_SHLIB_EXT ".dll")
145 set(EXEEXT ".exe")
146 # Maximum path length is 160 for non-unicode paths
147 set(MAXPATHLEN 160)
148else(WIN32)
149 if(UNIX)
150 set(LLVM_ON_WIN32 0)
151 set(LLVM_ON_UNIX 1)
Daniel Dunbar05dafd82009-09-22 06:09:37 +0000152 if(APPLE)
153 set(LTDL_SHLIB_EXT ".dylib")
154 else(APPLE)
155 set(LTDL_SHLIB_EXT ".so")
156 endif(APPLE)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000157 set(EXEEXT "")
158 # FIXME: Maximum path length is currently set to 'safe' fixed value
159 set(MAXPATHLEN 2024)
160 else(UNIX)
161 MESSAGE(SEND_ERROR "Unable to determine platform")
162 endif(UNIX)
163endif(WIN32)
164
Oscar Fuentesde98db32008-10-25 03:29:36 +0000165include(config-ix)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000166
Oscar Fuentes1e02bf02009-08-18 15:29:35 +0000167option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
Oscar Fuentes64fb4c82008-11-20 19:13:51 +0000168
Douglas Gregor318de602009-06-05 23:46:34 +0000169set(ENABLE_PIC 0)
Oscar Fuentes64fb4c82008-11-20 19:13:51 +0000170if( LLVM_ENABLE_PIC )
Daniel Dunbar36206182009-11-08 00:34:22 +0000171 if( XCODE )
172 # Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't
173 # know how to disable this, so just force ENABLE_PIC off for now.
174 message(STATUS "Warning: -fPIC not supported with Xcode.")
175 else( XCODE )
176 if( SUPPORTS_FPIC_FLAG )
177 message(STATUS "Building with -fPIC")
178 add_llvm_definitions(-fPIC)
179 set(ENABLE_PIC 1)
180 else( SUPPORTS_FPIC_FLAG )
181 message(STATUS "Warning: -fPIC not supported.")
182 endif()
183 endif()
Oscar Fuentes64fb4c82008-11-20 19:13:51 +0000184endif()
185
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000186set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} )
187set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
188set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
189
190# set(CMAKE_VERBOSE_MAKEFILE true)
191
Oscar Fuentes9a0107d2009-04-04 22:41:07 +0000192add_llvm_definitions( -D__STDC_LIMIT_MACROS )
193add_llvm_definitions( -D__STDC_CONSTANT_MACROS )
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000194
Daniel Dunbar9ea3a2c2009-12-01 19:11:36 +0000195# MSVC has a gazillion warnings with this.
196if( MSVC )
197 option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." OFF)
198else( MSVC )
199 option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
200endif()
201
Oscar Fuentesf12a9002009-12-01 02:21:51 +0000202option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
203option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
204
Oscar Fuentesb0c56992008-11-04 03:27:24 +0000205if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
206 # TODO: support other platforms and toolchains.
Oscar Fuentes6307b942008-11-19 00:10:39 +0000207 option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
208 if( LLVM_BUILD_32_BITS )
Oscar Fuentesb0c56992008-11-04 03:27:24 +0000209 message(STATUS "Building 32 bits executables and libraries.")
Oscar Fuentes9a0107d2009-04-04 22:41:07 +0000210 add_llvm_definitions( -m32 )
Oscar Fuentes6307b942008-11-19 00:10:39 +0000211 list(APPEND CMAKE_EXE_LINKER_FLAGS -m32)
212 list(APPEND CMAKE_SHARED_LINKER_FLAGS -m32)
Oscar Fuentes6307b942008-11-19 00:10:39 +0000213 endif( LLVM_BUILD_32_BITS )
Oscar Fuentesb0c56992008-11-04 03:27:24 +0000214endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
215
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000216if( MSVC )
Stefanus Du Toit4ba3a0e2009-06-08 21:18:31 +0000217 # List of valid CRTs for MSVC
218 set(MSVC_CRT
219 MD
Oscar Fuentes3f0cc8c2010-03-18 13:52:05 +0000220 MDd
221 MT
222 MTd)
Stefanus Du Toit4ba3a0e2009-06-08 21:18:31 +0000223
224 set(LLVM_USE_CRT "" CACHE STRING "Specify VC++ CRT to use for debug/release configurations.")
Oscar Fuentes9a0107d2009-04-04 22:41:07 +0000225 add_llvm_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS )
226 add_llvm_definitions( -D_SCL_SECURE_NO_WARNINGS -DCRT_NONSTDC_NO_WARNINGS )
227 add_llvm_definitions( -D_SCL_SECURE_NO_DEPRECATE )
228 add_llvm_definitions( -wd4146 -wd4503 -wd4996 -wd4800 -wd4244 -wd4624 )
229 add_llvm_definitions( -wd4355 -wd4715 -wd4180 -wd4345 -wd4224 )
Stefanus Du Toit4ba3a0e2009-06-08 21:18:31 +0000230
Daniel Dunbar2c4df5a2009-07-19 01:35:10 +0000231 # Suppress 'new behavior: elements of array 'array' will be default initialized'
232 add_llvm_definitions( -wd4351 )
233
Stefanus Du Toit4ba3a0e2009-06-08 21:18:31 +0000234 if (NOT ${LLVM_USE_CRT} STREQUAL "")
235 list(FIND MSVC_CRT ${LLVM_USE_CRT} idx)
236 if (idx LESS 0)
237 message(FATAL_ERROR "Invalid value for LLVM_USE_CRT: ${LLVM_USE_CRT}. Valid options are one of: ${MSVC_CRT}")
238 endif (idx LESS 0)
239 add_llvm_definitions("/${LLVM_USE_CRT}")
240 message(STATUS "Using VC++ CRT: ${LLVM_USE_CRT}")
241 endif (NOT ${LLVM_USE_CRT} STREQUAL "")
Oscar Fuentesf12a9002009-12-01 02:21:51 +0000242
243 # Enable warnings
244 if (LLVM_ENABLE_WARNINGS)
245 add_llvm_definitions( /W4 /Wall )
246 if (LLVM_ENABLE_PEDANTIC)
247 # No MSVC equivalent available
248 endif (LLVM_ENABLE_PEDANTIC)
249 endif (LLVM_ENABLE_WARNINGS)
250 if (LLVM_ENABLE_WERROR)
251 add_llvm_definitions( /WX )
252 endif (LLVM_ENABLE_WERROR)
Oscar Fuentes2343b102009-11-30 23:50:14 +0000253elseif( CMAKE_COMPILER_IS_GNUCXX )
Oscar Fuentesf12a9002009-12-01 02:21:51 +0000254 if (LLVM_ENABLE_WARNINGS)
255 add_llvm_definitions( -Wall -W -Wno-unused-parameter -Wwrite-strings )
256 if (LLVM_ENABLE_PEDANTIC)
257 add_llvm_definitions( -pedantic -Wno-long-long )
258 endif (LLVM_ENABLE_PEDANTIC)
259 endif (LLVM_ENABLE_WARNINGS)
260 if (LLVM_ENABLE_WERROR)
261 add_llvm_definitions( -Werror )
262 endif (LLVM_ENABLE_WERROR)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000263endif( MSVC )
264
Oscar Fuentes980e8422008-10-29 02:33:15 +0000265include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR})
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000266
Edward O'Callaghanc6cf5fe2009-10-12 04:00:11 +0000267if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
268 SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-include llvm/System/Solaris.h")
269endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
270
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000271include(AddLLVM)
Oscar Fuentese1ad0872008-09-26 04:40:32 +0000272include(TableGen)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000273
274add_subdirectory(lib/Support)
275add_subdirectory(lib/System)
Oscar Fuentes1d8e4cf2008-09-22 18:21:51 +0000276
277# Everything else depends on Support and System:
278set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} )
279
Oscar Fuentes3ab40ca2008-11-09 18:53:19 +0000280set(LLVM_TABLEGEN "tblgen" CACHE
Oscar Fuentes41bdedf2008-11-10 02:35:55 +0000281 STRING "Native TableGen executable. Saves building one when cross-compiling.")
Oscar Fuentes99b94892009-06-11 04:16:10 +0000282# Effective tblgen executable to be used:
283set(LLVM_TABLEGEN_EXE ${LLVM_TABLEGEN})
Oscar Fuentes3ab40ca2008-11-09 18:53:19 +0000284
Oscar Fuentes02516ba2008-11-10 01:32:14 +0000285add_subdirectory(utils/TableGen)
286
Oscar Fuentes3ab40ca2008-11-09 18:53:19 +0000287if( CMAKE_CROSSCOMPILING )
Oscar Fuentes02516ba2008-11-10 01:32:14 +0000288 # This adds a dependency on target `tblgen', so must go after utils/TableGen
Oscar Fuentes3ab40ca2008-11-09 18:53:19 +0000289 include( CrossCompileLLVM )
290endif( CMAKE_CROSSCOMPILING )
291
Oscar Fuentes422fcf32008-11-15 00:24:38 +0000292add_subdirectory(include/llvm)
Oscar Fuentes1d8e4cf2008-09-22 18:21:51 +0000293
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000294add_subdirectory(lib/VMCore)
295add_subdirectory(lib/CodeGen)
296add_subdirectory(lib/CodeGen/SelectionDAG)
297add_subdirectory(lib/CodeGen/AsmPrinter)
298add_subdirectory(lib/Bitcode/Reader)
299add_subdirectory(lib/Bitcode/Writer)
300add_subdirectory(lib/Transforms/Utils)
301add_subdirectory(lib/Transforms/Instrumentation)
Douglas Gregorf1c3a862010-01-04 21:58:55 +0000302add_subdirectory(lib/Transforms/InstCombine)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000303add_subdirectory(lib/Transforms/Scalar)
304add_subdirectory(lib/Transforms/IPO)
305add_subdirectory(lib/Transforms/Hello)
306add_subdirectory(lib/Linker)
307add_subdirectory(lib/Analysis)
308add_subdirectory(lib/Analysis/IPA)
Daniel Dunbarecc63f82009-06-23 22:01:43 +0000309add_subdirectory(lib/MC)
Daniel Dunbar4bd8dc32010-01-22 02:04:33 +0000310add_subdirectory(lib/MC/MCParser)
Chris Lattner847da552010-07-20 18:25:19 +0000311add_subdirectory(lib/MC/MCDisassembler)
Daniel Dunbara1774922009-09-22 07:38:44 +0000312add_subdirectory(test)
Oscar Fuentese1ad0872008-09-26 04:40:32 +0000313
Douglas Gregor4d20c242009-07-20 18:30:25 +0000314add_subdirectory(utils/FileCheck)
Daniel Dunbar48f7ce82009-09-24 06:23:57 +0000315add_subdirectory(utils/count)
316add_subdirectory(utils/not)
Douglas Gregor4d20c242009-07-20 18:30:25 +0000317
Oscar Fuentes75caad42009-08-14 04:55:21 +0000318set(LLVM_ENUM_ASM_PRINTERS "")
319set(LLVM_ENUM_ASM_PARSERS "")
Daniel Dunbarfa3f0b92009-11-25 04:30:13 +0000320set(LLVM_ENUM_DISASSEMBLERS "")
Oscar Fuentes75caad42009-08-14 04:55:21 +0000321foreach(t ${LLVM_TARGETS_TO_BUILD})
Oscar Fuentese1ad0872008-09-26 04:40:32 +0000322 message(STATUS "Targeting ${t}")
323 add_subdirectory(lib/Target/${t})
Daniel Dunbarb5a8c082009-07-15 07:04:27 +0000324 add_subdirectory(lib/Target/${t}/TargetInfo)
Oscar Fuentescccecb82008-11-14 22:21:02 +0000325 if( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt )
Oscar Fuentes75caad42009-08-14 04:55:21 +0000326 add_subdirectory(lib/Target/${t}/AsmPrinter)
Douglas Gregor1555a232009-06-16 20:12:29 +0000327 set(LLVM_ENUM_ASM_PRINTERS
Oscar Fuentes75caad42009-08-14 04:55:21 +0000328 "${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n")
329 endif( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt )
Daniel Dunbar092a9dd2009-07-17 20:42:00 +0000330 if( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmParser/CMakeLists.txt )
Oscar Fuentes75caad42009-08-14 04:55:21 +0000331 add_subdirectory(lib/Target/${t}/AsmParser)
Daniel Dunbar092a9dd2009-07-17 20:42:00 +0000332 set(LLVM_ENUM_ASM_PARSERS
Oscar Fuentes75caad42009-08-14 04:55:21 +0000333 "${LLVM_ENUM_ASM_PARSERS}LLVM_ASM_PARSER(${t})\n")
334 endif( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmParser/CMakeLists.txt )
Daniel Dunbarfa3f0b92009-11-25 04:30:13 +0000335 if( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/Disassembler/CMakeLists.txt )
336 add_subdirectory(lib/Target/${t}/Disassembler)
337 set(LLVM_ENUM_DISASSEMBLERS
338 "${LLVM_ENUM_DISASSEMBLERS}LLVM_DISASSEMBLER(${t})\n")
339 endif( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/Disassembler/CMakeLists.txt )
Oscar Fuentesb78829e2009-08-16 05:16:43 +0000340 set(CURRENT_LLVM_TARGET)
Oscar Fuentese1ad0872008-09-26 04:40:32 +0000341endforeach(t)
342
Douglas Gregor1555a232009-06-16 20:12:29 +0000343# Produce llvm/Config/AsmPrinters.def
344configure_file(
345 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmPrinters.def.in
346 ${LLVM_BINARY_DIR}/include/llvm/Config/AsmPrinters.def
347 )
348
Daniel Dunbar092a9dd2009-07-17 20:42:00 +0000349# Produce llvm/Config/AsmParsers.def
350configure_file(
351 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmParsers.def.in
352 ${LLVM_BINARY_DIR}/include/llvm/Config/AsmParsers.def
353 )
354
Daniel Dunbarfa3f0b92009-11-25 04:30:13 +0000355# Produce llvm/Config/Disassemblers.def
356configure_file(
357 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Disassemblers.def.in
358 ${LLVM_BINARY_DIR}/include/llvm/Config/Disassemblers.def
359 )
360
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000361add_subdirectory(lib/ExecutionEngine)
362add_subdirectory(lib/ExecutionEngine/Interpreter)
363add_subdirectory(lib/ExecutionEngine/JIT)
364add_subdirectory(lib/Target)
365add_subdirectory(lib/AsmParser)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000366add_subdirectory(lib/Archive)
367
Oscar Fuentes5c6bf652009-03-06 01:16:52 +0000368add_subdirectory(projects)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000369
Oscar Fuentesc81f56d2009-08-16 20:56:30 +0000370option(LLVM_BUILD_TOOLS "Build LLVM tool programs." ON)
Oscar Fuentesb8352de2009-11-23 00:21:43 +0000371add_subdirectory(tools)
Oscar Fuentesc81f56d2009-08-16 20:56:30 +0000372
Daniel Dunbare1caa982009-11-18 17:42:22 +0000373option(LLVM_BUILD_EXAMPLES "Build LLVM example programs." OFF)
Oscar Fuentesb8352de2009-11-23 00:21:43 +0000374add_subdirectory(examples)
Oscar Fuentes1dc97162008-10-22 02:56:07 +0000375
Oscar Fuentes1d7c43b2009-10-27 19:57:29 +0000376install(DIRECTORY include/
377 DESTINATION include
378 FILES_MATCHING
Oscar Fuentesbc2eb132009-10-30 11:42:08 +0000379 PATTERN "*.def"
Oscar Fuentes1d7c43b2009-10-27 19:57:29 +0000380 PATTERN "*.h"
381 PATTERN "*.td"
Oscar Fuentesa2281e72009-10-27 20:04:22 +0000382 PATTERN "*.inc"
Oscar Fuentes1dc97162008-10-22 02:56:07 +0000383 PATTERN ".svn" EXCLUDE
Oscar Fuentes1dc97162008-10-22 02:56:07 +0000384 )
385
Oscar Fuentes1d7c43b2009-10-27 19:57:29 +0000386install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
387 DESTINATION include
388 FILES_MATCHING
389 PATTERN "*.def"
390 PATTERN "*.h"
391 PATTERN "*.gen"
Oscar Fuentesa2281e72009-10-27 20:04:22 +0000392 PATTERN "*.inc"
Oscar Fuentes1d7c43b2009-10-27 19:57:29 +0000393 # Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def"
394 PATTERN "CMakeFiles" EXCLUDE
395 PATTERN ".svn" EXCLUDE
Oscar Fuentes1dc97162008-10-22 02:56:07 +0000396 )
397
398# TODO: make and install documentation.