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