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