Reid Kleckner | a2a07f9 | 2016-03-28 18:19:32 +0000 | [diff] [blame] | 1 | # See docs/CMake.html for instructions about how to build LLVM with CMake. |
| 2 | |
| 3 | cmake_minimum_required(VERSION 2.8.12.2) |
| 4 | |
| 5 | if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) |
| 6 | message(STATUS "No build type selected, default to Debug") |
| 7 | set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (default Debug)") |
| 8 | endif() |
| 9 | |
| 10 | if(POLICY CMP0022) |
| 11 | cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required |
| 12 | endif() |
| 13 | |
| 14 | if (POLICY CMP0051) |
| 15 | # CMake 3.1 and higher include generator expressions of the form |
| 16 | # $<TARGETLIB:obj> in the SOURCES property. These need to be |
| 17 | # stripped everywhere that access the SOURCES property, so we just |
| 18 | # defer to the OLD behavior of not including generator expressions |
| 19 | # in the output for now. |
| 20 | cmake_policy(SET CMP0051 OLD) |
| 21 | endif() |
| 22 | |
| 23 | if(CMAKE_VERSION VERSION_LESS 3.1.20141117) |
| 24 | set(cmake_3_2_USES_TERMINAL) |
| 25 | else() |
| 26 | set(cmake_3_2_USES_TERMINAL USES_TERMINAL) |
| 27 | endif() |
| 28 | |
| 29 | if(NOT DEFINED LLVM_VERSION_MAJOR) |
| 30 | set(LLVM_VERSION_MAJOR 3) |
| 31 | endif() |
| 32 | if(NOT DEFINED LLVM_VERSION_MINOR) |
| 33 | set(LLVM_VERSION_MINOR 9) |
| 34 | endif() |
| 35 | if(NOT DEFINED LLVM_VERSION_PATCH) |
| 36 | set(LLVM_VERSION_PATCH 0) |
| 37 | endif() |
| 38 | if(NOT DEFINED LLVM_VERSION_SUFFIX) |
| 39 | set(LLVM_VERSION_SUFFIX svn) |
| 40 | endif() |
| 41 | |
| 42 | if (POLICY CMP0048) |
| 43 | cmake_policy(SET CMP0048 NEW) |
| 44 | set(cmake_3_0_PROJ_VERSION |
| 45 | VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}) |
| 46 | set(cmake_3_0_LANGUAGES LANGUAGES) |
| 47 | endif() |
| 48 | |
| 49 | if (NOT PACKAGE_VERSION) |
| 50 | set(PACKAGE_VERSION |
| 51 | "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}") |
| 52 | endif() |
| 53 | |
| 54 | project(LLVM |
| 55 | ${cmake_3_0_PROJ_VERSION} |
| 56 | ${cmake_3_0_LANGUAGES} |
| 57 | C CXX ASM) |
| 58 | |
Chris Bieneman | 6108658 | 2016-04-28 20:14:19 +0000 | [diff] [blame] | 59 | if(APPLE) |
| 60 | if(NOT CMAKE_LIBTOOL) |
| 61 | find_program(CMAKE_LIBTOOL NAMES libtool) |
| 62 | endif() |
| 63 | if(CMAKE_LIBTOOL) |
| 64 | set(CMAKE_LIBTOOL ${CMAKE_LIBTOOL} CACHE PATH "libtool executable") |
| 65 | message(STATUS "Found libtool - ${CMAKE_LIBTOOL}") |
| 66 | get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) |
| 67 | foreach(lang ${languages}) |
| 68 | set(CMAKE_${lang}_CREATE_STATIC_LIBRARY |
| 69 | "${CMAKE_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ") |
| 70 | endforeach() |
| 71 | endif() |
| 72 | endif() |
| 73 | |
Reid Kleckner | a2a07f9 | 2016-03-28 18:19:32 +0000 | [diff] [blame] | 74 | # The following only works with the Ninja generator in CMake >= 3.0. |
| 75 | set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING |
| 76 | "Define the maximum number of concurrent compilation jobs.") |
| 77 | if(LLVM_PARALLEL_COMPILE_JOBS) |
| 78 | if(CMAKE_VERSION VERSION_LESS 3.0 OR NOT CMAKE_MAKE_PROGRAM MATCHES "ninja") |
| 79 | message(WARNING "Job pooling is only available with Ninja generators and CMake 3.0 and later.") |
| 80 | else() |
| 81 | set_property(GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool=${LLVM_PARALLEL_COMPILE_JOBS}) |
| 82 | set(CMAKE_JOB_POOL_COMPILE compile_job_pool) |
| 83 | endif() |
| 84 | endif() |
| 85 | |
| 86 | set(LLVM_BUILD_GLOBAL_ISEL OFF CACHE BOOL "Experimental: Build GlobalISel") |
| 87 | if(LLVM_BUILD_GLOBAL_ISEL) |
| 88 | add_definitions(-DLLVM_BUILD_GLOBAL_ISEL) |
| 89 | endif() |
| 90 | |
| 91 | set(LLVM_PARALLEL_LINK_JOBS "" CACHE STRING |
| 92 | "Define the maximum number of concurrent link jobs.") |
| 93 | if(LLVM_PARALLEL_LINK_JOBS) |
| 94 | if(CMAKE_VERSION VERSION_LESS 3.0 OR NOT CMAKE_MAKE_PROGRAM MATCHES "ninja") |
| 95 | message(WARNING "Job pooling is only available with Ninja generators and CMake 3.0 and later.") |
| 96 | else() |
| 97 | set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${LLVM_PARALLEL_LINK_JOBS}) |
| 98 | set(CMAKE_JOB_POOL_LINK link_job_pool) |
| 99 | endif() |
| 100 | endif() |
| 101 | |
| 102 | # Add path for custom modules |
| 103 | set(CMAKE_MODULE_PATH |
| 104 | ${CMAKE_MODULE_PATH} |
| 105 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake" |
| 106 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" |
| 107 | ) |
| 108 | |
| 109 | # Generate a CompilationDatabase (compile_commands.json file) for our build, |
| 110 | # for use by clang_complete, YouCompleteMe, etc. |
| 111 | set(CMAKE_EXPORT_COMPILE_COMMANDS 1) |
| 112 | |
| 113 | option(LLVM_INSTALL_UTILS "Include utility binaries in the 'install' target." OFF) |
| 114 | |
| 115 | option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF) |
| 116 | |
| 117 | option(LLVM_USE_FOLDERS "Enable solution folders in Visual Studio. Disable for Express versions." ON) |
| 118 | if ( LLVM_USE_FOLDERS ) |
| 119 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 120 | endif() |
| 121 | |
| 122 | include(VersionFromVCS) |
| 123 | |
| 124 | option(LLVM_APPEND_VC_REV |
| 125 | "Append the version control system revision id to LLVM version" OFF) |
| 126 | |
| 127 | if( LLVM_APPEND_VC_REV ) |
| 128 | add_version_info_from_vcs(PACKAGE_VERSION) |
| 129 | endif() |
| 130 | |
| 131 | set(PACKAGE_NAME LLVM) |
| 132 | set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") |
| 133 | set(PACKAGE_BUGREPORT "http://llvm.org/bugs/") |
| 134 | |
| 135 | set(BUG_REPORT_URL "${PACKAGE_BUGREPORT}" CACHE STRING |
| 136 | "Default URL where bug reports are to be submitted.") |
| 137 | |
| 138 | # Configure CPack. |
| 139 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "LLVM") |
| 140 | set(CPACK_PACKAGE_VENDOR "LLVM") |
| 141 | set(CPACK_PACKAGE_VERSION_MAJOR ${LLVM_VERSION_MAJOR}) |
| 142 | set(CPACK_PACKAGE_VERSION_MINOR ${LLVM_VERSION_MINOR}) |
| 143 | set(CPACK_PACKAGE_VERSION_PATCH ${LLVM_VERSION_PATCH}) |
| 144 | set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION}) |
| 145 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT") |
| 146 | set(CPACK_NSIS_COMPRESSOR "/SOLID lzma \r\n SetCompressorDictSize 32") |
| 147 | if(WIN32 AND NOT UNIX) |
| 148 | set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "LLVM") |
| 149 | set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_logo.bmp") |
| 150 | set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico") |
| 151 | set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico") |
| 152 | set(CPACK_NSIS_MODIFY_PATH "ON") |
| 153 | set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON") |
| 154 | set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS |
| 155 | "ExecWait '$INSTDIR/tools/msbuild/install.bat'") |
| 156 | set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS |
| 157 | "ExecWait '$INSTDIR/tools/msbuild/uninstall.bat'") |
| 158 | if( CMAKE_CL_64 ) |
| 159 | set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") |
| 160 | endif() |
| 161 | endif() |
| 162 | include(CPack) |
| 163 | |
| 164 | # Sanity check our source directory to make sure that we are not trying to |
| 165 | # generate an in-tree build (unless on MSVC_IDE, where it is ok), and to make |
| 166 | # sure that we don't have any stray generated files lying around in the tree |
| 167 | # (which would end up getting picked up by header search, instead of the correct |
| 168 | # versions). |
| 169 | if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) |
| 170 | message(FATAL_ERROR "In-source builds are not allowed. |
| 171 | CMake would overwrite the makefiles distributed with LLVM. |
| 172 | Please create a directory and run cmake from there, passing the path |
| 173 | to this source directory as the last argument. |
| 174 | This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. |
| 175 | Please delete them.") |
| 176 | endif() |
| 177 | if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) |
| 178 | file(GLOB_RECURSE |
| 179 | tablegenned_files_on_include_dir |
| 180 | "${CMAKE_CURRENT_SOURCE_DIR}/include/llvm/*.gen") |
| 181 | file(GLOB_RECURSE |
| 182 | tablegenned_files_on_lib_dir |
| 183 | "${CMAKE_CURRENT_SOURCE_DIR}/lib/Target/*.inc") |
| 184 | if( tablegenned_files_on_include_dir OR tablegenned_files_on_lib_dir) |
| 185 | message(FATAL_ERROR "Apparently there is a previous in-source build, |
| 186 | probably as the result of running `configure' and `make' on |
| 187 | ${CMAKE_CURRENT_SOURCE_DIR}. |
| 188 | This may cause problems. The suspicious files are: |
| 189 | ${tablegenned_files_on_lib_dir} |
| 190 | ${tablegenned_files_on_include_dir} |
| 191 | Please clean the source directory.") |
| 192 | endif() |
| 193 | endif() |
| 194 | |
| 195 | string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) |
| 196 | |
| 197 | if (CMAKE_BUILD_TYPE AND |
| 198 | NOT uppercase_CMAKE_BUILD_TYPE MATCHES "^(DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL)$") |
| 199 | message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") |
| 200 | endif() |
| 201 | |
| 202 | set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" ) |
| 203 | |
| 204 | # They are used as destination of target generators. |
| 205 | set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) |
| 206 | set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) |
| 207 | if(WIN32 OR CYGWIN) |
| 208 | # DLL platform -- put DLLs into bin. |
| 209 | set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) |
| 210 | else() |
| 211 | set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) |
| 212 | endif() |
| 213 | |
| 214 | # Each of them corresponds to llvm-config's. |
| 215 | set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir |
| 216 | set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) # --libdir |
| 217 | set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root |
| 218 | set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir |
| 219 | set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) # --prefix |
| 220 | |
| 221 | set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples) |
| 222 | set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include) |
| 223 | |
| 224 | set(LLVM_ALL_TARGETS |
| 225 | AArch64 |
| 226 | AMDGPU |
| 227 | ARM |
| 228 | BPF |
| 229 | CppBackend |
| 230 | Hexagon |
| 231 | Mips |
| 232 | MSP430 |
| 233 | NVPTX |
| 234 | PowerPC |
| 235 | Sparc |
| 236 | SystemZ |
| 237 | X86 |
| 238 | XCore |
| 239 | ) |
| 240 | |
| 241 | # List of targets with JIT support: |
| 242 | set(LLVM_TARGETS_WITH_JIT X86 PowerPC AArch64 ARM Mips SystemZ) |
| 243 | |
| 244 | set(LLVM_TARGETS_TO_BUILD "all" |
| 245 | CACHE STRING "Semicolon-separated list of targets to build, or \"all\".") |
| 246 | |
| 247 | set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD "" |
| 248 | CACHE STRING "Semicolon-separated list of experimental targets to build.") |
| 249 | |
| 250 | option(BUILD_SHARED_LIBS |
| 251 | "Build all libraries as shared libraries instead of static" OFF) |
| 252 | |
| 253 | option(LLVM_ENABLE_TIMESTAMPS "Enable embedding timestamp information in build" ON) |
| 254 | if(LLVM_ENABLE_TIMESTAMPS) |
| 255 | set(ENABLE_TIMESTAMPS 1) |
| 256 | endif() |
| 257 | |
| 258 | option(LLVM_ENABLE_BACKTRACES "Enable embedding backtraces on crash." ON) |
| 259 | if(LLVM_ENABLE_BACKTRACES) |
| 260 | set(ENABLE_BACKTRACES 1) |
| 261 | endif() |
| 262 | |
| 263 | option(LLVM_ENABLE_CRASH_OVERRIDES "Enable crash overrides." ON) |
| 264 | if(LLVM_ENABLE_CRASH_OVERRIDES) |
| 265 | set(ENABLE_CRASH_OVERRIDES 1) |
| 266 | endif() |
| 267 | |
| 268 | option(LLVM_ENABLE_FFI "Use libffi to call external functions from the interpreter" OFF) |
| 269 | set(FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so") |
| 270 | set(FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for ffi.h or ffi/ffi.h") |
| 271 | |
| 272 | set(LLVM_TARGET_ARCH "host" |
| 273 | CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.") |
| 274 | |
| 275 | option(LLVM_ENABLE_TERMINFO "Use terminfo database if available." ON) |
| 276 | |
| 277 | option(LLVM_ENABLE_THREADS "Use threads if available." ON) |
| 278 | |
| 279 | option(LLVM_ENABLE_ZLIB "Use zlib for compression/decompression if available." ON) |
| 280 | |
| 281 | if( LLVM_TARGETS_TO_BUILD STREQUAL "all" ) |
| 282 | set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} ) |
| 283 | endif() |
| 284 | |
| 285 | set(LLVM_TARGETS_TO_BUILD |
| 286 | ${LLVM_TARGETS_TO_BUILD} |
| 287 | ${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}) |
| 288 | list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD) |
| 289 | |
| 290 | include(AddLLVMDefinitions) |
| 291 | |
| 292 | option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON) |
| 293 | option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) |
| 294 | option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF) |
| 295 | option(LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF) |
| 296 | option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF) |
| 297 | option(LLVM_ENABLE_LIBCXXABI "Use libc++abi when using libc++." OFF) |
| 298 | option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) |
| 299 | option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) |
| 300 | |
| 301 | if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" ) |
| 302 | option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF) |
| 303 | else() |
| 304 | option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) |
| 305 | endif() |
| 306 | |
Filipe Cabecinhas | 0da9937 | 2016-04-29 15:22:48 +0000 | [diff] [blame] | 307 | option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF) |
| 308 | |
Reid Kleckner | a2a07f9 | 2016-03-28 18:19:32 +0000 | [diff] [blame] | 309 | set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING |
| 310 | "Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF.") |
| 311 | |
| 312 | option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN |
| 313 | "Set to ON to force using an old, unsupported host toolchain." OFF) |
| 314 | |
| 315 | option(LLVM_USE_INTEL_JITEVENTS |
| 316 | "Use Intel JIT API to inform Intel(R) VTune(TM) Amplifier XE 2011 about JIT code" |
| 317 | OFF) |
| 318 | |
| 319 | if( LLVM_USE_INTEL_JITEVENTS ) |
| 320 | # Verify we are on a supported platform |
| 321 | if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) |
| 322 | message(FATAL_ERROR |
| 323 | "Intel JIT API support is available on Linux and Windows only.") |
| 324 | endif() |
| 325 | endif( LLVM_USE_INTEL_JITEVENTS ) |
| 326 | |
| 327 | option(LLVM_USE_OPROFILE |
| 328 | "Use opagent JIT interface to inform OProfile about JIT code" OFF) |
| 329 | |
| 330 | option(LLVM_EXTERNALIZE_DEBUGINFO |
| 331 | "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF) |
| 332 | |
| 333 | # If enabled, verify we are on a platform that supports oprofile. |
| 334 | if( LLVM_USE_OPROFILE ) |
| 335 | if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) |
| 336 | message(FATAL_ERROR "OProfile support is available on Linux only.") |
| 337 | endif( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) |
| 338 | endif( LLVM_USE_OPROFILE ) |
| 339 | |
| 340 | set(LLVM_USE_SANITIZER "" CACHE STRING |
| 341 | "Define the sanitizer used to build binaries and tests.") |
| 342 | |
| 343 | option(LLVM_USE_SPLIT_DWARF |
| 344 | "Use -gsplit-dwarf when compiling llvm." OFF) |
| 345 | |
| 346 | option(WITH_POLLY "Build LLVM with Polly" ON) |
Tobias Grosser | d7773f7 | 2016-04-29 15:07:22 +0000 | [diff] [blame] | 347 | option(LINK_POLLY_INTO_TOOLS "Static link Polly into tools" ON) |
Reid Kleckner | a2a07f9 | 2016-03-28 18:19:32 +0000 | [diff] [blame] | 348 | |
| 349 | # Define an option controlling whether we should build for 32-bit on 64-bit |
| 350 | # platforms, where supported. |
| 351 | if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) |
| 352 | # TODO: support other platforms and toolchains. |
| 353 | option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF) |
| 354 | endif() |
| 355 | |
| 356 | # Define the default arguments to use with 'lit', and an option for the user to |
| 357 | # override. |
| 358 | set(LIT_ARGS_DEFAULT "-sv") |
| 359 | if (MSVC_IDE OR XCODE) |
| 360 | set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") |
| 361 | endif() |
| 362 | set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") |
| 363 | |
| 364 | # On Win32 hosts, provide an option to specify the path to the GnuWin32 tools. |
| 365 | if( WIN32 AND NOT CYGWIN ) |
| 366 | set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") |
| 367 | endif() |
| 368 | |
| 369 | # Define options to control the inclusion and default build behavior for |
| 370 | # components which may not strictly be necessary (tools, examples, and tests). |
| 371 | # |
| 372 | # This is primarily to support building smaller or faster project files. |
| 373 | option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON) |
| 374 | option(LLVM_BUILD_TOOLS |
| 375 | "Build the LLVM tools. If OFF, just generate build targets." ON) |
| 376 | |
| 377 | option(LLVM_INCLUDE_UTILS "Generate build targets for the LLVM utils." ON) |
| 378 | |
| 379 | option(LLVM_BUILD_RUNTIME |
| 380 | "Build the LLVM runtime libraries." ON) |
| 381 | option(LLVM_BUILD_EXAMPLES |
| 382 | "Build the LLVM example programs. If OFF, just generate build targets." OFF) |
| 383 | option(LLVM_INCLUDE_EXAMPLES "Generate build targets for the LLVM examples" ON) |
| 384 | |
| 385 | option(LLVM_BUILD_TESTS |
| 386 | "Build LLVM unit tests. If OFF, just generate build targets." OFF) |
| 387 | option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON) |
| 388 | option(LLVM_INCLUDE_GO_TESTS "Include the Go bindings tests in test build targets." ON) |
| 389 | |
| 390 | option (LLVM_BUILD_DOCS "Build the llvm documentation." OFF) |
| 391 | option (LLVM_INCLUDE_DOCS "Generate build targets for llvm documentation." ON) |
| 392 | option (LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm API documentation." OFF) |
| 393 | option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF) |
| 394 | |
| 395 | option (LLVM_BUILD_EXTERNAL_COMPILER_RT |
| 396 | "Build compiler-rt as an external project." OFF) |
| 397 | |
Tobias Grosser | d7773f7 | 2016-04-29 15:07:22 +0000 | [diff] [blame] | 398 | if(WITH_POLLY) |
| 399 | if(NOT EXISTS ${LLVM_MAIN_SRC_DIR}/tools/polly/CMakeLists.txt) |
| 400 | set(WITH_POLLY OFF) |
| 401 | endif() |
| 402 | endif(WITH_POLLY) |
| 403 | |
| 404 | if (NOT WITH_POLLY) |
| 405 | set(LINK_POLLY_INTO_TOOLS OFF) |
| 406 | endif (NOT WITH_POLLY) |
| 407 | |
Reid Kleckner | a2a07f9 | 2016-03-28 18:19:32 +0000 | [diff] [blame] | 408 | # You can configure which libraries from LLVM you want to include in the |
| 409 | # shared library by setting LLVM_DYLIB_COMPONENTS to a semi-colon delimited |
| 410 | # list of LLVM components. All component names handled by llvm-config are valid. |
| 411 | if(NOT DEFINED LLVM_DYLIB_COMPONENTS) |
| 412 | set(LLVM_DYLIB_COMPONENTS "all" CACHE STRING |
| 413 | "Semicolon-separated list of components to include in libLLVM, or \"all\".") |
| 414 | endif() |
| 415 | option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF) |
| 416 | option(LLVM_BUILD_LLVM_C_DYLIB "Build libllvm-c re-export library (Darwin Only)" OFF) |
| 417 | set(LLVM_BUILD_LLVM_DYLIB_default OFF) |
| 418 | if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB) |
| 419 | set(LLVM_BUILD_LLVM_DYLIB_default ON) |
| 420 | endif() |
| 421 | option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default}) |
| 422 | |
| 423 | option(LLVM_OPTIMIZED_TABLEGEN "Force TableGen to be built with optimization" OFF) |
| 424 | if(CMAKE_CROSSCOMPILING OR (LLVM_OPTIMIZED_TABLEGEN AND LLVM_ENABLE_ASSERTIONS)) |
| 425 | set(LLVM_USE_HOST_TOOLS ON) |
| 426 | endif() |
| 427 | |
| 428 | if (MSVC_IDE AND NOT (MSVC_VERSION LESS 1900)) |
| 429 | option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE) |
| 430 | else() |
| 431 | set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\Visual Studio 2013\\Visualizers" FORCE) |
| 432 | endif() |
| 433 | |
| 434 | # All options referred to from HandleLLVMOptions have to be specified |
| 435 | # BEFORE this include, otherwise options will not be correctly set on |
| 436 | # first cmake run |
| 437 | include(config-ix) |
| 438 | |
| 439 | string(REPLACE "Native" ${LLVM_NATIVE_ARCH} |
| 440 | LLVM_TARGETS_TO_BUILD "${LLVM_TARGETS_TO_BUILD}") |
| 441 | list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD) |
| 442 | |
| 443 | # By default, we target the host, but this can be overridden at CMake |
| 444 | # invocation time. |
| 445 | set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING |
| 446 | "Default target for which LLVM will generate code." ) |
| 447 | set(TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}") |
| 448 | |
| 449 | include(HandleLLVMOptions) |
| 450 | |
| 451 | # Verify that we can find a Python 2 interpreter. Python 3 is unsupported. |
| 452 | # FIXME: We should support systems with only Python 3, but that requires work |
| 453 | # on LLDB. |
| 454 | set(Python_ADDITIONAL_VERSIONS 2.7) |
| 455 | include(FindPythonInterp) |
| 456 | if( NOT PYTHONINTERP_FOUND ) |
| 457 | message(FATAL_ERROR |
| 458 | "Unable to find Python interpreter, required for builds and testing. |
| 459 | |
| 460 | Please install Python or specify the PYTHON_EXECUTABLE CMake variable.") |
| 461 | endif() |
| 462 | |
| 463 | if( ${PYTHON_VERSION_STRING} VERSION_LESS 2.7 ) |
| 464 | message(FATAL_ERROR "Python 2.7 or newer is required") |
| 465 | endif() |
| 466 | |
| 467 | ###### |
| 468 | # LLVMBuild Integration |
| 469 | # |
| 470 | # We use llvm-build to generate all the data required by the CMake based |
| 471 | # build system in one swoop: |
| 472 | # |
| 473 | # - We generate a file (a CMake fragment) in the object root which contains |
| 474 | # all the definitions that are required by CMake. |
| 475 | # |
| 476 | # - We generate the library table used by llvm-config. |
| 477 | # |
| 478 | # - We generate the dependencies for the CMake fragment, so that we will |
| 479 | # automatically reconfigure outselves. |
| 480 | |
| 481 | set(LLVMBUILDTOOL "${LLVM_MAIN_SRC_DIR}/utils/llvm-build/llvm-build") |
| 482 | set(LLVMCONFIGLIBRARYDEPENDENCIESINC |
| 483 | "${LLVM_BINARY_DIR}/tools/llvm-config/LibraryDependencies.inc") |
| 484 | set(LLVMBUILDCMAKEFRAG |
| 485 | "${LLVM_BINARY_DIR}/LLVMBuild.cmake") |
| 486 | |
| 487 | # Create the list of optional components that are enabled |
| 488 | if (LLVM_USE_INTEL_JITEVENTS) |
| 489 | set(LLVMOPTIONALCOMPONENTS IntelJITEvents) |
| 490 | endif (LLVM_USE_INTEL_JITEVENTS) |
| 491 | if (LLVM_USE_OPROFILE) |
| 492 | set(LLVMOPTIONALCOMPONENTS ${LLVMOPTIONALCOMPONENTS} OProfileJIT) |
| 493 | endif (LLVM_USE_OPROFILE) |
| 494 | |
| 495 | message(STATUS "Constructing LLVMBuild project information") |
| 496 | execute_process( |
| 497 | COMMAND ${PYTHON_EXECUTABLE} ${LLVMBUILDTOOL} |
| 498 | --native-target "${LLVM_NATIVE_ARCH}" |
| 499 | --enable-targets "${LLVM_TARGETS_TO_BUILD}" |
| 500 | --enable-optional-components "${LLVMOPTIONALCOMPONENTS}" |
| 501 | --write-library-table ${LLVMCONFIGLIBRARYDEPENDENCIESINC} |
| 502 | --write-cmake-fragment ${LLVMBUILDCMAKEFRAG} |
| 503 | OUTPUT_VARIABLE LLVMBUILDOUTPUT |
| 504 | ERROR_VARIABLE LLVMBUILDERRORS |
| 505 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 506 | ERROR_STRIP_TRAILING_WHITESPACE |
| 507 | RESULT_VARIABLE LLVMBUILDRESULT) |
| 508 | |
| 509 | # On Win32, CMake doesn't properly handle piping the default output/error |
| 510 | # streams into the GUI console. So, we explicitly catch and report them. |
| 511 | if( NOT "${LLVMBUILDOUTPUT}" STREQUAL "") |
| 512 | message(STATUS "llvm-build output: ${LLVMBUILDOUTPUT}") |
| 513 | endif() |
| 514 | if( NOT "${LLVMBUILDRESULT}" STREQUAL "0" ) |
| 515 | message(FATAL_ERROR |
| 516 | "Unexpected failure executing llvm-build: ${LLVMBUILDERRORS}") |
| 517 | endif() |
| 518 | |
| 519 | # Include the generated CMake fragment. This will define properties from the |
| 520 | # LLVMBuild files in a format which is easy to consume from CMake, and will add |
| 521 | # the dependencies so that CMake will reconfigure properly when the LLVMBuild |
| 522 | # files change. |
| 523 | include(${LLVMBUILDCMAKEFRAG}) |
| 524 | |
| 525 | ###### |
| 526 | |
| 527 | # Configure all of the various header file fragments LLVM uses which depend on |
| 528 | # configuration variables. |
| 529 | set(LLVM_ENUM_TARGETS "") |
| 530 | set(LLVM_ENUM_ASM_PRINTERS "") |
| 531 | set(LLVM_ENUM_ASM_PARSERS "") |
| 532 | set(LLVM_ENUM_DISASSEMBLERS "") |
| 533 | foreach(t ${LLVM_TARGETS_TO_BUILD}) |
| 534 | set( td ${LLVM_MAIN_SRC_DIR}/lib/Target/${t} ) |
| 535 | |
| 536 | list(FIND LLVM_ALL_TARGETS ${t} idx) |
| 537 | list(FIND LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ${t} idy) |
| 538 | if( idx LESS 0 AND idy LESS 0 ) |
| 539 | message(FATAL_ERROR "The target `${t}' does not exist. |
| 540 | It should be one of\n${LLVM_ALL_TARGETS}") |
| 541 | else() |
| 542 | set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${t})\n") |
| 543 | endif() |
| 544 | |
| 545 | file(GLOB asmp_file "${td}/*AsmPrinter.cpp") |
| 546 | if( asmp_file ) |
| 547 | set(LLVM_ENUM_ASM_PRINTERS |
| 548 | "${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n") |
| 549 | endif() |
| 550 | if( EXISTS ${td}/AsmParser/CMakeLists.txt ) |
| 551 | set(LLVM_ENUM_ASM_PARSERS |
| 552 | "${LLVM_ENUM_ASM_PARSERS}LLVM_ASM_PARSER(${t})\n") |
| 553 | endif() |
| 554 | if( EXISTS ${td}/Disassembler/CMakeLists.txt ) |
| 555 | set(LLVM_ENUM_DISASSEMBLERS |
| 556 | "${LLVM_ENUM_DISASSEMBLERS}LLVM_DISASSEMBLER(${t})\n") |
| 557 | endif() |
| 558 | endforeach(t) |
| 559 | |
| 560 | # Produce the target definition files, which provide a way for clients to easily |
| 561 | # include various classes of targets. |
| 562 | configure_file( |
| 563 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmPrinters.def.in |
| 564 | ${LLVM_INCLUDE_DIR}/llvm/Config/AsmPrinters.def |
| 565 | ) |
| 566 | configure_file( |
| 567 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmParsers.def.in |
| 568 | ${LLVM_INCLUDE_DIR}/llvm/Config/AsmParsers.def |
| 569 | ) |
| 570 | configure_file( |
| 571 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Disassemblers.def.in |
| 572 | ${LLVM_INCLUDE_DIR}/llvm/Config/Disassemblers.def |
| 573 | ) |
| 574 | configure_file( |
| 575 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.def.in |
| 576 | ${LLVM_INCLUDE_DIR}/llvm/Config/Targets.def |
| 577 | ) |
| 578 | |
| 579 | # Configure the three LLVM configuration header files. |
| 580 | configure_file( |
| 581 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/config.h.cmake |
| 582 | ${LLVM_INCLUDE_DIR}/llvm/Config/config.h) |
| 583 | configure_file( |
| 584 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/llvm-config.h.cmake |
| 585 | ${LLVM_INCLUDE_DIR}/llvm/Config/llvm-config.h) |
| 586 | configure_file( |
| 587 | ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/DataTypes.h.cmake |
| 588 | ${LLVM_INCLUDE_DIR}/llvm/Support/DataTypes.h) |
| 589 | |
| 590 | # They are not referenced. See set_output_directory(). |
| 591 | set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/bin ) |
| 592 | set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) |
| 593 | set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) |
| 594 | |
| 595 | set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) |
| 596 | if (APPLE) |
| 597 | set(CMAKE_INSTALL_NAME_DIR "@rpath") |
| 598 | set(CMAKE_INSTALL_RPATH "@executable_path/../lib") |
| 599 | else(UNIX) |
| 600 | if(NOT DEFINED CMAKE_INSTALL_RPATH) |
| 601 | set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}") |
| 602 | if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)") |
| 603 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,origin") |
| 604 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,origin") |
| 605 | endif() |
| 606 | endif(NOT DEFINED CMAKE_INSTALL_RPATH) |
| 607 | endif() |
| 608 | |
| 609 | if(APPLE AND DARWIN_LTO_LIBRARY) |
| 610 | set(CMAKE_EXE_LINKER_FLAGS |
| 611 | "${CMAKE_EXE_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}") |
| 612 | set(CMAKE_SHARED_LINKER_FLAGS |
| 613 | "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}") |
| 614 | set(CMAKE_MODULE_LINKER_FLAGS |
| 615 | "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}") |
| 616 | endif() |
| 617 | |
| 618 | # Work around a broken bfd ld behavior. When linking a binary with a |
| 619 | # foo.so library, it will try to find any library that foo.so uses and |
| 620 | # check its symbols. This is wasteful (the check was done when foo.so |
| 621 | # was created) and can fail since it is not the dynamic linker and |
| 622 | # doesn't know how to handle search paths correctly. |
| 623 | if (UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS") |
| 624 | set(CMAKE_EXE_LINKER_FLAGS |
| 625 | "${CMAKE_EXE_LINKER_FLAGS} -Wl,-allow-shlib-undefined") |
| 626 | endif() |
| 627 | |
| 628 | set(CMAKE_INCLUDE_CURRENT_DIR ON) |
| 629 | |
| 630 | include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}) |
| 631 | |
| 632 | # when crosscompiling import the executable targets from a file |
| 633 | if(LLVM_USE_HOST_TOOLS) |
| 634 | include(CrossCompile) |
| 635 | endif(LLVM_USE_HOST_TOOLS) |
| 636 | if(LLVM_TARGET_IS_CROSSCOMPILE_HOST) |
| 637 | # Dummy use to avoid CMake Wraning: Manually-specified variables were not used |
| 638 | # (this is a variable that CrossCompile sets on recursive invocations) |
| 639 | endif() |
| 640 | |
| 641 | if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)") |
| 642 | # On FreeBSD, /usr/local/* is not used by default. In order to build LLVM |
| 643 | # with libxml2, iconv.h, etc., we must add /usr/local paths. |
| 644 | include_directories("/usr/local/include") |
| 645 | link_directories("/usr/local/lib") |
| 646 | endif(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)") |
| 647 | |
| 648 | if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS ) |
| 649 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include llvm/Support/Solaris.h") |
| 650 | endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS ) |
| 651 | |
| 652 | # Make sure we don't get -rdynamic in every binary. For those that need it, |
| 653 | # use export_executable_symbols(target). |
| 654 | set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") |
| 655 | |
| 656 | set(LLVM_PROFDATA_FILE "" CACHE FILEPATH |
| 657 | "Profiling data file to use when compiling in order to improve runtime performance.") |
| 658 | |
| 659 | if(LLVM_PROFDATA_FILE AND EXISTS ${LLVM_PROFDATA_FILE}) |
| 660 | if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) |
| 661 | add_definitions("-fprofile-instr-use=${LLVM_PROFDATA_FILE}") |
| 662 | else() |
| 663 | message(FATAL_ERROR "LLVM_PROFDATA_FILE can only be specified when compiling with clang") |
| 664 | endif() |
| 665 | endif() |
| 666 | |
| 667 | include(AddLLVM) |
| 668 | include(TableGen) |
| 669 | |
| 670 | if( MINGW ) |
| 671 | # People report that -O3 is unreliable on MinGW. The traditional |
| 672 | # build also uses -O2 for that reason: |
| 673 | llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2") |
| 674 | endif() |
| 675 | |
| 676 | # Put this before tblgen. Else we have a circular dependence. |
| 677 | add_subdirectory(lib/Support) |
| 678 | add_subdirectory(lib/TableGen) |
| 679 | |
| 680 | add_subdirectory(utils/TableGen) |
| 681 | |
| 682 | add_subdirectory(include/llvm) |
| 683 | |
| 684 | add_subdirectory(lib) |
| 685 | |
| 686 | if( LLVM_INCLUDE_UTILS ) |
| 687 | add_subdirectory(utils/FileCheck) |
| 688 | add_subdirectory(utils/PerfectShuffle) |
| 689 | add_subdirectory(utils/count) |
| 690 | add_subdirectory(utils/not) |
| 691 | add_subdirectory(utils/llvm-lit) |
| 692 | add_subdirectory(utils/yaml-bench) |
| 693 | else() |
| 694 | if ( LLVM_INCLUDE_TESTS ) |
| 695 | message(FATAL_ERROR "Including tests when not building utils will not work. |
| 696 | Either set LLVM_INCLUDE_UTILS to On, or set LLVM_INCLDE_TESTS to Off.") |
| 697 | endif() |
| 698 | endif() |
| 699 | |
| 700 | # Use LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION instead of LLVM_INCLUDE_UTILS because it is not really a util |
| 701 | if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION) |
| 702 | add_subdirectory(utils/LLVMVisualizers) |
| 703 | endif() |
| 704 | |
| 705 | if(LLVM_INCLUDE_TESTS) |
| 706 | add_subdirectory(utils/unittest) |
| 707 | endif() |
| 708 | |
| 709 | foreach( binding ${LLVM_BINDINGS_LIST} ) |
| 710 | if( EXISTS "${LLVM_MAIN_SRC_DIR}/bindings/${binding}/CMakeLists.txt" ) |
| 711 | add_subdirectory(bindings/${binding}) |
| 712 | endif() |
| 713 | endforeach() |
| 714 | |
| 715 | add_subdirectory(projects) |
| 716 | |
Reid Kleckner | a2a07f9 | 2016-03-28 18:19:32 +0000 | [diff] [blame] | 717 | if( LLVM_INCLUDE_TOOLS ) |
| 718 | add_subdirectory(tools) |
| 719 | endif() |
| 720 | |
| 721 | if( LLVM_INCLUDE_EXAMPLES ) |
| 722 | add_subdirectory(examples) |
| 723 | endif() |
| 724 | |
| 725 | if( LLVM_INCLUDE_TESTS ) |
| 726 | if(EXISTS ${LLVM_MAIN_SRC_DIR}/projects/test-suite AND TARGET clang) |
| 727 | include(LLVMExternalProjectUtils) |
| 728 | llvm_ExternalProject_Add(test-suite ${LLVM_MAIN_SRC_DIR}/projects/test-suite |
| 729 | USE_TOOLCHAIN |
| 730 | EXCLUDE_FROM_ALL |
| 731 | NO_INSTALL) |
| 732 | endif() |
| 733 | add_subdirectory(test) |
| 734 | add_subdirectory(unittests) |
| 735 | if (MSVC) |
| 736 | # This utility is used to prevent crashing tests from calling Dr. Watson on |
| 737 | # Windows. |
| 738 | add_subdirectory(utils/KillTheDoctor) |
| 739 | endif() |
| 740 | |
| 741 | # Add a global check rule now that all subdirectories have been traversed |
| 742 | # and we know the total set of lit testsuites. |
| 743 | get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES) |
| 744 | get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS) |
| 745 | get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS) |
| 746 | get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS) |
| 747 | add_lit_target(check-all |
| 748 | "Running all regression tests" |
| 749 | ${LLVM_LIT_TESTSUITES} |
| 750 | PARAMS ${LLVM_LIT_PARAMS} |
| 751 | DEPENDS ${LLVM_LIT_DEPENDS} |
| 752 | ARGS ${LLVM_LIT_EXTRA_ARGS} |
| 753 | ) |
| 754 | add_custom_target(test-depends DEPENDS ${LLVM_LIT_DEPENDS}) |
Aaron Ballman | 01a9854 | 2016-04-12 15:09:14 +0000 | [diff] [blame] | 755 | set_target_properties(test-depends PROPERTIES FOLDER "Tests") |
Reid Kleckner | a2a07f9 | 2016-03-28 18:19:32 +0000 | [diff] [blame] | 756 | endif() |
| 757 | |
| 758 | if (LLVM_INCLUDE_DOCS) |
| 759 | add_subdirectory(docs) |
| 760 | endif() |
| 761 | |
| 762 | add_subdirectory(cmake/modules) |
| 763 | |
| 764 | if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) |
| 765 | install(DIRECTORY include/llvm include/llvm-c |
| 766 | DESTINATION include |
| 767 | COMPONENT llvm-headers |
| 768 | FILES_MATCHING |
| 769 | PATTERN "*.def" |
| 770 | PATTERN "*.h" |
| 771 | PATTERN "*.td" |
| 772 | PATTERN "*.inc" |
| 773 | PATTERN "LICENSE.TXT" |
| 774 | PATTERN ".svn" EXCLUDE |
| 775 | ) |
| 776 | |
| 777 | install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm |
| 778 | DESTINATION include |
| 779 | COMPONENT llvm-headers |
| 780 | FILES_MATCHING |
| 781 | PATTERN "*.def" |
| 782 | PATTERN "*.h" |
| 783 | PATTERN "*.gen" |
| 784 | PATTERN "*.inc" |
| 785 | # Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def" |
| 786 | PATTERN "CMakeFiles" EXCLUDE |
| 787 | PATTERN "config.h" EXCLUDE |
| 788 | PATTERN ".svn" EXCLUDE |
| 789 | ) |
| 790 | |
| 791 | if (NOT CMAKE_CONFIGURATION_TYPES) |
| 792 | add_custom_target(installhdrs |
| 793 | DEPENDS ${name} |
| 794 | COMMAND "${CMAKE_COMMAND}" |
| 795 | -DCMAKE_INSTALL_COMPONENT=llvm-headers |
| 796 | -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") |
| 797 | endif() |
| 798 | endif() |
| 799 | |
| 800 | # This must be at the end of the LLVM root CMakeLists file because it must run |
| 801 | # after all targets are created. |
| 802 | if(LLVM_DISTRIBUTION_COMPONENTS) |
| 803 | if(CMAKE_CONFIGURATION_TYPES) |
| 804 | message(FATAL_ERROR "LLVM_DISTRIBUTION_COMPONENTS cannot be specified with multi-configuration generators (i.e. Xcode or Visual Studio)") |
| 805 | endif() |
| 806 | |
| 807 | add_custom_target(distribution) |
| 808 | add_custom_target(install-distribution) |
| 809 | foreach(target ${LLVM_DISTRIBUTION_COMPONENTS}) |
| 810 | if(TARGET ${target}) |
| 811 | add_dependencies(distribution ${target}) |
| 812 | else() |
| 813 | message(FATAL_ERROR "Specified distribution component '${target}' doesn't have a target") |
| 814 | endif() |
| 815 | |
| 816 | if(TARGET install-${target}) |
| 817 | add_dependencies(install-distribution install-${target}) |
| 818 | else() |
| 819 | message(FATAL_ERROR "Specified distribution component '${target}' doesn't have an install target") |
| 820 | endif() |
| 821 | endforeach() |
| 822 | endif() |