| Oscar Fuentes | fff33a3 | 2009-04-04 22:52:02 +0000 | [diff] [blame] | 1 | # See docs/CMake.html for instructions about how to build LLVM with CMake. |
| 2 | |
| Chandler Carruth | 5aad86a | 2014-01-13 22:05:20 +0000 | [diff] [blame] | 3 | cmake_minimum_required(VERSION 2.8.8) |
| NAKAMURA Takumi | 85d65ff | 2014-02-02 16:59:36 +0000 | [diff] [blame^] | 4 | project(LLVM) |
| Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 5 | |
| Oscar Fuentes | 052c23c | 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 | |
| Dylan Noblesmith | c6c7a58 | 2012-02-13 18:48:10 +0000 | [diff] [blame] | 13 | set(LLVM_VERSION_MAJOR 3) |
| NAKAMURA Takumi | a5997c4 | 2013-11-20 13:11:48 +0000 | [diff] [blame] | 14 | set(LLVM_VERSION_MINOR 5) |
| Dylan Noblesmith | c6c7a58 | 2012-02-13 18:48:10 +0000 | [diff] [blame] | 15 | |
| Hans Wennborg | 09d108b | 2013-11-21 22:47:21 +0000 | [diff] [blame] | 16 | if (NOT PACKAGE_VERSION) |
| 17 | set(PACKAGE_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}svn") |
| 18 | endif() |
| Oscar Fuentes | 7064035 | 2010-12-20 09:47:13 +0000 | [diff] [blame] | 19 | |
| Hans Wennborg | 1654627 | 2013-08-24 00:20:36 +0000 | [diff] [blame] | 20 | option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF) |
| 21 | |
| Manuel Klimek | 13cfa00 | 2012-05-09 15:10:54 +0000 | [diff] [blame] | 22 | option(LLVM_USE_FOLDERS "Enable solution folders in Visual Studio. Disable for Express versions." ON) |
| 23 | if ( LLVM_USE_FOLDERS ) |
| 24 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 25 | endif() |
| Oscar Fuentes | 3145e92 | 2011-02-20 22:06:10 +0000 | [diff] [blame] | 26 | |
| Oscar Fuentes | 052c23c | 2010-08-03 17:28:09 +0000 | [diff] [blame] | 27 | include(VersionFromVCS) |
| Oscar Fuentes | 7064035 | 2010-12-20 09:47:13 +0000 | [diff] [blame] | 28 | |
| 29 | option(LLVM_APPEND_VC_REV |
| 30 | "Append the version control system revision id to LLVM version" OFF) |
| 31 | |
| 32 | if( LLVM_APPEND_VC_REV ) |
| 33 | add_version_info_from_vcs(PACKAGE_VERSION) |
| 34 | endif() |
| Oscar Fuentes | 052c23c | 2010-08-03 17:28:09 +0000 | [diff] [blame] | 35 | |
| Dylan Noblesmith | 67c4970 | 2011-12-18 18:50:16 +0000 | [diff] [blame] | 36 | set(PACKAGE_NAME LLVM) |
| Chris Lattner | ff2d99d | 2009-01-28 17:49:03 +0000 | [diff] [blame] | 37 | set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") |
| Dylan Noblesmith | 67c4970 | 2011-12-18 18:50:16 +0000 | [diff] [blame] | 38 | set(PACKAGE_BUGREPORT "http://llvm.org/bugs/") |
| Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 39 | |
| NAKAMURA Takumi | f0a1ab8 | 2014-01-13 05:25:13 +0000 | [diff] [blame] | 40 | set(BUG_REPORT_URL "${PACKAGE_BUGREPORT}" CACHE STRING |
| 41 | "Default URL where bug reports are to be submitted.") |
| 42 | |
| Reid Kleckner | c974f09 | 2013-08-29 22:09:43 +0000 | [diff] [blame] | 43 | # Configure CPack. |
| Hans Wennborg | 09d108b | 2013-11-21 22:47:21 +0000 | [diff] [blame] | 44 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "LLVM") |
| Reid Kleckner | c974f09 | 2013-08-29 22:09:43 +0000 | [diff] [blame] | 45 | set(CPACK_PACKAGE_VENDOR "LLVM") |
| 46 | set(CPACK_PACKAGE_VERSION_MAJOR ${LLVM_VERSION_MAJOR}) |
| 47 | set(CPACK_PACKAGE_VERSION_MINOR ${LLVM_VERSION_MINOR}) |
| Hans Wennborg | 09d108b | 2013-11-21 22:47:21 +0000 | [diff] [blame] | 48 | set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION}) |
| Reid Kleckner | c974f09 | 2013-08-29 22:09:43 +0000 | [diff] [blame] | 49 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT") |
| 50 | if(WIN32 AND NOT UNIX) |
| Hans Wennborg | 09d108b | 2013-11-21 22:47:21 +0000 | [diff] [blame] | 51 | set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "LLVM") |
| Reid Kleckner | c974f09 | 2013-08-29 22:09:43 +0000 | [diff] [blame] | 52 | set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_logo.bmp") |
| 53 | set(CPACK_NSIS_MODIFY_PATH "ON") |
| 54 | set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON") |
| 55 | set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS |
| 56 | "ExecWait '$INSTDIR/tools/msbuild/install.bat'") |
| 57 | set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS |
| 58 | "ExecWait '$INSTDIR/tools/msbuild/uninstall.bat'") |
| 59 | endif() |
| 60 | include(CPack) |
| 61 | |
| Daniel Dunbar | ad3946a | 2011-11-04 19:04:39 +0000 | [diff] [blame] | 62 | # Sanity check our source directory to make sure that we are not trying to |
| 63 | # generate an in-tree build (unless on MSVC_IDE, where it is ok), and to make |
| 64 | # sure that we don't have any stray generated files lying around in the tree |
| 65 | # (which would end up getting picked up by header search, instead of the correct |
| 66 | # versions). |
| Oscar Fuentes | a5f8356 | 2008-11-14 03:43:18 +0000 | [diff] [blame] | 67 | if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) |
| 68 | message(FATAL_ERROR "In-source builds are not allowed. |
| 69 | CMake would overwrite the makefiles distributed with LLVM. |
| 70 | Please create a directory and run cmake from there, passing the path |
| 71 | to this source directory as the last argument. |
| 72 | This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. |
| 73 | Please delete them.") |
| 74 | endif() |
| Daniel Dunbar | ad3946a | 2011-11-04 19:04:39 +0000 | [diff] [blame] | 75 | if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) |
| 76 | file(GLOB_RECURSE |
| 77 | tablegenned_files_on_include_dir |
| 78 | "${CMAKE_CURRENT_SOURCE_DIR}/include/llvm/*.gen") |
| 79 | file(GLOB_RECURSE |
| 80 | tablegenned_files_on_lib_dir |
| 81 | "${CMAKE_CURRENT_SOURCE_DIR}/lib/Target/*.inc") |
| 82 | if( tablegenned_files_on_include_dir OR tablegenned_files_on_lib_dir) |
| 83 | message(FATAL_ERROR "Apparently there is a previous in-source build, |
| 84 | probably as the result of running `configure' and `make' on |
| 85 | ${CMAKE_CURRENT_SOURCE_DIR}. |
| 86 | This may cause problems. The suspicious files are: |
| 87 | ${tablegenned_files_on_lib_dir} |
| 88 | ${tablegenned_files_on_include_dir} |
| 89 | Please clean the source directory.") |
| 90 | endif() |
| 91 | endif() |
| Oscar Fuentes | a5f8356 | 2008-11-14 03:43:18 +0000 | [diff] [blame] | 92 | |
| Oscar Fuentes | 6133813 | 2009-06-03 15:11:25 +0000 | [diff] [blame] | 93 | string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) |
| 94 | |
| NAKAMURA Takumi | 0190e94 | 2014-01-19 12:47:26 +0000 | [diff] [blame] | 95 | # They are used as destination of target generators. |
| 96 | set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) |
| 97 | set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib) |
| 98 | |
| 99 | # Each of them corresponds to llvm-config's. |
| NAKAMURA Takumi | ce78b80 | 2014-01-19 12:52:10 +0000 | [diff] [blame] | 100 | set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir |
| 101 | set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) # --libdir |
| NAKAMURA Takumi | 0190e94 | 2014-01-19 12:47:26 +0000 | [diff] [blame] | 102 | set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root |
| 103 | set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir |
| 104 | set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) # --prefix |
| 105 | |
| Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 106 | set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples) |
| NAKAMURA Takumi | 03932fb | 2013-12-16 15:05:39 +0000 | [diff] [blame] | 107 | set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include) |
| Oscar Fuentes | 46fed3b | 2009-06-12 02:49:53 +0000 | [diff] [blame] | 108 | set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" ) |
| Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 109 | |
| Oscar Fuentes | e9edc2c | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 110 | set(LLVM_ALL_TARGETS |
| Tim Northover | 43852f2 | 2013-02-04 12:32:21 +0000 | [diff] [blame] | 111 | AArch64 |
| Oscar Fuentes | e9edc2c | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 112 | ARM |
| Oscar Fuentes | e9edc2c | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 113 | CppBackend |
| Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 114 | Hexagon |
| Oscar Fuentes | e9edc2c | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 115 | Mips |
| Richard Pennington | 9f3bd4a | 2009-07-09 20:27:09 +0000 | [diff] [blame] | 116 | MSP430 |
| Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 117 | NVPTX |
| Oscar Fuentes | e9edc2c | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 118 | PowerPC |
| Rafael Espindola | f6474d2 | 2013-05-22 00:35:47 +0000 | [diff] [blame] | 119 | R600 |
| Oscar Fuentes | e9edc2c | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 120 | Sparc |
| Ulrich Weigand | 92b2085 | 2013-05-06 16:23:07 +0000 | [diff] [blame] | 121 | SystemZ |
| Oscar Fuentes | e9edc2c | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 122 | X86 |
| 123 | XCore |
| 124 | ) |
| 125 | |
| Oscar Fuentes | 465f936 | 2011-03-23 17:42:13 +0000 | [diff] [blame] | 126 | # List of targets with JIT support: |
| Tim Northover | c17f3f7 | 2013-05-19 19:44:56 +0000 | [diff] [blame] | 127 | set(LLVM_TARGETS_WITH_JIT X86 PowerPC AArch64 ARM Mips SystemZ) |
| Oscar Fuentes | 465f936 | 2011-03-23 17:42:13 +0000 | [diff] [blame] | 128 | |
| Tim Northover | 865f4bc | 2013-04-15 11:53:05 +0000 | [diff] [blame] | 129 | set(LLVM_TARGETS_TO_BUILD "all" |
| Oscar Fuentes | e9edc2c | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 130 | CACHE STRING "Semicolon-separated list of targets to build, or \"all\".") |
| Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 131 | |
| Victor Oliveira | 9d4b8f5 | 2012-08-09 01:13:59 +0000 | [diff] [blame] | 132 | set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD "" |
| 133 | CACHE STRING "Semicolon-separated list of experimental targets to build.") |
| 134 | |
| Dylan Noblesmith | af9be0b | 2012-02-01 14:49:39 +0000 | [diff] [blame] | 135 | option(BUILD_SHARED_LIBS |
| 136 | "Build all libraries as shared libraries instead of static" OFF) |
| 137 | |
| Oscar Fuentes | c8cb58e | 2011-01-11 12:31:54 +0000 | [diff] [blame] | 138 | option(LLVM_ENABLE_CBE_PRINTF_A "Set to ON if CBE is enabled for printf %a output" ON) |
| 139 | if(LLVM_ENABLE_CBE_PRINTF_A) |
| 140 | set(ENABLE_CBE_PRINTF_A 1) |
| 141 | endif() |
| 142 | |
| 143 | option(LLVM_ENABLE_TIMESTAMPS "Enable embedding timestamp information in build" ON) |
| 144 | if(LLVM_ENABLE_TIMESTAMPS) |
| 145 | set(ENABLE_TIMESTAMPS 1) |
| 146 | endif() |
| 147 | |
| Benjamin Kramer | 5651cbd | 2012-09-28 10:10:46 +0000 | [diff] [blame] | 148 | option(LLVM_ENABLE_BACKTRACES "Enable embedding backtraces on crash." ON) |
| 149 | if(LLVM_ENABLE_BACKTRACES) |
| 150 | set(ENABLE_BACKTRACES 1) |
| 151 | endif() |
| 152 | |
| Daniel Dunbar | eb6c708 | 2013-08-30 20:39:21 +0000 | [diff] [blame] | 153 | option(LLVM_ENABLE_CRASH_OVERRIDES "Enable crash overrides." ON) |
| 154 | if(LLVM_ENABLE_CRASH_OVERRIDES) |
| 155 | set(ENABLE_CRASH_OVERRIDES 1) |
| 156 | endif() |
| 157 | |
| Oscar Fuentes | 6495595 | 2011-01-21 15:42:54 +0000 | [diff] [blame] | 158 | option(LLVM_ENABLE_FFI "Use libffi to call external functions from the interpreter" OFF) |
| 159 | set(FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so") |
| 160 | set(FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for ffi.h or ffi/ffi.h") |
| 161 | |
| Sebastian Pop | 82622dc | 2012-08-08 18:04:45 +0000 | [diff] [blame] | 162 | set(LLVM_TARGET_ARCH "host" |
| 163 | CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.") |
| Oscar Fuentes | b9a7813 | 2009-09-13 22:18:38 +0000 | [diff] [blame] | 164 | |
| Chandler Carruth | f11f1e4 | 2013-08-12 09:49:17 +0000 | [diff] [blame] | 165 | option(LLVM_ENABLE_TERMINFO "Use terminfo database if available." ON) |
| Chandler Carruth | cad7e5e | 2013-08-07 08:47:36 +0000 | [diff] [blame] | 166 | |
| Oscar Fuentes | 366fbb7 | 2008-11-18 23:45:21 +0000 | [diff] [blame] | 167 | option(LLVM_ENABLE_THREADS "Use threads if available." ON) |
| 168 | |
| Alexey Samsonov | 2fb337e | 2013-04-23 08:28:39 +0000 | [diff] [blame] | 169 | option(LLVM_ENABLE_ZLIB "Use zlib for compression/decompression if available." ON) |
| 170 | |
| Oscar Fuentes | e9edc2c | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 171 | if( LLVM_TARGETS_TO_BUILD STREQUAL "all" ) |
| 172 | set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} ) |
| 173 | endif() |
| 174 | |
| Victor Oliveira | 18023e4 | 2012-08-15 22:35:36 +0000 | [diff] [blame] | 175 | set(LLVM_TARGETS_TO_BUILD |
| 176 | ${LLVM_TARGETS_TO_BUILD} |
| 177 | ${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}) |
| Rafael Espindola | cf1e657 | 2013-05-22 02:45:28 +0000 | [diff] [blame] | 178 | list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD) |
| Victor Oliveira | 18023e4 | 2012-08-15 22:35:36 +0000 | [diff] [blame] | 179 | |
| Oscar Fuentes | bda403b | 2009-04-04 22:41:07 +0000 | [diff] [blame] | 180 | include(AddLLVMDefinitions) |
| 181 | |
| Oscar Fuentes | 6d61f55 | 2009-08-18 15:29:35 +0000 | [diff] [blame] | 182 | option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON) |
| Oscar Fuentes | 073b0b1 | 2008-11-20 19:13:51 +0000 | [diff] [blame] | 183 | |
| Oscar Fuentes | 1276e32 | 2011-03-01 22:31:19 +0000 | [diff] [blame] | 184 | # MSVC has a gazillion warnings with this. |
| 185 | if( MSVC ) |
| 186 | option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." OFF) |
| 187 | else( MSVC ) |
| 188 | option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) |
| 189 | endif() |
| Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 190 | |
| Arnaud A. de Grandmaison | b697b53 | 2013-11-26 10:33:53 +0000 | [diff] [blame] | 191 | option(LLVM_ENABLE_CXX11 "Compile with C++11 enabled." OFF) |
| Jean-Daniel Dupas | edad1b4 | 2014-01-06 18:27:27 +0000 | [diff] [blame] | 192 | option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF) |
| Oscar Fuentes | 1276e32 | 2011-03-01 22:31:19 +0000 | [diff] [blame] | 193 | option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) |
| 194 | option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) |
| Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 195 | |
| Duncan Sands | 80f122f | 2013-07-17 09:34:51 +0000 | [diff] [blame] | 196 | if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" ) |
| Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 197 | option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF) |
| 198 | else() |
| 199 | option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) |
| Oscar Fuentes | 073b0b1 | 2008-11-20 19:13:51 +0000 | [diff] [blame] | 200 | endif() |
| 201 | |
| Chandler Carruth | 8388597 | 2014-01-13 22:21:34 +0000 | [diff] [blame] | 202 | option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN |
| 203 | "Set to ON to force using an old, unsupported host toolchain." OFF) |
| 204 | |
| Eli Bendersky | 5262ad2 | 2012-03-13 08:33:15 +0000 | [diff] [blame] | 205 | option(LLVM_USE_INTEL_JITEVENTS |
| 206 | "Use Intel JIT API to inform Intel(R) VTune(TM) Amplifier XE 2011 about JIT code" |
| 207 | OFF) |
| 208 | |
| 209 | if( LLVM_USE_INTEL_JITEVENTS ) |
| 210 | # Verify we are on a supported platform |
| Andrew Kaylor | 5808c7d | 2012-09-28 17:35:20 +0000 | [diff] [blame] | 211 | if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) |
| Eli Bendersky | 5262ad2 | 2012-03-13 08:33:15 +0000 | [diff] [blame] | 212 | message(FATAL_ERROR |
| 213 | "Intel JIT API support is available on Linux and Windows only.") |
| 214 | endif() |
| 215 | endif( LLVM_USE_INTEL_JITEVENTS ) |
| 216 | |
| 217 | option(LLVM_USE_OPROFILE |
| 218 | "Use opagent JIT interface to inform OProfile about JIT code" OFF) |
| 219 | |
| Joel Jones | 54594f2 | 2012-12-13 15:25:07 +0000 | [diff] [blame] | 220 | # If enabled, verify we are on a platform that supports oprofile. |
| Eli Bendersky | 5262ad2 | 2012-03-13 08:33:15 +0000 | [diff] [blame] | 221 | if( LLVM_USE_OPROFILE ) |
| 222 | if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) |
| 223 | message(FATAL_ERROR "OProfile support is available on Linux only.") |
| 224 | endif( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) |
| 225 | endif( LLVM_USE_OPROFILE ) |
| 226 | |
| Alexey Samsonov | 75789a2 | 2013-03-26 07:49:46 +0000 | [diff] [blame] | 227 | set(LLVM_USE_SANITIZER "" CACHE STRING |
| 228 | "Define the sanitizer used to build binaries and tests.") |
| 229 | |
| Eric Christopher | 3987806 | 2013-07-30 21:44:10 +0000 | [diff] [blame] | 230 | option(LLVM_USE_SPLIT_DWARF |
| 231 | "Use -gsplit-dwarf when compiling llvm." OFF) |
| 232 | |
| Daniel Dunbar | 10fa2df | 2011-11-04 19:04:35 +0000 | [diff] [blame] | 233 | # Define an option controlling whether we should build for 32-bit on 64-bit |
| 234 | # platforms, where supported. |
| 235 | if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) |
| 236 | # TODO: support other platforms and toolchains. |
| 237 | option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF) |
| 238 | endif() |
| 239 | |
| Daniel Dunbar | 10fa2df | 2011-11-04 19:04:35 +0000 | [diff] [blame] | 240 | # Define the default arguments to use with 'lit', and an option for the user to |
| 241 | # override. |
| 242 | set(LIT_ARGS_DEFAULT "-sv") |
| 243 | if (MSVC OR XCODE) |
| 244 | set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") |
| 245 | endif() |
| 246 | set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") |
| 247 | |
| NAKAMURA Takumi | ba330ae | 2011-12-11 03:07:53 +0000 | [diff] [blame] | 248 | # On Win32 hosts, provide an option to specify the path to the GnuWin32 tools. |
| 249 | if( WIN32 AND NOT CYGWIN ) |
| Daniel Dunbar | 10fa2df | 2011-11-04 19:04:35 +0000 | [diff] [blame] | 250 | set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") |
| 251 | endif() |
| 252 | |
| Daniel Dunbar | 511e296 | 2011-11-04 19:04:37 +0000 | [diff] [blame] | 253 | # Define options to control the inclusion and default build behavior for |
| Chandler Carruth | ea56494 | 2013-10-02 15:42:23 +0000 | [diff] [blame] | 254 | # components which may not strictly be necessary (tools, examples, and tests). |
| Daniel Dunbar | 511e296 | 2011-11-04 19:04:37 +0000 | [diff] [blame] | 255 | # |
| 256 | # This is primarily to support building smaller or faster project files. |
| 257 | option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON) |
| 258 | option(LLVM_BUILD_TOOLS |
| 259 | "Build the LLVM tools. If OFF, just generate build targets." ON) |
| 260 | |
| Alexey Samsonov | 693e1a5 | 2013-10-04 10:41:38 +0000 | [diff] [blame] | 261 | option(LLVM_BUILD_RUNTIME |
| 262 | "Build the LLVM runtime libraries." ON) |
| Daniel Dunbar | 511e296 | 2011-11-04 19:04:37 +0000 | [diff] [blame] | 263 | option(LLVM_BUILD_EXAMPLES |
| 264 | "Build the LLVM example programs. If OFF, just generate build targets." OFF) |
| 265 | option(LLVM_INCLUDE_EXAMPLES "Generate build targets for the LLVM examples" ON) |
| 266 | |
| 267 | option(LLVM_BUILD_TESTS |
| 268 | "Build LLVM unit tests. If OFF, just generate build targets." OFF) |
| 269 | option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON) |
| 270 | |
| Michael Gottesman | 4d35b90 | 2013-08-24 07:25:21 +0000 | [diff] [blame] | 271 | option (LLVM_BUILD_DOCS "Build the llvm documentation." OFF) |
| 272 | option (LLVM_INCLUDE_DOCS "Generate build targets for llvm documentation." ON) |
| 273 | option (LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm documentation." OFF) |
| 274 | |
| Chris Lattner | 0ab5e2c | 2011-04-15 05:18:47 +0000 | [diff] [blame] | 275 | # All options referred to from HandleLLVMOptions have to be specified |
| Oscar Fuentes | 1276e32 | 2011-03-01 22:31:19 +0000 | [diff] [blame] | 276 | # BEFORE this include, otherwise options will not be correctly set on |
| 277 | # first cmake run |
| 278 | include(config-ix) |
| Sebastian Pop | faeca29 | 2012-08-20 19:56:52 +0000 | [diff] [blame] | 279 | |
| 280 | # By default, we target the host, but this can be overridden at CMake |
| 281 | # invocation time. |
| 282 | set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING |
| 283 | "Default target for which LLVM will generate code." ) |
| NAKAMURA Takumi | f9573f1 | 2012-12-10 07:14:29 +0000 | [diff] [blame] | 284 | set(TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}") |
| Sebastian Pop | faeca29 | 2012-08-20 19:56:52 +0000 | [diff] [blame] | 285 | |
| Oscar Fuentes | 1276e32 | 2011-03-01 22:31:19 +0000 | [diff] [blame] | 286 | include(HandleLLVMOptions) |
| 287 | |
| Reid Kleckner | 63784ba | 2013-06-24 13:21:16 +0000 | [diff] [blame] | 288 | # Verify that we can find a Python 2 interpreter. Python 3 is unsupported. |
| Bill Wendling | 8edd8f9 | 2013-10-28 21:22:23 +0000 | [diff] [blame] | 289 | set(Python_ADDITIONAL_VERSIONS 2.7 2.6 2.5) |
| Daniel Dunbar | 21079ca | 2011-11-04 23:04:05 +0000 | [diff] [blame] | 290 | include(FindPythonInterp) |
| 291 | if( NOT PYTHONINTERP_FOUND ) |
| 292 | message(FATAL_ERROR |
| 293 | "Unable to find Python interpreter, required for builds and testing. |
| 294 | |
| 295 | Please install Python or specify the PYTHON_EXECUTABLE CMake variable.") |
| 296 | endif() |
| 297 | |
| Daniel Dunbar | 6437126 | 2011-11-05 06:30:03 +0000 | [diff] [blame] | 298 | ###### |
| 299 | # LLVMBuild Integration |
| 300 | # |
| 301 | # We use llvm-build to generate all the data required by the CMake based |
| 302 | # build system in one swoop: |
| 303 | # |
| 304 | # - We generate a file (a CMake fragment) in the object root which contains |
| 305 | # all the definitions that are required by CMake. |
| 306 | # |
| 307 | # - We generate the library table used by llvm-config. |
| 308 | # |
| 309 | # - We generate the dependencies for the CMake fragment, so that we will |
| 310 | # automatically reconfigure outselves. |
| 311 | |
| 312 | set(LLVMBUILDTOOL "${LLVM_MAIN_SRC_DIR}/utils/llvm-build/llvm-build") |
| 313 | set(LLVMCONFIGLIBRARYDEPENDENCIESINC |
| Daniel Dunbar | ab0ad4e | 2011-12-01 20:18:09 +0000 | [diff] [blame] | 314 | "${LLVM_BINARY_DIR}/tools/llvm-config/LibraryDependencies.inc") |
| Daniel Dunbar | 6437126 | 2011-11-05 06:30:03 +0000 | [diff] [blame] | 315 | set(LLVMBUILDCMAKEFRAG |
| 316 | "${LLVM_BINARY_DIR}/LLVMBuild.cmake") |
| Preston Gurd | e65f4e6 | 2012-05-07 19:38:40 +0000 | [diff] [blame] | 317 | |
| 318 | # Create the list of optional components that are enabled |
| 319 | if (LLVM_USE_INTEL_JITEVENTS) |
| 320 | set(LLVMOPTIONALCOMPONENTS IntelJITEvents) |
| 321 | endif (LLVM_USE_INTEL_JITEVENTS) |
| 322 | if (LLVM_USE_OPROFILE) |
| 323 | set(LLVMOPTIONALCOMPONENTS ${LLVMOPTIONALCOMPONENTS} OProfileJIT) |
| 324 | endif (LLVM_USE_OPROFILE) |
| 325 | |
| Daniel Dunbar | 6437126 | 2011-11-05 06:30:03 +0000 | [diff] [blame] | 326 | message(STATUS "Constructing LLVMBuild project information") |
| 327 | execute_process( |
| 328 | COMMAND ${PYTHON_EXECUTABLE} ${LLVMBUILDTOOL} |
| Daniel Dunbar | 807c6e4 | 2011-11-10 01:16:48 +0000 | [diff] [blame] | 329 | --native-target "${LLVM_NATIVE_ARCH}" |
| 330 | --enable-targets "${LLVM_TARGETS_TO_BUILD}" |
| Preston Gurd | e65f4e6 | 2012-05-07 19:38:40 +0000 | [diff] [blame] | 331 | --enable-optional-components "${LLVMOPTIONALCOMPONENTS}" |
| Daniel Dunbar | 6437126 | 2011-11-05 06:30:03 +0000 | [diff] [blame] | 332 | --write-library-table ${LLVMCONFIGLIBRARYDEPENDENCIESINC} |
| 333 | --write-cmake-fragment ${LLVMBUILDCMAKEFRAG} |
| Michael Gottesman | 21c6948 | 2013-08-15 04:16:12 +0000 | [diff] [blame] | 334 | OUTPUT_VARIABLE LLVMBUILDOUTPUT |
| Daniel Dunbar | 6437126 | 2011-11-05 06:30:03 +0000 | [diff] [blame] | 335 | ERROR_VARIABLE LLVMBUILDERRORS |
| 336 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 337 | ERROR_STRIP_TRAILING_WHITESPACE |
| 338 | RESULT_VARIABLE LLVMBUILDRESULT) |
| 339 | |
| 340 | # On Win32, CMake doesn't properly handle piping the default output/error |
| 341 | # streams into the GUI console. So, we explicitly catch and report them. |
| 342 | if( NOT "${LLVMBUILDOUTPUT}" STREQUAL "") |
| 343 | message(STATUS "llvm-build output: ${LLVMBUILDOUTPUT}") |
| 344 | endif() |
| 345 | if( NOT "${LLVMBUILDRESULT}" STREQUAL "0" ) |
| 346 | message(FATAL_ERROR |
| 347 | "Unexpected failure executing llvm-build: ${LLVMBUILDERRORS}") |
| 348 | endif() |
| 349 | |
| 350 | # Include the generated CMake fragment. This will define properties from the |
| 351 | # LLVMBuild files in a format which is easy to consume from CMake, and will add |
| 352 | # the dependencies so that CMake will reconfigure properly when the LLVMBuild |
| 353 | # files change. |
| 354 | include(${LLVMBUILDCMAKEFRAG}) |
| 355 | |
| 356 | ###### |
| 357 | |
| Daniel Dunbar | 4a2eab0 | 2011-11-04 19:04:42 +0000 | [diff] [blame] | 358 | # Configure all of the various header file fragments LLVM uses which depend on |
| 359 | # configuration variables. |
| Andy Gibbs | f5dede1 | 2013-06-26 07:57:53 +0000 | [diff] [blame] | 360 | set(LLVM_ENUM_TARGETS "") |
| Daniel Dunbar | 4a2eab0 | 2011-11-04 19:04:42 +0000 | [diff] [blame] | 361 | set(LLVM_ENUM_ASM_PRINTERS "") |
| 362 | set(LLVM_ENUM_ASM_PARSERS "") |
| 363 | set(LLVM_ENUM_DISASSEMBLERS "") |
| 364 | foreach(t ${LLVM_TARGETS_TO_BUILD}) |
| 365 | set( td ${LLVM_MAIN_SRC_DIR}/lib/Target/${t} ) |
| Andy Gibbs | f5dede1 | 2013-06-26 07:57:53 +0000 | [diff] [blame] | 366 | |
| 367 | list(FIND LLVM_ALL_TARGETS ${t} idx) |
| 368 | list(FIND LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ${t} idy) |
| 369 | if( idx LESS 0 AND idy LESS 0 ) |
| 370 | message(FATAL_ERROR "The target `${t}' does not exist. |
| 371 | It should be one of\n${LLVM_ALL_TARGETS}") |
| 372 | else() |
| 373 | set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${t})\n") |
| 374 | endif() |
| 375 | |
| Daniel Dunbar | 4a2eab0 | 2011-11-04 19:04:42 +0000 | [diff] [blame] | 376 | file(GLOB asmp_file "${td}/*AsmPrinter.cpp") |
| 377 | if( asmp_file ) |
| 378 | set(LLVM_ENUM_ASM_PRINTERS |
| 379 | "${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n") |
| 380 | endif() |
| 381 | if( EXISTS ${td}/AsmParser/CMakeLists.txt ) |
| 382 | set(LLVM_ENUM_ASM_PARSERS |
| 383 | "${LLVM_ENUM_ASM_PARSERS}LLVM_ASM_PARSER(${t})\n") |
| 384 | endif() |
| 385 | if( EXISTS ${td}/Disassembler/CMakeLists.txt ) |
| 386 | set(LLVM_ENUM_DISASSEMBLERS |
| 387 | "${LLVM_ENUM_DISASSEMBLERS}LLVM_DISASSEMBLER(${t})\n") |
| 388 | endif() |
| 389 | endforeach(t) |
| 390 | |
| 391 | # Produce the target definition files, which provide a way for clients to easily |
| 392 | # include various classes of targets. |
| 393 | configure_file( |
| 394 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmPrinters.def.in |
| NAKAMURA Takumi | 03932fb | 2013-12-16 15:05:39 +0000 | [diff] [blame] | 395 | ${LLVM_INCLUDE_DIR}/llvm/Config/AsmPrinters.def |
| Daniel Dunbar | 4a2eab0 | 2011-11-04 19:04:42 +0000 | [diff] [blame] | 396 | ) |
| 397 | configure_file( |
| 398 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmParsers.def.in |
| NAKAMURA Takumi | 03932fb | 2013-12-16 15:05:39 +0000 | [diff] [blame] | 399 | ${LLVM_INCLUDE_DIR}/llvm/Config/AsmParsers.def |
| Daniel Dunbar | 4a2eab0 | 2011-11-04 19:04:42 +0000 | [diff] [blame] | 400 | ) |
| 401 | configure_file( |
| 402 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Disassemblers.def.in |
| NAKAMURA Takumi | 03932fb | 2013-12-16 15:05:39 +0000 | [diff] [blame] | 403 | ${LLVM_INCLUDE_DIR}/llvm/Config/Disassemblers.def |
| Daniel Dunbar | 4a2eab0 | 2011-11-04 19:04:42 +0000 | [diff] [blame] | 404 | ) |
| 405 | configure_file( |
| 406 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.def.in |
| NAKAMURA Takumi | 03932fb | 2013-12-16 15:05:39 +0000 | [diff] [blame] | 407 | ${LLVM_INCLUDE_DIR}/llvm/Config/Targets.def |
| Daniel Dunbar | 4a2eab0 | 2011-11-04 19:04:42 +0000 | [diff] [blame] | 408 | ) |
| 409 | |
| 410 | # Configure the three LLVM configuration header files. |
| Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 411 | configure_file( |
| 412 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/config.h.cmake |
| NAKAMURA Takumi | 03932fb | 2013-12-16 15:05:39 +0000 | [diff] [blame] | 413 | ${LLVM_INCLUDE_DIR}/llvm/Config/config.h) |
| Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 414 | configure_file( |
| 415 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/llvm-config.h.cmake |
| NAKAMURA Takumi | 03932fb | 2013-12-16 15:05:39 +0000 | [diff] [blame] | 416 | ${LLVM_INCLUDE_DIR}/llvm/Config/llvm-config.h) |
| Oscar Fuentes | f4202ba | 2011-02-03 20:57:36 +0000 | [diff] [blame] | 417 | configure_file( |
| 418 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/DataTypes.h.cmake |
| NAKAMURA Takumi | 03932fb | 2013-12-16 15:05:39 +0000 | [diff] [blame] | 419 | ${LLVM_INCLUDE_DIR}/llvm/Support/DataTypes.h) |
| Oscar Fuentes | edfc184 | 2011-01-09 14:34:39 +0000 | [diff] [blame] | 420 | |
| NAKAMURA Takumi | 0ec65f1 | 2014-01-19 12:47:22 +0000 | [diff] [blame] | 421 | # They are not referenced. See set_output_directory(). |
| 422 | set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/bin ) |
| Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 423 | set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) |
| 424 | set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) |
| 425 | |
| Artyom Skrobov | 01c1825 | 2013-12-20 18:13:12 +0000 | [diff] [blame] | 426 | if( NOT DEFINED CMAKE_INSTALL_RPATH ) |
| 427 | set( CMAKE_INSTALL_RPATH "\$ORIGIN/../lib") |
| 428 | endif( NOT DEFINED CMAKE_INSTALL_RPATH ) |
| Rafael Espindola | 6ad1b3f | 2013-12-19 23:13:58 +0000 | [diff] [blame] | 429 | |
| Oscar Fuentes | 210b06a | 2011-02-14 20:13:58 +0000 | [diff] [blame] | 430 | set(CMAKE_INCLUDE_CURRENT_DIR ON) |
| 431 | |
| NAKAMURA Takumi | 03932fb | 2013-12-16 15:05:39 +0000 | [diff] [blame] | 432 | include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}) |
| Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 433 | |
| David Chisnall | 7945013 | 2013-02-14 15:40:44 +0000 | [diff] [blame] | 434 | if( ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD ) |
| 435 | # On FreeBSD, /usr/local/* is not used by default. In order to build LLVM |
| 436 | # with libxml2, iconv.h, etc., we must add /usr/local paths. |
| 437 | include_directories("/usr/local/include") |
| 438 | link_directories("/usr/local/lib") |
| 439 | endif( ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD ) |
| 440 | |
| Edward O'Callaghan | 396ed2b | 2009-10-12 04:00:11 +0000 | [diff] [blame] | 441 | if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS ) |
| Oscar Fuentes | 2d48f65 | 2011-07-17 17:35:15 +0000 | [diff] [blame] | 442 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include llvm/Support/Solaris.h") |
| Edward O'Callaghan | 396ed2b | 2009-10-12 04:00:11 +0000 | [diff] [blame] | 443 | endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS ) |
| 444 | |
| Rafael Espindola | 76f9227 | 2013-04-04 01:01:32 +0000 | [diff] [blame] | 445 | # Make sure we don't get -rdynamic in every binary. For those that need it, |
| 446 | # use set_target_properties(target PROPERTIES ENABLE_EXPORTS 1) |
| 447 | set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") |
| 448 | |
| Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 449 | include(AddLLVM) |
| Oscar Fuentes | cdc9549 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 450 | include(TableGen) |
| Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 451 | |
| Michael J. Spencer | 7c3a5ee | 2010-09-11 02:13:39 +0000 | [diff] [blame] | 452 | if( MINGW ) |
| Oscar Fuentes | 9bf2595 | 2011-01-07 20:31:03 +0000 | [diff] [blame] | 453 | # People report that -O3 is unreliable on MinGW. The traditional |
| 454 | # build also uses -O2 for that reason: |
| 455 | llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2") |
| 456 | endif() |
| 457 | |
| Oscar Fuentes | 5ed9626 | 2011-02-18 22:06:14 +0000 | [diff] [blame] | 458 | # Put this before tblgen. Else we have a circular dependence. |
| Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 459 | add_subdirectory(lib/Support) |
| Peter Collingbourne | 84c287e | 2011-10-01 16:41:13 +0000 | [diff] [blame] | 460 | add_subdirectory(lib/TableGen) |
| Oscar Fuentes | 8807bdd | 2008-09-22 18:21:51 +0000 | [diff] [blame] | 461 | |
| Oscar Fuentes | e352ca0 | 2008-11-10 01:32:14 +0000 | [diff] [blame] | 462 | add_subdirectory(utils/TableGen) |
| 463 | |
| Oscar Fuentes | dc8d56e | 2008-11-15 00:24:38 +0000 | [diff] [blame] | 464 | add_subdirectory(include/llvm) |
| Oscar Fuentes | 8807bdd | 2008-09-22 18:21:51 +0000 | [diff] [blame] | 465 | |
| Oscar Fuentes | 5ed9626 | 2011-02-18 22:06:14 +0000 | [diff] [blame] | 466 | add_subdirectory(lib) |
| Oscar Fuentes | cdc9549 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 467 | |
| Douglas Gregor | 289dfc5 | 2009-07-20 18:30:25 +0000 | [diff] [blame] | 468 | add_subdirectory(utils/FileCheck) |
| Michael J. Spencer | 01639a4 | 2010-12-09 17:54:44 +0000 | [diff] [blame] | 469 | add_subdirectory(utils/FileUpdate) |
| Daniel Dunbar | 00dd448 | 2009-09-24 06:23:57 +0000 | [diff] [blame] | 470 | add_subdirectory(utils/count) |
| 471 | add_subdirectory(utils/not) |
| Michael J. Spencer | 885611b | 2010-09-13 17:52:38 +0000 | [diff] [blame] | 472 | add_subdirectory(utils/llvm-lit) |
| Michael J. Spencer | 22120c4 | 2012-04-03 23:09:22 +0000 | [diff] [blame] | 473 | add_subdirectory(utils/yaml-bench) |
| Douglas Gregor | 289dfc5 | 2009-07-20 18:30:25 +0000 | [diff] [blame] | 474 | |
| NAKAMURA Takumi | 5a0234f | 2014-01-31 17:32:46 +0000 | [diff] [blame] | 475 | if(LLVM_INCLUDE_TESTS) |
| 476 | add_subdirectory(utils/unittest) |
| 477 | endif() |
| 478 | |
| Oscar Fuentes | afbe975 | 2009-03-06 01:16:52 +0000 | [diff] [blame] | 479 | add_subdirectory(projects) |
| Oscar Fuentes | a229b3c | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 480 | |
| Oscar Fuentes | bf03084 | 2010-09-25 20:43:06 +0000 | [diff] [blame] | 481 | if( LLVM_INCLUDE_TOOLS ) |
| 482 | add_subdirectory(tools) |
| 483 | endif() |
| Oscar Fuentes | acfd9ad | 2009-08-16 20:56:30 +0000 | [diff] [blame] | 484 | |
| Oscar Fuentes | bf03084 | 2010-09-25 20:43:06 +0000 | [diff] [blame] | 485 | if( LLVM_INCLUDE_EXAMPLES ) |
| 486 | add_subdirectory(examples) |
| 487 | endif() |
| Oscar Fuentes | 64c9962 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 488 | |
| Oscar Fuentes | bf03084 | 2010-09-25 20:43:06 +0000 | [diff] [blame] | 489 | if( LLVM_INCLUDE_TESTS ) |
| 490 | add_subdirectory(test) |
| Oscar Fuentes | bf03084 | 2010-09-25 20:43:06 +0000 | [diff] [blame] | 491 | add_subdirectory(unittests) |
| NAKAMURA Takumi | 4bb599c | 2010-10-26 05:08:27 +0000 | [diff] [blame] | 492 | if (MSVC) |
| Joel Jones | 54594f2 | 2012-12-13 15:25:07 +0000 | [diff] [blame] | 493 | # This utility is used to prevent crashing tests from calling Dr. Watson on |
| Michael J. Spencer | 279362d | 2010-10-11 19:55:38 +0000 | [diff] [blame] | 494 | # Windows. |
| 495 | add_subdirectory(utils/KillTheDoctor) |
| 496 | endif() |
| Chandler Carruth | 69ce665 | 2012-06-30 10:14:14 +0000 | [diff] [blame] | 497 | |
| 498 | # Add a global check rule now that all subdirectories have been traversed |
| 499 | # and we know the total set of lit testsuites. |
| 500 | get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES) |
| 501 | get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS) |
| 502 | get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS) |
| 503 | get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS) |
| 504 | add_lit_target(check-all |
| 505 | "Running all regression tests" |
| 506 | ${LLVM_LIT_TESTSUITES} |
| 507 | PARAMS ${LLVM_LIT_PARAMS} |
| 508 | DEPENDS ${LLVM_LIT_DEPENDS} |
| 509 | ARGS ${LLVM_LIT_EXTRA_ARGS} |
| 510 | ) |
| Oscar Fuentes | bf03084 | 2010-09-25 20:43:06 +0000 | [diff] [blame] | 511 | endif() |
| Michael J. Spencer | 10d274d | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 512 | |
| Michael Gottesman | 4d35b90 | 2013-08-24 07:25:21 +0000 | [diff] [blame] | 513 | if (LLVM_INCLUDE_DOCS) |
| 514 | add_subdirectory(docs) |
| 515 | endif() |
| 516 | |
| Oscar Fuentes | a389c58 | 2010-08-09 03:26:43 +0000 | [diff] [blame] | 517 | add_subdirectory(cmake/modules) |
| 518 | |
| Hans Wennborg | 1654627 | 2013-08-24 00:20:36 +0000 | [diff] [blame] | 519 | if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) |
| 520 | install(DIRECTORY include/ |
| 521 | DESTINATION include |
| 522 | FILES_MATCHING |
| 523 | PATTERN "*.def" |
| 524 | PATTERN "*.h" |
| 525 | PATTERN "*.td" |
| 526 | PATTERN "*.inc" |
| 527 | PATTERN "LICENSE.TXT" |
| 528 | PATTERN ".svn" EXCLUDE |
| 529 | ) |
| Oscar Fuentes | 64c9962 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 530 | |
| NAKAMURA Takumi | 03932fb | 2013-12-16 15:05:39 +0000 | [diff] [blame] | 531 | install(DIRECTORY ${LLVM_INCLUDE_DIR}/ |
| Hans Wennborg | 1654627 | 2013-08-24 00:20:36 +0000 | [diff] [blame] | 532 | DESTINATION include |
| 533 | FILES_MATCHING |
| 534 | PATTERN "*.def" |
| 535 | PATTERN "*.h" |
| 536 | PATTERN "*.gen" |
| 537 | PATTERN "*.inc" |
| 538 | # Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def" |
| 539 | PATTERN "CMakeFiles" EXCLUDE |
| 540 | PATTERN ".svn" EXCLUDE |
| 541 | ) |
| 542 | endif() |
| 543 | |
| NAKAMURA Takumi | 148b62c | 2010-11-19 03:19:18 +0000 | [diff] [blame] | 544 | # Workaround for MSVS10 to avoid the Dialog Hell |
| 545 | # FIXME: This could be removed with future version of CMake. |
| 546 | if(MSVC_VERSION EQUAL 1600) |
| 547 | set(LLVM_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/LLVM.sln") |
| 548 | if( EXISTS "${LLVM_SLN_FILENAME}" ) |
| 549 | file(APPEND "${LLVM_SLN_FILENAME}" "\n# This should be regenerated!\n") |
| 550 | endif() |
| 551 | endif() |
| Rafael Espindola | fc0447b | 2013-10-31 22:13:41 +0000 | [diff] [blame] | 552 | |