blob: 3300fddae736397e8db2dadb170b1d9a6dc61146 [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 Fuentesc677c5d2010-08-03 15:07:17 +00004cmake_minimum_required(VERSION 2.8)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +00005
Oscar Fuentesee993172010-08-03 17:28:09 +00006# Add path for custom modules
7set(CMAKE_MODULE_PATH
8 ${CMAKE_MODULE_PATH}
9 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
10 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
11 )
12
Douglas Gregor6b5db952010-09-23 14:19:21 +000013set(PACKAGE_VERSION "2.9")
Oscar Fuentesee993172010-08-03 17:28:09 +000014include(VersionFromVCS)
15add_version_info_from_vcs(PACKAGE_VERSION)
16
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000017set(PACKAGE_NAME llvm)
Chris Lattner8c46e852009-01-28 17:49:03 +000018set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
Oscar Fuentesf7e73b92008-10-25 03:49:35 +000019set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu")
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000020
Oscar Fuentes6326a0d2008-11-14 03:43:18 +000021if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
22 message(FATAL_ERROR "In-source builds are not allowed.
23CMake would overwrite the makefiles distributed with LLVM.
24Please create a directory and run cmake from there, passing the path
25to this source directory as the last argument.
26This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
27Please delete them.")
28endif()
29
Oscar Fuentes81a87552009-06-03 15:11:25 +000030string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
31
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000032set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Oscar Fuentes980e8422008-10-29 02:33:15 +000033set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000034set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
35set(LLVM_TOOLS_BINARY_DIR ${LLVM_BINARY_DIR}/bin)
36set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
Oscar Fuentesaf0f65f2009-06-12 02:49:53 +000037set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000038
Oscar Fuentes6761c5d2009-07-13 21:58:44 +000039if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
40 file(GLOB_RECURSE
41 tablegenned_files_on_include_dir
42 "${LLVM_MAIN_SRC_DIR}/include/llvm/*.gen")
43 file(GLOB_RECURSE
44 tablegenned_files_on_lib_dir
45 "${LLVM_MAIN_SRC_DIR}/lib/Target/*.inc")
46 if( tablegenned_files_on_include_dir OR tablegenned_files_on_lib_dir)
47 message(FATAL_ERROR "Apparently there is a previous in-source build,
48probably as the result of running `configure' and `make' on
49${LLVM_MAIN_SRC_DIR}.
50This may cause problems. The suspicious files are:
51${tablegenned_files_on_lib_dir}
52${tablegenned_files_on_include_dir}
53Please clean the source directory.")
54 endif()
55endif()
56
Oscar Fuentes4f21c132008-11-10 01:47:07 +000057set(LLVM_ALL_TARGETS
58 Alpha
59 ARM
Jakob Stoklund Olesen73b7bb72009-08-02 17:32:37 +000060 Blackfin
Oscar Fuentes4f21c132008-11-10 01:47:07 +000061 CBackend
62 CellSPU
63 CppBackend
Oscar Fuentes4f21c132008-11-10 01:47:07 +000064 Mips
Wesley Peckc84a9562010-03-05 15:15:55 +000065 MBlaze
Richard Penningtona51984b2009-07-09 20:27:09 +000066 MSP430
Oscar Fuentes4f21c132008-11-10 01:47:07 +000067 PowerPC
Oscar Fuentesb2c70cf2010-09-28 14:02:36 +000068 PTX
Oscar Fuentes4f21c132008-11-10 01:47:07 +000069 Sparc
Daniel Dunbar3f189a32009-07-20 00:24:17 +000070 SystemZ
Oscar Fuentes4f21c132008-11-10 01:47:07 +000071 X86
72 XCore
73 )
74
Oscar Fuentese1ad0872008-09-26 04:40:32 +000075if( MSVC )
76 set(LLVM_TARGETS_TO_BUILD X86
Oscar Fuentes4f21c132008-11-10 01:47:07 +000077 CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
Oscar Fuentese1ad0872008-09-26 04:40:32 +000078else( MSVC )
Oscar Fuentes4f21c132008-11-10 01:47:07 +000079 set(LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS}
80 CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
Oscar Fuentese1ad0872008-09-26 04:40:32 +000081endif( MSVC )
Oscar Fuentes3d01fc72008-09-22 01:08:49 +000082
Chandler Carruth6b241162010-10-19 08:21:25 +000083set(CLANG_RESOURCE_DIR "" CACHE STRING
84 "Relative directory from the Clang binary to its resource files.")
85
Oscar Fuentes8e3c1692009-11-12 06:48:09 +000086set(C_INCLUDE_DIRS "" CACHE STRING
87 "Colon separated list of directories clang will search for headers.")
88
Oscar Fuentesa9ff1392009-09-13 22:18:38 +000089set(LLVM_TARGET_ARCH "host"
90 CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.")
91
NAKAMURA Takumie7ae70b2010-11-11 04:09:35 +000092set(LIT_ARGS_DEFAULT "-sv")
93if (MSVC OR XCODE)
94 set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
95endif()
96set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}"
97 CACHE STRING "Default options for lit")
98
Oscar Fuentes4b442832008-11-18 23:45:21 +000099option(LLVM_ENABLE_THREADS "Use threads if available." ON)
100
Oscar Fuentes81a87552009-06-03 15:11:25 +0000101if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
Oscar Fuentes76941b22009-06-04 09:26:16 +0000102 option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF)
Oscar Fuentes81a87552009-06-03 15:11:25 +0000103else()
Oscar Fuentes76941b22009-06-04 09:26:16 +0000104 option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
Oscar Fuentes81a87552009-06-03 15:11:25 +0000105endif()
106
Oscar Fuentes76941b22009-06-04 09:26:16 +0000107if( LLVM_ENABLE_ASSERTIONS )
Oscar Fuentesaf109102009-07-05 18:43:52 +0000108 # MSVC doesn't like _DEBUG on release builds. See PR 4379.
Oscar Fuentese8c81ea2009-07-05 23:58:20 +0000109 if( NOT MSVC )
Oscar Fuentesaf109102009-07-05 18:43:52 +0000110 add_definitions( -D_DEBUG )
111 endif()
Oscar Fuentes76941b22009-06-04 09:26:16 +0000112 # On Release builds cmake automatically defines NDEBUG, so we
113 # explicitly undefine it:
114 if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
115 add_definitions( -UNDEBUG )
116 endif()
117else()
118 if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
119 add_definitions( -DNDEBUG )
120 endif()
Oscar Fuentes81a87552009-06-03 15:11:25 +0000121endif()
122
Oscar Fuentes4f21c132008-11-10 01:47:07 +0000123if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
124 set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
125endif()
126
Douglas Gregor1555a232009-06-16 20:12:29 +0000127set(LLVM_ENUM_TARGETS "")
Oscar Fuentes4f21c132008-11-10 01:47:07 +0000128foreach(c ${LLVM_TARGETS_TO_BUILD})
129 list(FIND LLVM_ALL_TARGETS ${c} idx)
130 if( idx LESS 0 )
Gabor Greif9befba82009-08-12 08:37:37 +0000131 message(FATAL_ERROR "The target `${c}' does not exist.
Oscar Fuentes4f21c132008-11-10 01:47:07 +0000132 It should be one of\n${LLVM_ALL_TARGETS}")
Douglas Gregor1555a232009-06-16 20:12:29 +0000133 else()
134 set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${c})\n")
Oscar Fuentes4f21c132008-11-10 01:47:07 +0000135 endif()
136endforeach(c)
137
Douglas Gregor1555a232009-06-16 20:12:29 +0000138# Produce llvm/Config/Targets.def
139configure_file(
140 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.def.in
141 ${LLVM_BINARY_DIR}/include/llvm/Config/Targets.def
142 )
143
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000144set(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm)
145
Oscar Fuentes9a0107d2009-04-04 22:41:07 +0000146include(AddLLVMDefinitions)
147
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000148if(WIN32)
Oscar Fuentes4fd38b82008-10-30 17:15:54 +0000149 if(CYGWIN)
150 set(LLVM_ON_WIN32 0)
151 set(LLVM_ON_UNIX 1)
152 else(CYGWIN)
153 set(LLVM_ON_WIN32 1)
154 set(LLVM_ON_UNIX 0)
155 endif(CYGWIN)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000156 set(LTDL_SHLIB_EXT ".dll")
157 set(EXEEXT ".exe")
158 # Maximum path length is 160 for non-unicode paths
159 set(MAXPATHLEN 160)
160else(WIN32)
161 if(UNIX)
162 set(LLVM_ON_WIN32 0)
163 set(LLVM_ON_UNIX 1)
Daniel Dunbar05dafd82009-09-22 06:09:37 +0000164 if(APPLE)
165 set(LTDL_SHLIB_EXT ".dylib")
166 else(APPLE)
167 set(LTDL_SHLIB_EXT ".so")
168 endif(APPLE)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000169 set(EXEEXT "")
170 # FIXME: Maximum path length is currently set to 'safe' fixed value
171 set(MAXPATHLEN 2024)
172 else(UNIX)
173 MESSAGE(SEND_ERROR "Unable to determine platform")
174 endif(UNIX)
175endif(WIN32)
176
Oscar Fuentesde98db32008-10-25 03:29:36 +0000177include(config-ix)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000178
Oscar Fuentes1e02bf02009-08-18 15:29:35 +0000179option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
Oscar Fuentes64fb4c82008-11-20 19:13:51 +0000180
Douglas Gregor318de602009-06-05 23:46:34 +0000181set(ENABLE_PIC 0)
Oscar Fuentes64fb4c82008-11-20 19:13:51 +0000182if( LLVM_ENABLE_PIC )
Daniel Dunbar36206182009-11-08 00:34:22 +0000183 if( XCODE )
184 # Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't
185 # know how to disable this, so just force ENABLE_PIC off for now.
186 message(STATUS "Warning: -fPIC not supported with Xcode.")
187 else( XCODE )
188 if( SUPPORTS_FPIC_FLAG )
189 message(STATUS "Building with -fPIC")
190 add_llvm_definitions(-fPIC)
191 set(ENABLE_PIC 1)
192 else( SUPPORTS_FPIC_FLAG )
193 message(STATUS "Warning: -fPIC not supported.")
194 endif()
195 endif()
Oscar Fuentes64fb4c82008-11-20 19:13:51 +0000196endif()
197
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000198set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} )
199set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
200set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
201
202# set(CMAKE_VERBOSE_MAKEFILE true)
203
Oscar Fuentes9a0107d2009-04-04 22:41:07 +0000204add_llvm_definitions( -D__STDC_LIMIT_MACROS )
205add_llvm_definitions( -D__STDC_CONSTANT_MACROS )
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000206
Daniel Dunbar9ea3a2c2009-12-01 19:11:36 +0000207# MSVC has a gazillion warnings with this.
208if( MSVC )
209 option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." OFF)
210else( MSVC )
211 option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
212endif()
213
Oscar Fuentesf12a9002009-12-01 02:21:51 +0000214option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
215option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
216
Oscar Fuentesb0c56992008-11-04 03:27:24 +0000217if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
218 # TODO: support other platforms and toolchains.
Oscar Fuentes6307b942008-11-19 00:10:39 +0000219 option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
220 if( LLVM_BUILD_32_BITS )
Oscar Fuentesb0c56992008-11-04 03:27:24 +0000221 message(STATUS "Building 32 bits executables and libraries.")
Oscar Fuentes9a0107d2009-04-04 22:41:07 +0000222 add_llvm_definitions( -m32 )
Oscar Fuentes6307b942008-11-19 00:10:39 +0000223 list(APPEND CMAKE_EXE_LINKER_FLAGS -m32)
224 list(APPEND CMAKE_SHARED_LINKER_FLAGS -m32)
Oscar Fuentes6307b942008-11-19 00:10:39 +0000225 endif( LLVM_BUILD_32_BITS )
Oscar Fuentesb0c56992008-11-04 03:27:24 +0000226endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
227
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000228if( MSVC )
Oscar Fuentes02a8f762010-08-05 01:25:48 +0000229 include(ChooseMSVCCRT)
Stefanus Du Toit4ba3a0e2009-06-08 21:18:31 +0000230
Oscar Fuentes9a0107d2009-04-04 22:41:07 +0000231 add_llvm_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS )
232 add_llvm_definitions( -D_SCL_SECURE_NO_WARNINGS -DCRT_NONSTDC_NO_WARNINGS )
233 add_llvm_definitions( -D_SCL_SECURE_NO_DEPRECATE )
234 add_llvm_definitions( -wd4146 -wd4503 -wd4996 -wd4800 -wd4244 -wd4624 )
Francois Pichetb2b9b762010-10-12 00:01:36 +0000235 add_llvm_definitions( -wd4355 -wd4715 -wd4180 -wd4345 -wd4224 -wd4267 )
Stefanus Du Toit4ba3a0e2009-06-08 21:18:31 +0000236
Daniel Dunbar2c4df5a2009-07-19 01:35:10 +0000237 # Suppress 'new behavior: elements of array 'array' will be default initialized'
238 add_llvm_definitions( -wd4351 )
239
Oscar Fuentesf12a9002009-12-01 02:21:51 +0000240 # Enable warnings
241 if (LLVM_ENABLE_WARNINGS)
242 add_llvm_definitions( /W4 /Wall )
243 if (LLVM_ENABLE_PEDANTIC)
244 # No MSVC equivalent available
245 endif (LLVM_ENABLE_PEDANTIC)
246 endif (LLVM_ENABLE_WARNINGS)
247 if (LLVM_ENABLE_WERROR)
248 add_llvm_definitions( /WX )
249 endif (LLVM_ENABLE_WERROR)
Oscar Fuentes2343b102009-11-30 23:50:14 +0000250elseif( CMAKE_COMPILER_IS_GNUCXX )
Oscar Fuentesf12a9002009-12-01 02:21:51 +0000251 if (LLVM_ENABLE_WARNINGS)
252 add_llvm_definitions( -Wall -W -Wno-unused-parameter -Wwrite-strings )
253 if (LLVM_ENABLE_PEDANTIC)
254 add_llvm_definitions( -pedantic -Wno-long-long )
255 endif (LLVM_ENABLE_PEDANTIC)
256 endif (LLVM_ENABLE_WARNINGS)
257 if (LLVM_ENABLE_WERROR)
258 add_llvm_definitions( -Werror )
259 endif (LLVM_ENABLE_WERROR)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000260endif( MSVC )
261
Oscar Fuentes980e8422008-10-29 02:33:15 +0000262include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR})
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000263
Edward O'Callaghanc6cf5fe2009-10-12 04:00:11 +0000264if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
265 SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-include llvm/System/Solaris.h")
266endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
267
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000268include(AddLLVM)
Oscar Fuentese1ad0872008-09-26 04:40:32 +0000269include(TableGen)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000270
Michael J. Spencer1c4e9342010-09-11 02:13:39 +0000271if( MINGW )
272 get_system_libs(LLVM_SYSTEM_LIBS_LIST)
273 foreach(l ${LLVM_SYSTEM_LIBS_LIST})
274 set(LLVM_SYSTEM_LIBS "${LLVM_SYSTEM_LIBS} -l${l}")
275 endforeach()
276 set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}${LLVM_SYSTEM_LIBS}")
277 set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}${LLVM_SYSTEM_LIBS}")
278endif()
279
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000280add_subdirectory(lib/Support)
281add_subdirectory(lib/System)
Oscar Fuentes1d8e4cf2008-09-22 18:21:51 +0000282
283# Everything else depends on Support and System:
284set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} )
285
Oscar Fuentes3ab40ca2008-11-09 18:53:19 +0000286set(LLVM_TABLEGEN "tblgen" CACHE
Oscar Fuentes41bdedf2008-11-10 02:35:55 +0000287 STRING "Native TableGen executable. Saves building one when cross-compiling.")
Oscar Fuentes99b94892009-06-11 04:16:10 +0000288# Effective tblgen executable to be used:
289set(LLVM_TABLEGEN_EXE ${LLVM_TABLEGEN})
Oscar Fuentes3ab40ca2008-11-09 18:53:19 +0000290
Oscar Fuentes02516ba2008-11-10 01:32:14 +0000291add_subdirectory(utils/TableGen)
292
Oscar Fuentes3ab40ca2008-11-09 18:53:19 +0000293if( CMAKE_CROSSCOMPILING )
Oscar Fuentes02516ba2008-11-10 01:32:14 +0000294 # This adds a dependency on target `tblgen', so must go after utils/TableGen
Oscar Fuentes3ab40ca2008-11-09 18:53:19 +0000295 include( CrossCompileLLVM )
296endif( CMAKE_CROSSCOMPILING )
297
Oscar Fuentes422fcf32008-11-15 00:24:38 +0000298add_subdirectory(include/llvm)
Oscar Fuentes1d8e4cf2008-09-22 18:21:51 +0000299
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000300add_subdirectory(lib/VMCore)
301add_subdirectory(lib/CodeGen)
302add_subdirectory(lib/CodeGen/SelectionDAG)
303add_subdirectory(lib/CodeGen/AsmPrinter)
304add_subdirectory(lib/Bitcode/Reader)
305add_subdirectory(lib/Bitcode/Writer)
306add_subdirectory(lib/Transforms/Utils)
307add_subdirectory(lib/Transforms/Instrumentation)
Douglas Gregorf1c3a862010-01-04 21:58:55 +0000308add_subdirectory(lib/Transforms/InstCombine)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000309add_subdirectory(lib/Transforms/Scalar)
310add_subdirectory(lib/Transforms/IPO)
311add_subdirectory(lib/Transforms/Hello)
312add_subdirectory(lib/Linker)
313add_subdirectory(lib/Analysis)
314add_subdirectory(lib/Analysis/IPA)
Daniel Dunbarecc63f82009-06-23 22:01:43 +0000315add_subdirectory(lib/MC)
Daniel Dunbar4bd8dc32010-01-22 02:04:33 +0000316add_subdirectory(lib/MC/MCParser)
Chris Lattner847da552010-07-20 18:25:19 +0000317add_subdirectory(lib/MC/MCDisassembler)
Oscar Fuentese1ad0872008-09-26 04:40:32 +0000318
Douglas Gregor4d20c242009-07-20 18:30:25 +0000319add_subdirectory(utils/FileCheck)
Daniel Dunbar48f7ce82009-09-24 06:23:57 +0000320add_subdirectory(utils/count)
321add_subdirectory(utils/not)
Michael J. Spencerbecf3922010-09-13 17:52:38 +0000322add_subdirectory(utils/llvm-lit)
Douglas Gregor4d20c242009-07-20 18:30:25 +0000323
Oscar Fuentes75caad42009-08-14 04:55:21 +0000324set(LLVM_ENUM_ASM_PRINTERS "")
325set(LLVM_ENUM_ASM_PARSERS "")
Daniel Dunbarfa3f0b92009-11-25 04:30:13 +0000326set(LLVM_ENUM_DISASSEMBLERS "")
Oscar Fuentes75caad42009-08-14 04:55:21 +0000327foreach(t ${LLVM_TARGETS_TO_BUILD})
Oscar Fuentese1ad0872008-09-26 04:40:32 +0000328 message(STATUS "Targeting ${t}")
329 add_subdirectory(lib/Target/${t})
Daniel Dunbarb5a8c082009-07-15 07:04:27 +0000330 add_subdirectory(lib/Target/${t}/TargetInfo)
Oscar Fuentesdb2c5092010-11-14 21:17:13 +0000331 set( td ${LLVM_MAIN_SRC_DIR}/lib/Target/${t} )
332 file(GLOB asmp_file "${td}/*AsmPrinter.cpp")
333 if( asmp_file )
Chris Lattneraeafb892010-11-14 19:12:57 +0000334 set(LLVM_ENUM_ASM_PRINTERS
335 "${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n")
Oscar Fuentes14b0c052010-11-14 20:15:05 +0000336 endif()
Oscar Fuentesdb2c5092010-11-14 21:17:13 +0000337 if( EXISTS ${td}/InstPrinter/CMakeLists.txt )
Oscar Fuentesbab2b012010-10-02 02:38:42 +0000338 add_subdirectory(lib/Target/${t}/InstPrinter)
Oscar Fuentesdb2c5092010-11-14 21:17:13 +0000339 endif()
340 if( EXISTS ${td}/AsmParser/CMakeLists.txt )
Oscar Fuentes75caad42009-08-14 04:55:21 +0000341 add_subdirectory(lib/Target/${t}/AsmParser)
Daniel Dunbar092a9dd2009-07-17 20:42:00 +0000342 set(LLVM_ENUM_ASM_PARSERS
Oscar Fuentes75caad42009-08-14 04:55:21 +0000343 "${LLVM_ENUM_ASM_PARSERS}LLVM_ASM_PARSER(${t})\n")
Oscar Fuentesdb2c5092010-11-14 21:17:13 +0000344 endif()
345 if( EXISTS ${td}/Disassembler/CMakeLists.txt )
Daniel Dunbarfa3f0b92009-11-25 04:30:13 +0000346 add_subdirectory(lib/Target/${t}/Disassembler)
347 set(LLVM_ENUM_DISASSEMBLERS
348 "${LLVM_ENUM_DISASSEMBLERS}LLVM_DISASSEMBLER(${t})\n")
Oscar Fuentesdb2c5092010-11-14 21:17:13 +0000349 endif()
Oscar Fuentesb78829e2009-08-16 05:16:43 +0000350 set(CURRENT_LLVM_TARGET)
Oscar Fuentese1ad0872008-09-26 04:40:32 +0000351endforeach(t)
352
Douglas Gregor1555a232009-06-16 20:12:29 +0000353# Produce llvm/Config/AsmPrinters.def
354configure_file(
355 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmPrinters.def.in
356 ${LLVM_BINARY_DIR}/include/llvm/Config/AsmPrinters.def
357 )
358
Daniel Dunbar092a9dd2009-07-17 20:42:00 +0000359# Produce llvm/Config/AsmParsers.def
360configure_file(
361 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmParsers.def.in
362 ${LLVM_BINARY_DIR}/include/llvm/Config/AsmParsers.def
363 )
364
Daniel Dunbarfa3f0b92009-11-25 04:30:13 +0000365# Produce llvm/Config/Disassemblers.def
366configure_file(
367 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Disassemblers.def.in
368 ${LLVM_BINARY_DIR}/include/llvm/Config/Disassemblers.def
369 )
370
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000371add_subdirectory(lib/ExecutionEngine)
372add_subdirectory(lib/ExecutionEngine/Interpreter)
373add_subdirectory(lib/ExecutionEngine/JIT)
374add_subdirectory(lib/Target)
375add_subdirectory(lib/AsmParser)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000376add_subdirectory(lib/Archive)
377
Oscar Fuentes5c6bf652009-03-06 01:16:52 +0000378add_subdirectory(projects)
Oscar Fuentes3d01fc72008-09-22 01:08:49 +0000379
Oscar Fuentesa6c1dbd2010-09-25 20:43:06 +0000380option(LLVM_BUILD_TOOLS
381 "Build the LLVM tools. If OFF, just generate build targets." ON)
382option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON)
383if( LLVM_INCLUDE_TOOLS )
384 add_subdirectory(tools)
385endif()
Oscar Fuentesc81f56d2009-08-16 20:56:30 +0000386
Oscar Fuentesa6c1dbd2010-09-25 20:43:06 +0000387option(LLVM_BUILD_EXAMPLES
388 "Build the LLVM example programs. If OFF, just generate build targets." OFF)
389option(LLVM_INCLUDE_EXAMPLES "Generate build targets for the LLVM examples" ON)
390if( LLVM_INCLUDE_EXAMPLES )
391 add_subdirectory(examples)
392endif()
Oscar Fuentes1dc97162008-10-22 02:56:07 +0000393
Oscar Fuentesa6c1dbd2010-09-25 20:43:06 +0000394option(LLVM_BUILD_TESTS
395 "Build LLVM unit tests. If OFF, just generate build targes." OFF)
396option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON)
397if( LLVM_INCLUDE_TESTS )
398 add_subdirectory(test)
399 add_subdirectory(utils/unittest)
400 add_subdirectory(unittests)
NAKAMURA Takumi15b337c2010-10-26 05:08:27 +0000401 if (MSVC)
Michael J. Spencerbbb9ea72010-10-11 19:55:38 +0000402 # This utility is used to prevent chrashing tests from calling Dr. Watson on
403 # Windows.
404 add_subdirectory(utils/KillTheDoctor)
405 endif()
Oscar Fuentesa6c1dbd2010-09-25 20:43:06 +0000406endif()
Michael J. Spenceree6944f2010-09-24 09:01:13 +0000407
Oscar Fuentes6252e982010-08-09 03:26:43 +0000408add_subdirectory(cmake/modules)
409
Oscar Fuentes1d7c43b2009-10-27 19:57:29 +0000410install(DIRECTORY include/
411 DESTINATION include
412 FILES_MATCHING
Oscar Fuentesbc2eb132009-10-30 11:42:08 +0000413 PATTERN "*.def"
Oscar Fuentes1d7c43b2009-10-27 19:57:29 +0000414 PATTERN "*.h"
415 PATTERN "*.td"
Oscar Fuentesa2281e72009-10-27 20:04:22 +0000416 PATTERN "*.inc"
Oscar Fuentes1dc97162008-10-22 02:56:07 +0000417 PATTERN ".svn" EXCLUDE
Oscar Fuentes1dc97162008-10-22 02:56:07 +0000418 )
419
Oscar Fuentes1d7c43b2009-10-27 19:57:29 +0000420install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
421 DESTINATION include
422 FILES_MATCHING
423 PATTERN "*.def"
424 PATTERN "*.h"
425 PATTERN "*.gen"
Oscar Fuentesa2281e72009-10-27 20:04:22 +0000426 PATTERN "*.inc"
Oscar Fuentes1d7c43b2009-10-27 19:57:29 +0000427 # Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def"
428 PATTERN "CMakeFiles" EXCLUDE
429 PATTERN ".svn" EXCLUDE
Oscar Fuentes1dc97162008-10-22 02:56:07 +0000430 )
431
432# TODO: make and install documentation.
Oscar Fuentes4d156d32010-10-14 21:11:51 +0000433
434set(CPACK_PACKAGE_VENDOR "LLVM")
435set(CPACK_PACKAGE_VERSION_MAJOR 2)
436set(CPACK_PACKAGE_VERSION_MINOR 9)
437add_version_info_from_vcs(CPACK_PACKAGE_VERSION_PATCH)
438include(CPack)