Oscar Fuentes | 34fc517 | 2009-04-04 22:52:02 +0000 | [diff] [blame] | 1 | # See docs/CMake.html for instructions about how to build LLVM with CMake. |
| 2 | |
Cedric Venet | 1d083f4 | 2008-10-30 21:22:00 +0000 | [diff] [blame] | 3 | project(LLVM) |
Oscar Fuentes | c677c5d | 2010-08-03 15:07:17 +0000 | [diff] [blame] | 4 | cmake_minimum_required(VERSION 2.8) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 5 | |
Oscar Fuentes | ee99317 | 2010-08-03 17:28:09 +0000 | [diff] [blame] | 6 | # Add path for custom modules |
| 7 | set(CMAKE_MODULE_PATH |
| 8 | ${CMAKE_MODULE_PATH} |
| 9 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake" |
| 10 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" |
| 11 | ) |
| 12 | |
Douglas Gregor | 6b5db95 | 2010-09-23 14:19:21 +0000 | [diff] [blame] | 13 | set(PACKAGE_VERSION "2.9") |
Oscar Fuentes | ee99317 | 2010-08-03 17:28:09 +0000 | [diff] [blame] | 14 | include(VersionFromVCS) |
| 15 | add_version_info_from_vcs(PACKAGE_VERSION) |
| 16 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 17 | set(PACKAGE_NAME llvm) |
Chris Lattner | 8c46e85 | 2009-01-28 17:49:03 +0000 | [diff] [blame] | 18 | set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") |
Oscar Fuentes | f7e73b9 | 2008-10-25 03:49:35 +0000 | [diff] [blame] | 19 | set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu") |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 20 | |
Oscar Fuentes | 6326a0d | 2008-11-14 03:43:18 +0000 | [diff] [blame] | 21 | if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) |
| 22 | message(FATAL_ERROR "In-source builds are not allowed. |
| 23 | CMake would overwrite the makefiles distributed with LLVM. |
| 24 | Please create a directory and run cmake from there, passing the path |
| 25 | to this source directory as the last argument. |
| 26 | This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. |
| 27 | Please delete them.") |
| 28 | endif() |
| 29 | |
Oscar Fuentes | 81a8755 | 2009-06-03 15:11:25 +0000 | [diff] [blame] | 30 | string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) |
| 31 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 32 | set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
Oscar Fuentes | 980e842 | 2008-10-29 02:33:15 +0000 | [diff] [blame] | 33 | set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 34 | set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
| 35 | set(LLVM_TOOLS_BINARY_DIR ${LLVM_BINARY_DIR}/bin) |
| 36 | set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples) |
Oscar Fuentes | af0f65f | 2009-06-12 02:49:53 +0000 | [diff] [blame] | 37 | set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 38 | |
Oscar Fuentes | 6761c5d | 2009-07-13 21:58:44 +0000 | [diff] [blame] | 39 | if( 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, |
| 48 | probably as the result of running `configure' and `make' on |
| 49 | ${LLVM_MAIN_SRC_DIR}. |
| 50 | This may cause problems. The suspicious files are: |
| 51 | ${tablegenned_files_on_lib_dir} |
| 52 | ${tablegenned_files_on_include_dir} |
| 53 | Please clean the source directory.") |
| 54 | endif() |
| 55 | endif() |
| 56 | |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 57 | set(LLVM_ALL_TARGETS |
| 58 | Alpha |
| 59 | ARM |
Jakob Stoklund Olesen | 73b7bb7 | 2009-08-02 17:32:37 +0000 | [diff] [blame] | 60 | Blackfin |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 61 | CBackend |
| 62 | CellSPU |
| 63 | CppBackend |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 64 | Mips |
Wesley Peck | c84a956 | 2010-03-05 15:15:55 +0000 | [diff] [blame] | 65 | MBlaze |
Richard Pennington | a51984b | 2009-07-09 20:27:09 +0000 | [diff] [blame] | 66 | MSP430 |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 67 | PowerPC |
Oscar Fuentes | b2c70cf | 2010-09-28 14:02:36 +0000 | [diff] [blame] | 68 | PTX |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 69 | Sparc |
Daniel Dunbar | 3f189a3 | 2009-07-20 00:24:17 +0000 | [diff] [blame] | 70 | SystemZ |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 71 | X86 |
| 72 | XCore |
| 73 | ) |
| 74 | |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 75 | if( MSVC ) |
| 76 | set(LLVM_TARGETS_TO_BUILD X86 |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 77 | CACHE STRING "Semicolon-separated list of targets to build, or \"all\".") |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 78 | else( MSVC ) |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 79 | set(LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} |
| 80 | CACHE STRING "Semicolon-separated list of targets to build, or \"all\".") |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 81 | endif( MSVC ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 82 | |
Chandler Carruth | 6b24116 | 2010-10-19 08:21:25 +0000 | [diff] [blame] | 83 | set(CLANG_RESOURCE_DIR "" CACHE STRING |
| 84 | "Relative directory from the Clang binary to its resource files.") |
| 85 | |
Oscar Fuentes | 8e3c169 | 2009-11-12 06:48:09 +0000 | [diff] [blame] | 86 | set(C_INCLUDE_DIRS "" CACHE STRING |
| 87 | "Colon separated list of directories clang will search for headers.") |
| 88 | |
Oscar Fuentes | a9ff139 | 2009-09-13 22:18:38 +0000 | [diff] [blame] | 89 | set(LLVM_TARGET_ARCH "host" |
| 90 | CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.") |
| 91 | |
NAKAMURA Takumi | e7ae70b | 2010-11-11 04:09:35 +0000 | [diff] [blame] | 92 | set(LIT_ARGS_DEFAULT "-sv") |
| 93 | if (MSVC OR XCODE) |
| 94 | set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") |
| 95 | endif() |
| 96 | set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" |
| 97 | CACHE STRING "Default options for lit") |
| 98 | |
Oscar Fuentes | 4b44283 | 2008-11-18 23:45:21 +0000 | [diff] [blame] | 99 | option(LLVM_ENABLE_THREADS "Use threads if available." ON) |
| 100 | |
Oscar Fuentes | 81a8755 | 2009-06-03 15:11:25 +0000 | [diff] [blame] | 101 | if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" ) |
Oscar Fuentes | 76941b2 | 2009-06-04 09:26:16 +0000 | [diff] [blame] | 102 | option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF) |
Oscar Fuentes | 81a8755 | 2009-06-03 15:11:25 +0000 | [diff] [blame] | 103 | else() |
Oscar Fuentes | 76941b2 | 2009-06-04 09:26:16 +0000 | [diff] [blame] | 104 | option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) |
Oscar Fuentes | 81a8755 | 2009-06-03 15:11:25 +0000 | [diff] [blame] | 105 | endif() |
| 106 | |
Oscar Fuentes | 76941b2 | 2009-06-04 09:26:16 +0000 | [diff] [blame] | 107 | if( LLVM_ENABLE_ASSERTIONS ) |
Oscar Fuentes | af10910 | 2009-07-05 18:43:52 +0000 | [diff] [blame] | 108 | # MSVC doesn't like _DEBUG on release builds. See PR 4379. |
Oscar Fuentes | e8c81ea | 2009-07-05 23:58:20 +0000 | [diff] [blame] | 109 | if( NOT MSVC ) |
Oscar Fuentes | af10910 | 2009-07-05 18:43:52 +0000 | [diff] [blame] | 110 | add_definitions( -D_DEBUG ) |
| 111 | endif() |
Oscar Fuentes | 76941b2 | 2009-06-04 09:26:16 +0000 | [diff] [blame] | 112 | # 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() |
| 117 | else() |
| 118 | if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" ) |
| 119 | add_definitions( -DNDEBUG ) |
| 120 | endif() |
Oscar Fuentes | 81a8755 | 2009-06-03 15:11:25 +0000 | [diff] [blame] | 121 | endif() |
| 122 | |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 123 | if( LLVM_TARGETS_TO_BUILD STREQUAL "all" ) |
| 124 | set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} ) |
| 125 | endif() |
| 126 | |
Douglas Gregor | 1555a23 | 2009-06-16 20:12:29 +0000 | [diff] [blame] | 127 | set(LLVM_ENUM_TARGETS "") |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 128 | foreach(c ${LLVM_TARGETS_TO_BUILD}) |
| 129 | list(FIND LLVM_ALL_TARGETS ${c} idx) |
| 130 | if( idx LESS 0 ) |
Gabor Greif | 9befba8 | 2009-08-12 08:37:37 +0000 | [diff] [blame] | 131 | message(FATAL_ERROR "The target `${c}' does not exist. |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 132 | It should be one of\n${LLVM_ALL_TARGETS}") |
Douglas Gregor | 1555a23 | 2009-06-16 20:12:29 +0000 | [diff] [blame] | 133 | else() |
| 134 | set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${c})\n") |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 135 | endif() |
| 136 | endforeach(c) |
| 137 | |
Douglas Gregor | 1555a23 | 2009-06-16 20:12:29 +0000 | [diff] [blame] | 138 | # Produce llvm/Config/Targets.def |
| 139 | configure_file( |
| 140 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.def.in |
| 141 | ${LLVM_BINARY_DIR}/include/llvm/Config/Targets.def |
| 142 | ) |
| 143 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 144 | set(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm) |
| 145 | |
Oscar Fuentes | 9a0107d | 2009-04-04 22:41:07 +0000 | [diff] [blame] | 146 | include(AddLLVMDefinitions) |
| 147 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 148 | if(WIN32) |
Oscar Fuentes | 4fd38b8 | 2008-10-30 17:15:54 +0000 | [diff] [blame] | 149 | 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 Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 156 | set(LTDL_SHLIB_EXT ".dll") |
| 157 | set(EXEEXT ".exe") |
| 158 | # Maximum path length is 160 for non-unicode paths |
| 159 | set(MAXPATHLEN 160) |
| 160 | else(WIN32) |
| 161 | if(UNIX) |
| 162 | set(LLVM_ON_WIN32 0) |
| 163 | set(LLVM_ON_UNIX 1) |
Daniel Dunbar | 05dafd8 | 2009-09-22 06:09:37 +0000 | [diff] [blame] | 164 | if(APPLE) |
| 165 | set(LTDL_SHLIB_EXT ".dylib") |
| 166 | else(APPLE) |
| 167 | set(LTDL_SHLIB_EXT ".so") |
| 168 | endif(APPLE) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 169 | 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) |
| 175 | endif(WIN32) |
| 176 | |
Oscar Fuentes | de98db3 | 2008-10-25 03:29:36 +0000 | [diff] [blame] | 177 | include(config-ix) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 178 | |
Oscar Fuentes | 1e02bf0 | 2009-08-18 15:29:35 +0000 | [diff] [blame] | 179 | option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON) |
Oscar Fuentes | 64fb4c8 | 2008-11-20 19:13:51 +0000 | [diff] [blame] | 180 | |
Douglas Gregor | 318de60 | 2009-06-05 23:46:34 +0000 | [diff] [blame] | 181 | set(ENABLE_PIC 0) |
Oscar Fuentes | 64fb4c8 | 2008-11-20 19:13:51 +0000 | [diff] [blame] | 182 | if( LLVM_ENABLE_PIC ) |
Daniel Dunbar | 3620618 | 2009-11-08 00:34:22 +0000 | [diff] [blame] | 183 | 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 Fuentes | 64fb4c8 | 2008-11-20 19:13:51 +0000 | [diff] [blame] | 196 | endif() |
| 197 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 198 | set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} ) |
| 199 | set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) |
| 200 | set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) |
| 201 | |
| 202 | # set(CMAKE_VERBOSE_MAKEFILE true) |
| 203 | |
Oscar Fuentes | 9a0107d | 2009-04-04 22:41:07 +0000 | [diff] [blame] | 204 | add_llvm_definitions( -D__STDC_LIMIT_MACROS ) |
| 205 | add_llvm_definitions( -D__STDC_CONSTANT_MACROS ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 206 | |
Daniel Dunbar | 9ea3a2c | 2009-12-01 19:11:36 +0000 | [diff] [blame] | 207 | # MSVC has a gazillion warnings with this. |
| 208 | if( MSVC ) |
| 209 | option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." OFF) |
| 210 | else( MSVC ) |
| 211 | option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) |
| 212 | endif() |
| 213 | |
Oscar Fuentes | f12a900 | 2009-12-01 02:21:51 +0000 | [diff] [blame] | 214 | option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) |
| 215 | option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) |
| 216 | |
Oscar Fuentes | b0c5699 | 2008-11-04 03:27:24 +0000 | [diff] [blame] | 217 | if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) |
| 218 | # TODO: support other platforms and toolchains. |
Oscar Fuentes | 6307b94 | 2008-11-19 00:10:39 +0000 | [diff] [blame] | 219 | option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF) |
| 220 | if( LLVM_BUILD_32_BITS ) |
Oscar Fuentes | b0c5699 | 2008-11-04 03:27:24 +0000 | [diff] [blame] | 221 | message(STATUS "Building 32 bits executables and libraries.") |
Oscar Fuentes | 9a0107d | 2009-04-04 22:41:07 +0000 | [diff] [blame] | 222 | add_llvm_definitions( -m32 ) |
Oscar Fuentes | 6307b94 | 2008-11-19 00:10:39 +0000 | [diff] [blame] | 223 | list(APPEND CMAKE_EXE_LINKER_FLAGS -m32) |
| 224 | list(APPEND CMAKE_SHARED_LINKER_FLAGS -m32) |
Oscar Fuentes | 6307b94 | 2008-11-19 00:10:39 +0000 | [diff] [blame] | 225 | endif( LLVM_BUILD_32_BITS ) |
Oscar Fuentes | b0c5699 | 2008-11-04 03:27:24 +0000 | [diff] [blame] | 226 | endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) |
| 227 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 228 | if( MSVC ) |
Oscar Fuentes | 02a8f76 | 2010-08-05 01:25:48 +0000 | [diff] [blame] | 229 | include(ChooseMSVCCRT) |
Stefanus Du Toit | 4ba3a0e | 2009-06-08 21:18:31 +0000 | [diff] [blame] | 230 | |
Oscar Fuentes | 9a0107d | 2009-04-04 22:41:07 +0000 | [diff] [blame] | 231 | 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 Pichet | b2b9b76 | 2010-10-12 00:01:36 +0000 | [diff] [blame] | 235 | add_llvm_definitions( -wd4355 -wd4715 -wd4180 -wd4345 -wd4224 -wd4267 ) |
Stefanus Du Toit | 4ba3a0e | 2009-06-08 21:18:31 +0000 | [diff] [blame] | 236 | |
Daniel Dunbar | 2c4df5a | 2009-07-19 01:35:10 +0000 | [diff] [blame] | 237 | # Suppress 'new behavior: elements of array 'array' will be default initialized' |
| 238 | add_llvm_definitions( -wd4351 ) |
| 239 | |
Oscar Fuentes | f12a900 | 2009-12-01 02:21:51 +0000 | [diff] [blame] | 240 | # 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 Fuentes | 2343b10 | 2009-11-30 23:50:14 +0000 | [diff] [blame] | 250 | elseif( CMAKE_COMPILER_IS_GNUCXX ) |
Oscar Fuentes | f12a900 | 2009-12-01 02:21:51 +0000 | [diff] [blame] | 251 | 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 Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 260 | endif( MSVC ) |
| 261 | |
Oscar Fuentes | 980e842 | 2008-10-29 02:33:15 +0000 | [diff] [blame] | 262 | include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR}) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 263 | |
Edward O'Callaghan | c6cf5fe | 2009-10-12 04:00:11 +0000 | [diff] [blame] | 264 | if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS ) |
| 265 | SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-include llvm/System/Solaris.h") |
| 266 | endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS ) |
| 267 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 268 | include(AddLLVM) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 269 | include(TableGen) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 270 | |
Michael J. Spencer | 1c4e934 | 2010-09-11 02:13:39 +0000 | [diff] [blame] | 271 | if( 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}") |
| 278 | endif() |
| 279 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 280 | add_subdirectory(lib/Support) |
| 281 | add_subdirectory(lib/System) |
Oscar Fuentes | 1d8e4cf | 2008-09-22 18:21:51 +0000 | [diff] [blame] | 282 | |
| 283 | # Everything else depends on Support and System: |
| 284 | set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} ) |
| 285 | |
Oscar Fuentes | 3ab40ca | 2008-11-09 18:53:19 +0000 | [diff] [blame] | 286 | set(LLVM_TABLEGEN "tblgen" CACHE |
Oscar Fuentes | 41bdedf | 2008-11-10 02:35:55 +0000 | [diff] [blame] | 287 | STRING "Native TableGen executable. Saves building one when cross-compiling.") |
Oscar Fuentes | 99b9489 | 2009-06-11 04:16:10 +0000 | [diff] [blame] | 288 | # Effective tblgen executable to be used: |
| 289 | set(LLVM_TABLEGEN_EXE ${LLVM_TABLEGEN}) |
Oscar Fuentes | 3ab40ca | 2008-11-09 18:53:19 +0000 | [diff] [blame] | 290 | |
Oscar Fuentes | 02516ba | 2008-11-10 01:32:14 +0000 | [diff] [blame] | 291 | add_subdirectory(utils/TableGen) |
| 292 | |
Oscar Fuentes | 3ab40ca | 2008-11-09 18:53:19 +0000 | [diff] [blame] | 293 | if( CMAKE_CROSSCOMPILING ) |
Oscar Fuentes | 02516ba | 2008-11-10 01:32:14 +0000 | [diff] [blame] | 294 | # This adds a dependency on target `tblgen', so must go after utils/TableGen |
Oscar Fuentes | 3ab40ca | 2008-11-09 18:53:19 +0000 | [diff] [blame] | 295 | include( CrossCompileLLVM ) |
| 296 | endif( CMAKE_CROSSCOMPILING ) |
| 297 | |
Oscar Fuentes | 422fcf3 | 2008-11-15 00:24:38 +0000 | [diff] [blame] | 298 | add_subdirectory(include/llvm) |
Oscar Fuentes | 1d8e4cf | 2008-09-22 18:21:51 +0000 | [diff] [blame] | 299 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 300 | add_subdirectory(lib/VMCore) |
| 301 | add_subdirectory(lib/CodeGen) |
| 302 | add_subdirectory(lib/CodeGen/SelectionDAG) |
| 303 | add_subdirectory(lib/CodeGen/AsmPrinter) |
| 304 | add_subdirectory(lib/Bitcode/Reader) |
| 305 | add_subdirectory(lib/Bitcode/Writer) |
| 306 | add_subdirectory(lib/Transforms/Utils) |
| 307 | add_subdirectory(lib/Transforms/Instrumentation) |
Douglas Gregor | f1c3a86 | 2010-01-04 21:58:55 +0000 | [diff] [blame] | 308 | add_subdirectory(lib/Transforms/InstCombine) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 309 | add_subdirectory(lib/Transforms/Scalar) |
| 310 | add_subdirectory(lib/Transforms/IPO) |
| 311 | add_subdirectory(lib/Transforms/Hello) |
| 312 | add_subdirectory(lib/Linker) |
| 313 | add_subdirectory(lib/Analysis) |
| 314 | add_subdirectory(lib/Analysis/IPA) |
Daniel Dunbar | ecc63f8 | 2009-06-23 22:01:43 +0000 | [diff] [blame] | 315 | add_subdirectory(lib/MC) |
Daniel Dunbar | 4bd8dc3 | 2010-01-22 02:04:33 +0000 | [diff] [blame] | 316 | add_subdirectory(lib/MC/MCParser) |
Chris Lattner | 847da55 | 2010-07-20 18:25:19 +0000 | [diff] [blame] | 317 | add_subdirectory(lib/MC/MCDisassembler) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 318 | |
Douglas Gregor | 4d20c24 | 2009-07-20 18:30:25 +0000 | [diff] [blame] | 319 | add_subdirectory(utils/FileCheck) |
Daniel Dunbar | 48f7ce8 | 2009-09-24 06:23:57 +0000 | [diff] [blame] | 320 | add_subdirectory(utils/count) |
| 321 | add_subdirectory(utils/not) |
Michael J. Spencer | becf392 | 2010-09-13 17:52:38 +0000 | [diff] [blame] | 322 | add_subdirectory(utils/llvm-lit) |
Douglas Gregor | 4d20c24 | 2009-07-20 18:30:25 +0000 | [diff] [blame] | 323 | |
Oscar Fuentes | 75caad4 | 2009-08-14 04:55:21 +0000 | [diff] [blame] | 324 | set(LLVM_ENUM_ASM_PRINTERS "") |
| 325 | set(LLVM_ENUM_ASM_PARSERS "") |
Daniel Dunbar | fa3f0b9 | 2009-11-25 04:30:13 +0000 | [diff] [blame] | 326 | set(LLVM_ENUM_DISASSEMBLERS "") |
Oscar Fuentes | 75caad4 | 2009-08-14 04:55:21 +0000 | [diff] [blame] | 327 | foreach(t ${LLVM_TARGETS_TO_BUILD}) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 328 | message(STATUS "Targeting ${t}") |
| 329 | add_subdirectory(lib/Target/${t}) |
Daniel Dunbar | b5a8c08 | 2009-07-15 07:04:27 +0000 | [diff] [blame] | 330 | add_subdirectory(lib/Target/${t}/TargetInfo) |
Oscar Fuentes | db2c509 | 2010-11-14 21:17:13 +0000 | [diff] [blame^] | 331 | set( td ${LLVM_MAIN_SRC_DIR}/lib/Target/${t} ) |
| 332 | file(GLOB asmp_file "${td}/*AsmPrinter.cpp") |
| 333 | if( asmp_file ) |
Chris Lattner | aeafb89 | 2010-11-14 19:12:57 +0000 | [diff] [blame] | 334 | set(LLVM_ENUM_ASM_PRINTERS |
| 335 | "${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n") |
Oscar Fuentes | 14b0c05 | 2010-11-14 20:15:05 +0000 | [diff] [blame] | 336 | endif() |
Oscar Fuentes | db2c509 | 2010-11-14 21:17:13 +0000 | [diff] [blame^] | 337 | if( EXISTS ${td}/InstPrinter/CMakeLists.txt ) |
Oscar Fuentes | bab2b01 | 2010-10-02 02:38:42 +0000 | [diff] [blame] | 338 | add_subdirectory(lib/Target/${t}/InstPrinter) |
Oscar Fuentes | db2c509 | 2010-11-14 21:17:13 +0000 | [diff] [blame^] | 339 | endif() |
| 340 | if( EXISTS ${td}/AsmParser/CMakeLists.txt ) |
Oscar Fuentes | 75caad4 | 2009-08-14 04:55:21 +0000 | [diff] [blame] | 341 | add_subdirectory(lib/Target/${t}/AsmParser) |
Daniel Dunbar | 092a9dd | 2009-07-17 20:42:00 +0000 | [diff] [blame] | 342 | set(LLVM_ENUM_ASM_PARSERS |
Oscar Fuentes | 75caad4 | 2009-08-14 04:55:21 +0000 | [diff] [blame] | 343 | "${LLVM_ENUM_ASM_PARSERS}LLVM_ASM_PARSER(${t})\n") |
Oscar Fuentes | db2c509 | 2010-11-14 21:17:13 +0000 | [diff] [blame^] | 344 | endif() |
| 345 | if( EXISTS ${td}/Disassembler/CMakeLists.txt ) |
Daniel Dunbar | fa3f0b9 | 2009-11-25 04:30:13 +0000 | [diff] [blame] | 346 | add_subdirectory(lib/Target/${t}/Disassembler) |
| 347 | set(LLVM_ENUM_DISASSEMBLERS |
| 348 | "${LLVM_ENUM_DISASSEMBLERS}LLVM_DISASSEMBLER(${t})\n") |
Oscar Fuentes | db2c509 | 2010-11-14 21:17:13 +0000 | [diff] [blame^] | 349 | endif() |
Oscar Fuentes | b78829e | 2009-08-16 05:16:43 +0000 | [diff] [blame] | 350 | set(CURRENT_LLVM_TARGET) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 351 | endforeach(t) |
| 352 | |
Douglas Gregor | 1555a23 | 2009-06-16 20:12:29 +0000 | [diff] [blame] | 353 | # Produce llvm/Config/AsmPrinters.def |
| 354 | configure_file( |
| 355 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmPrinters.def.in |
| 356 | ${LLVM_BINARY_DIR}/include/llvm/Config/AsmPrinters.def |
| 357 | ) |
| 358 | |
Daniel Dunbar | 092a9dd | 2009-07-17 20:42:00 +0000 | [diff] [blame] | 359 | # Produce llvm/Config/AsmParsers.def |
| 360 | configure_file( |
| 361 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmParsers.def.in |
| 362 | ${LLVM_BINARY_DIR}/include/llvm/Config/AsmParsers.def |
| 363 | ) |
| 364 | |
Daniel Dunbar | fa3f0b9 | 2009-11-25 04:30:13 +0000 | [diff] [blame] | 365 | # Produce llvm/Config/Disassemblers.def |
| 366 | configure_file( |
| 367 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Disassemblers.def.in |
| 368 | ${LLVM_BINARY_DIR}/include/llvm/Config/Disassemblers.def |
| 369 | ) |
| 370 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 371 | add_subdirectory(lib/ExecutionEngine) |
| 372 | add_subdirectory(lib/ExecutionEngine/Interpreter) |
| 373 | add_subdirectory(lib/ExecutionEngine/JIT) |
| 374 | add_subdirectory(lib/Target) |
| 375 | add_subdirectory(lib/AsmParser) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 376 | add_subdirectory(lib/Archive) |
| 377 | |
Oscar Fuentes | 5c6bf65 | 2009-03-06 01:16:52 +0000 | [diff] [blame] | 378 | add_subdirectory(projects) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 379 | |
Oscar Fuentes | a6c1dbd | 2010-09-25 20:43:06 +0000 | [diff] [blame] | 380 | option(LLVM_BUILD_TOOLS |
| 381 | "Build the LLVM tools. If OFF, just generate build targets." ON) |
| 382 | option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON) |
| 383 | if( LLVM_INCLUDE_TOOLS ) |
| 384 | add_subdirectory(tools) |
| 385 | endif() |
Oscar Fuentes | c81f56d | 2009-08-16 20:56:30 +0000 | [diff] [blame] | 386 | |
Oscar Fuentes | a6c1dbd | 2010-09-25 20:43:06 +0000 | [diff] [blame] | 387 | option(LLVM_BUILD_EXAMPLES |
| 388 | "Build the LLVM example programs. If OFF, just generate build targets." OFF) |
| 389 | option(LLVM_INCLUDE_EXAMPLES "Generate build targets for the LLVM examples" ON) |
| 390 | if( LLVM_INCLUDE_EXAMPLES ) |
| 391 | add_subdirectory(examples) |
| 392 | endif() |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 393 | |
Oscar Fuentes | a6c1dbd | 2010-09-25 20:43:06 +0000 | [diff] [blame] | 394 | option(LLVM_BUILD_TESTS |
| 395 | "Build LLVM unit tests. If OFF, just generate build targes." OFF) |
| 396 | option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON) |
| 397 | if( LLVM_INCLUDE_TESTS ) |
| 398 | add_subdirectory(test) |
| 399 | add_subdirectory(utils/unittest) |
| 400 | add_subdirectory(unittests) |
NAKAMURA Takumi | 15b337c | 2010-10-26 05:08:27 +0000 | [diff] [blame] | 401 | if (MSVC) |
Michael J. Spencer | bbb9ea7 | 2010-10-11 19:55:38 +0000 | [diff] [blame] | 402 | # This utility is used to prevent chrashing tests from calling Dr. Watson on |
| 403 | # Windows. |
| 404 | add_subdirectory(utils/KillTheDoctor) |
| 405 | endif() |
Oscar Fuentes | a6c1dbd | 2010-09-25 20:43:06 +0000 | [diff] [blame] | 406 | endif() |
Michael J. Spencer | ee6944f | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 407 | |
Oscar Fuentes | 6252e98 | 2010-08-09 03:26:43 +0000 | [diff] [blame] | 408 | add_subdirectory(cmake/modules) |
| 409 | |
Oscar Fuentes | 1d7c43b | 2009-10-27 19:57:29 +0000 | [diff] [blame] | 410 | install(DIRECTORY include/ |
| 411 | DESTINATION include |
| 412 | FILES_MATCHING |
Oscar Fuentes | bc2eb13 | 2009-10-30 11:42:08 +0000 | [diff] [blame] | 413 | PATTERN "*.def" |
Oscar Fuentes | 1d7c43b | 2009-10-27 19:57:29 +0000 | [diff] [blame] | 414 | PATTERN "*.h" |
| 415 | PATTERN "*.td" |
Oscar Fuentes | a2281e7 | 2009-10-27 20:04:22 +0000 | [diff] [blame] | 416 | PATTERN "*.inc" |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 417 | PATTERN ".svn" EXCLUDE |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 418 | ) |
| 419 | |
Oscar Fuentes | 1d7c43b | 2009-10-27 19:57:29 +0000 | [diff] [blame] | 420 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ |
| 421 | DESTINATION include |
| 422 | FILES_MATCHING |
| 423 | PATTERN "*.def" |
| 424 | PATTERN "*.h" |
| 425 | PATTERN "*.gen" |
Oscar Fuentes | a2281e7 | 2009-10-27 20:04:22 +0000 | [diff] [blame] | 426 | PATTERN "*.inc" |
Oscar Fuentes | 1d7c43b | 2009-10-27 19:57:29 +0000 | [diff] [blame] | 427 | # Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def" |
| 428 | PATTERN "CMakeFiles" EXCLUDE |
| 429 | PATTERN ".svn" EXCLUDE |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 430 | ) |
| 431 | |
| 432 | # TODO: make and install documentation. |
Oscar Fuentes | 4d156d3 | 2010-10-14 21:11:51 +0000 | [diff] [blame] | 433 | |
| 434 | set(CPACK_PACKAGE_VENDOR "LLVM") |
| 435 | set(CPACK_PACKAGE_VERSION_MAJOR 2) |
| 436 | set(CPACK_PACKAGE_VERSION_MINOR 9) |
| 437 | add_version_info_from_vcs(CPACK_PACKAGE_VERSION_PATCH) |
| 438 | include(CPack) |