1 # See docs/CMake.html for instructions about how to build LLVM with CMake.
3 cmake_minimum_required(VERSION 3.13.4)
5 # CMP0114: ExternalProject step targets fully adopt their steps.
6 # New in CMake 3.19: https://cmake.org/cmake/help/latest/policy/CMP0114.html
8 cmake_policy(SET CMP0114 OLD)
10 # CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
11 # New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
13 cmake_policy(SET CMP0116 OLD)
16 set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
18 if(NOT DEFINED LLVM_VERSION_MAJOR)
19 set(LLVM_VERSION_MAJOR 16)
21 if(NOT DEFINED LLVM_VERSION_MINOR)
22 set(LLVM_VERSION_MINOR 0)
24 if(NOT DEFINED LLVM_VERSION_PATCH)
25 set(LLVM_VERSION_PATCH 0)
27 if(NOT DEFINED LLVM_VERSION_SUFFIX)
28 set(LLVM_VERSION_SUFFIX git)
31 if (NOT PACKAGE_VERSION)
33 "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}")
36 if(NOT DEFINED LLVM_SHLIB_SYMBOL_VERSION)
37 # "Symbol version prefix for libLLVM.so"
38 set(LLVM_SHLIB_SYMBOL_VERSION "LLVM_${LLVM_VERSION_MAJOR}")
41 if ((CMAKE_GENERATOR MATCHES "Visual Studio") AND (MSVC_TOOLSET_VERSION LESS 142) AND (CMAKE_GENERATOR_TOOLSET STREQUAL ""))
42 message(WARNING "Visual Studio generators use the x86 host compiler by "
43 "default, even for 64-bit targets. This can result in linker "
44 "instability and out of memory errors. To use the 64-bit "
45 "host compiler, pass -Thost=x64 on the CMake command line.")
48 if (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT CMAKE_OSX_ARCHITECTURES)
49 # Some CMake features like object libraries get confused if you don't
50 # explicitly specify an architecture setting with the Xcode generator.
51 set(CMAKE_OSX_ARCHITECTURES "x86_64")
55 VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}
58 if (NOT DEFINED CMAKE_INSTALL_LIBDIR AND DEFINED LLVM_LIBDIR_SUFFIX)
59 # Must go before `include(GNUInstallDirs)`.
60 set(CMAKE_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}")
63 # Must go after `DEFINED LLVM_LIBDIR_SUFFIX` check.
64 set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
66 # Must go after `project(..)`.
67 include(GNUInstallDirs)
69 # This C++ standard is required to build LLVM.
70 set(LLVM_REQUIRED_CXX_STANDARD 17)
72 # If we find that the cache contains CMAKE_CXX_STANDARD it means that it's a old CMakeCache.txt
73 # and we can just inform the user and then reset it.
74 if($CACHE{CMAKE_CXX_STANDARD} AND $CACHE{CMAKE_CXX_STANDARD} LESS ${LLVM_REQUIRED_CXX_STANDARD})
75 message(WARNING "Resetting cache value for CMAKE_CXX_STANDARD to ${LLVM_REQUIRED_CXX_STANDARD}")
76 unset(CMAKE_CXX_STANDARD CACHE)
79 # if CMAKE_CXX_STANDARD is still set after the cache unset above it means that the user requested it
80 # and we allow it to be set to something newer than the required standard but otherwise we fail.
81 if(DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD LESS ${LLVM_REQUIRED_CXX_STANDARD})
82 message(FATAL_ERROR "Requested CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} which is less than the required ${LLVM_REQUIRED_CXX_STANDARD}.")
85 set(CMAKE_CXX_STANDARD ${LLVM_REQUIRED_CXX_STANDARD} CACHE STRING "C++ standard to conform to")
86 set(CMAKE_CXX_STANDARD_REQUIRED YES)
89 # Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in
91 set(CMAKE_CXX_EXTENSIONS YES)
93 set(CMAKE_CXX_EXTENSIONS NO)
96 if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
98 No build type selected. You need to pass -DCMAKE_BUILD_TYPE=<type> in order to configure LLVM.
99 Available options are:
100 * -DCMAKE_BUILD_TYPE=Release - For an optimized build with no assertions or debug info.
101 * -DCMAKE_BUILD_TYPE=Debug - For an unoptimized build with assertions and debug info.
102 * -DCMAKE_BUILD_TYPE=RelWithDebInfo - For an optimized build with no assertions but with debug info.
103 * -DCMAKE_BUILD_TYPE=MinSizeRel - For a build optimized for size instead of speed.
104 Learn more about these options in our documentation at https://llvm.org/docs/CMake.html#cmake-build-type
108 # Side-by-side subprojects layout: automatically set the
109 # LLVM_EXTERNAL_${project}_SOURCE_DIR using LLVM_ALL_PROJECTS
110 # This allows an easy way of setting up a build directory for llvm and another
111 # one for llvm+clang+... using the same sources.
112 set(LLVM_ALL_PROJECTS "bolt;clang;clang-tools-extra;compiler-rt;cross-project-tests;libc;libclc;libcxx;libcxxabi;libunwind;lld;lldb;mlir;openmp;polly;pstl")
113 # The flang project is not yet part of "all" projects (see C++ requirements)
114 set(LLVM_EXTRA_PROJECTS "flang")
115 # List of all known projects in the mono repo
116 set(LLVM_KNOWN_PROJECTS "${LLVM_ALL_PROJECTS};${LLVM_EXTRA_PROJECTS}")
117 set(LLVM_ENABLE_PROJECTS "" CACHE STRING
118 "Semicolon-separated list of projects to build (${LLVM_KNOWN_PROJECTS}), or \"all\".")
119 # Make sure expansion happens first to not handle "all" in rest of the checks.
120 if( LLVM_ENABLE_PROJECTS STREQUAL "all" )
121 set( LLVM_ENABLE_PROJECTS ${LLVM_ALL_PROJECTS})
123 foreach(proj ${LLVM_ENABLE_PROJECTS})
124 if (NOT proj STREQUAL "llvm" AND NOT "${proj}" IN_LIST LLVM_KNOWN_PROJECTS)
125 MESSAGE(FATAL_ERROR "${proj} isn't a known project: ${LLVM_KNOWN_PROJECTS}")
128 foreach(proj "libcxx" "libcxxabi" "libunwind")
129 if (${proj} IN_LIST LLVM_ENABLE_PROJECTS)
130 message(WARNING "Using LLVM_ENABLE_PROJECTS=${proj} is deprecated now, please use -DLLVM_ENABLE_RUNTIMES=${proj} or "
131 "see the instructions at https://libcxx.llvm.org/BuildingLibcxx.html for building the runtimes.")
135 if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
136 if (NOT "mlir" IN_LIST LLVM_ENABLE_PROJECTS)
137 message(STATUS "Enabling MLIR as a dependency to flang")
138 list(APPEND LLVM_ENABLE_PROJECTS "mlir")
141 if (NOT "clang" IN_LIST LLVM_ENABLE_PROJECTS)
142 message(FATAL_ERROR "Clang is not enabled, but is required for the Flang driver")
146 # LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the
147 # `LLVM_ENABLE_PROJECTS` CMake cache variable. This exists for
150 # * As an indicator that the `LLVM_ENABLE_PROJECTS` list is now the single
151 # source of truth for which projects to build. This means we will ignore user
152 # supplied `LLVM_TOOL_<project>_BUILD` CMake cache variables and overwrite
155 # * The case where the user previously had `LLVM_ENABLE_PROJECTS` set to a
156 # non-empty list but now the user wishes to disable building all other projects
157 # by setting `LLVM_ENABLE_PROJECTS` to an empty string. In that case we still
158 # need to set the `LLVM_TOOL_${upper_proj}_BUILD` variables so that we disable
159 # building all the projects that were previously enabled.
160 set(LLVM_ENABLE_PROJECTS_USED OFF CACHE BOOL "")
161 mark_as_advanced(LLVM_ENABLE_PROJECTS_USED)
163 if (LLVM_ENABLE_PROJECTS_USED OR NOT LLVM_ENABLE_PROJECTS STREQUAL "")
164 set(LLVM_ENABLE_PROJECTS_USED ON CACHE BOOL "" FORCE)
165 foreach(proj ${LLVM_KNOWN_PROJECTS} ${LLVM_EXTERNAL_PROJECTS})
166 string(TOUPPER "${proj}" upper_proj)
167 string(REGEX REPLACE "-" "_" upper_proj ${upper_proj})
168 if ("${proj}" IN_LIST LLVM_ENABLE_PROJECTS)
169 message(STATUS "${proj} project is enabled")
170 set(SHOULD_ENABLE_PROJECT TRUE)
171 set(PROJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
172 if(NOT EXISTS "${PROJ_DIR}" OR NOT IS_DIRECTORY "${PROJ_DIR}")
173 message(FATAL_ERROR "LLVM_ENABLE_PROJECTS requests ${proj} but directory not found: ${PROJ_DIR}")
175 if( LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR STREQUAL "" )
176 set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}" CACHE PATH "" FORCE)
178 set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}" CACHE PATH "")
180 elseif ("${proj}" IN_LIST LLVM_EXTERNAL_PROJECTS)
181 message(STATUS "${proj} project is enabled")
182 set(SHOULD_ENABLE_PROJECT TRUE)
184 message(STATUS "${proj} project is disabled")
185 set(SHOULD_ENABLE_PROJECT FALSE)
187 # Force `LLVM_TOOL_${upper_proj}_BUILD` variables to have values that
188 # corresponds with `LLVM_ENABLE_PROJECTS`. This prevents the user setting
189 # `LLVM_TOOL_${upper_proj}_BUILD` variables externally. At some point
190 # we should deprecate allowing users to set these variables by turning them
191 # into normal CMake variables rather than cache variables.
192 set(LLVM_TOOL_${upper_proj}_BUILD
193 ${SHOULD_ENABLE_PROJECT}
195 BOOL "Whether to build ${upper_proj} as part of LLVM" FORCE
199 unset(SHOULD_ENABLE_PROJECT)
201 # Build llvm with ccache if the package is present
202 set(LLVM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build")
203 if(LLVM_CCACHE_BUILD)
204 find_program(CCACHE_PROGRAM ccache)
206 set(LLVM_CCACHE_MAXSIZE "" CACHE STRING "Size of ccache")
207 set(LLVM_CCACHE_DIR "" CACHE STRING "Directory to keep ccached data")
208 set(LLVM_CCACHE_PARAMS "CCACHE_CPP2=yes CCACHE_HASHDIR=yes"
209 CACHE STRING "Parameters to pass through to ccache")
211 if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
212 set(CCACHE_PROGRAM "${LLVM_CCACHE_PARAMS} ${CCACHE_PROGRAM}")
213 if (LLVM_CCACHE_MAXSIZE)
214 set(CCACHE_PROGRAM "CCACHE_MAXSIZE=${LLVM_CCACHE_MAXSIZE} ${CCACHE_PROGRAM}")
217 set(CCACHE_PROGRAM "CCACHE_DIR=${LLVM_CCACHE_DIR} ${CCACHE_PROGRAM}")
219 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM})
221 if(LLVM_CCACHE_MAXSIZE OR LLVM_CCACHE_DIR OR
222 NOT LLVM_CCACHE_PARAMS MATCHES "CCACHE_CPP2=yes CCACHE_HASHDIR=yes")
223 message(FATAL_ERROR "Ccache configuration through CMake is not supported on Windows. Please use environment variables.")
225 # RULE_LAUNCH_COMPILE should work with Ninja but currently has issues
226 # with cmd.exe and some MSVC tools other than cl.exe
227 set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
228 set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
231 message(FATAL_ERROR "Unable to find the program ccache. Set LLVM_CCACHE_BUILD to OFF")
235 set(LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS "" CACHE STRING
236 "Optional arguments for the native tool used in CMake --build invocations for external projects.")
237 mark_as_advanced(LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS)
239 option(LLVM_DEPENDENCY_DEBUGGING "Dependency debugging mode to verify correctly expressed library dependencies (Darwin only)" OFF)
241 # Some features of the LLVM build may be disallowed when dependency debugging is
242 # enabled. In particular you cannot use ccache because we want to force compile
243 # operations to always happen.
244 if(LLVM_DEPENDENCY_DEBUGGING)
245 if(NOT CMAKE_HOST_APPLE)
246 message(FATAL_ERROR "Dependency debugging is only currently supported on Darwin hosts.")
248 if(LLVM_CCACHE_BUILD)
249 message(FATAL_ERROR "Cannot enable dependency debugging while using ccache.")
253 option(LLVM_ENABLE_DAGISEL_COV "Debug: Prints tablegen patterns that were used for selecting" OFF)
254 option(LLVM_ENABLE_GISEL_COV "Enable collection of GlobalISel rule coverage" OFF)
255 if(LLVM_ENABLE_GISEL_COV)
256 set(LLVM_GISEL_COV_PREFIX "${CMAKE_BINARY_DIR}/gisel-coverage-" CACHE STRING "Provide a filename prefix to collect the GlobalISel rule coverage")
259 set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
261 # Add path for custom modules
262 list(INSERT CMAKE_MODULE_PATH 0
263 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
264 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
265 "${LLVM_COMMON_CMAKE_UTILS}/Modules"
268 # Generate a CompilationDatabase (compile_commands.json file) for our build,
269 # for use by clang_complete, YouCompleteMe, etc.
270 set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
272 option(LLVM_INSTALL_BINUTILS_SYMLINKS
273 "Install symlinks from the binutils tool names to the corresponding LLVM tools." OFF)
275 option(LLVM_INSTALL_CCTOOLS_SYMLINKS
276 "Install symlinks from the cctools tool names to the corresponding LLVM tools." OFF)
278 option(LLVM_INSTALL_UTILS "Include utility binaries in the 'install' target." OFF)
280 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
282 # Unfortunatly Clang is too eager to search directories for module maps, which can cause the
283 # installed version of the maps to be found when building LLVM from source. Therefore we turn off
284 # the installation by default. See llvm.org/PR31905.
285 option(LLVM_INSTALL_MODULEMAPS "Install the modulemap files in the 'install' target." OFF)
287 option(LLVM_USE_FOLDERS "Enable solution folders in Visual Studio. Disable for Express versions." ON)
288 if ( LLVM_USE_FOLDERS )
289 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
292 include(VersionFromVCS)
294 option(LLVM_APPEND_VC_REV
295 "Embed the version control system revision in LLVM" ON)
297 option(LLVM_TOOL_LLVM_DRIVER_BUILD "Enables building the llvm multicall tool" OFF)
299 set(PACKAGE_NAME LLVM)
300 set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
301 set(PACKAGE_BUGREPORT "https://github.com/llvm/llvm-project/issues/")
303 set(BUG_REPORT_URL "${PACKAGE_BUGREPORT}" CACHE STRING
304 "Default URL where bug reports are to be submitted.")
307 set(CPACK_PACKAGE_INSTALL_DIRECTORY "LLVM")
308 set(CPACK_PACKAGE_VENDOR "LLVM")
309 set(CPACK_PACKAGE_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
310 set(CPACK_PACKAGE_VERSION_MINOR ${LLVM_VERSION_MINOR})
311 set(CPACK_PACKAGE_VERSION_PATCH ${LLVM_VERSION_PATCH})
312 set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
313 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT")
314 set(CPACK_NSIS_COMPRESSOR "/SOLID lzma \r\n SetCompressorDictSize 32")
315 if(WIN32 AND NOT UNIX)
316 set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "LLVM")
317 set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_logo.bmp")
318 set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico")
319 set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico")
320 set(CPACK_NSIS_MODIFY_PATH "ON")
321 set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
323 set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
328 # Sanity check our source directory to make sure that we are not trying to
329 # generate an in-source build (unless on MSVC_IDE, where it is ok), and to make
330 # sure that we don't have any stray generated files lying around in the tree
331 # (which would end up getting picked up by header search, instead of the correct
333 if( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE )
334 message(FATAL_ERROR "In-source builds are not allowed.
335 Please create a directory and run cmake from there, passing the path
336 to this source directory as the last argument.
337 This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
338 Please delete them.")
341 string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
343 if (CMAKE_BUILD_TYPE AND
344 NOT uppercase_CMAKE_BUILD_TYPE MATCHES "^(DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL)$")
345 message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
348 # LLVM_INSTALL_PACKAGE_DIR needs to be declared prior to adding the tools
349 # subdirectory in order to have the value available for llvm-config.
350 include(GNUInstallPackageDir)
351 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
352 "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
354 set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
355 "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
356 mark_as_advanced(LLVM_TOOLS_INSTALL_DIR)
358 set(LLVM_UTILS_INSTALL_DIR "${LLVM_TOOLS_INSTALL_DIR}" CACHE STRING
359 "Path to install LLVM utilities (enabled by LLVM_INSTALL_UTILS=ON) (defaults to LLVM_TOOLS_INSTALL_DIR)")
360 mark_as_advanced(LLVM_UTILS_INSTALL_DIR)
362 set(LLVM_EXAMPLES_INSTALL_DIR "examples" CACHE STRING
363 "Path for examples subdirectory (enabled by LLVM_BUILD_EXAMPLES=ON) (defaults to 'examples')")
364 mark_as_advanced(LLVM_EXAMPLES_INSTALL_DIR)
366 # They are used as destination of target generators.
367 set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
368 set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
370 # DLL platform -- put DLLs into bin.
371 set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
373 set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
376 # Each of them corresponds to llvm-config's.
377 set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir
378 set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) # --libdir
379 set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root
380 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir
381 set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) # --prefix
383 set(LLVM_THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../third-party)
385 # Note: LLVM_CMAKE_DIR does not include generated files
386 set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
387 set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
388 set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
390 # List of all targets to be built by default:
412 # List of targets with JIT support:
413 set(LLVM_TARGETS_WITH_JIT X86 PowerPC AArch64 ARM Mips SystemZ)
415 set(LLVM_TARGETS_TO_BUILD "all"
416 CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
418 set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ""
419 CACHE STRING "Semicolon-separated list of experimental targets to build.")
421 option(BUILD_SHARED_LIBS
422 "Build all libraries as shared libraries instead of static" OFF)
424 option(LLVM_ENABLE_BACKTRACES "Enable embedding backtraces on crash." ON)
425 if(LLVM_ENABLE_BACKTRACES)
426 set(ENABLE_BACKTRACES 1)
429 option(LLVM_ENABLE_UNWIND_TABLES "Emit unwind tables for the libraries" ON)
431 option(LLVM_ENABLE_CRASH_OVERRIDES "Enable crash overrides." ON)
432 if(LLVM_ENABLE_CRASH_OVERRIDES)
433 set(ENABLE_CRASH_OVERRIDES 1)
436 option(LLVM_ENABLE_CRASH_DUMPS "Turn on memory dumps on crashes. Currently only implemented on Windows." OFF)
438 set(WINDOWS_PREFER_FORWARD_SLASH_DEFAULT OFF)
440 # Cygwin doesn't identify itself as Windows, and thus gets path::Style::posix
441 # as native path style, regardless of what this is set to.
442 set(WINDOWS_PREFER_FORWARD_SLASH_DEFAULT ON)
444 option(LLVM_WINDOWS_PREFER_FORWARD_SLASH "Prefer path names with forward slashes on Windows." ${WINDOWS_PREFER_FORWARD_SLASH_DEFAULT})
446 option(LLVM_ENABLE_FFI "Use libffi to call external functions from the interpreter" OFF)
447 set(FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so")
448 set(FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for ffi.h or ffi/ffi.h")
450 set(LLVM_TARGET_ARCH "host"
451 CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.")
453 option(LLVM_ENABLE_TERMINFO "Use terminfo database if available." ON)
455 set(LLVM_ENABLE_LIBXML2 "ON" CACHE STRING "Use libxml2 if available. Can be ON, OFF, or FORCE_ON")
457 option(LLVM_ENABLE_LIBEDIT "Use libedit if available." ON)
459 option(LLVM_ENABLE_LIBPFM "Use libpfm for performance counters if available." ON)
461 # On z/OS, threads cannot be used because TLS is not supported.
462 if (CMAKE_SYSTEM_NAME MATCHES "OS390")
463 option(LLVM_ENABLE_THREADS "Use threads if available." OFF)
465 option(LLVM_ENABLE_THREADS "Use threads if available." ON)
468 set(LLVM_ENABLE_ZLIB "ON" CACHE STRING "Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON")
470 set(LLVM_ENABLE_ZSTD "ON" CACHE STRING "Use zstd for compression/decompression if available. Can be ON, OFF, or FORCE_ON")
472 set(LLVM_ENABLE_CURL "OFF" CACHE STRING "Use libcurl for the HTTP client if available. Can be ON, OFF, or FORCE_ON")
474 set(LLVM_ENABLE_HTTPLIB "OFF" CACHE STRING "Use cpp-httplib HTTP server library if available. Can be ON, OFF, or FORCE_ON")
476 set(LLVM_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.")
478 option(LLVM_ENABLE_Z3_SOLVER
479 "Enable Support for the Z3 constraint solver in LLVM."
480 ${LLVM_ENABLE_Z3_SOLVER_DEFAULT}
483 if (LLVM_ENABLE_Z3_SOLVER)
484 find_package(Z3 4.7.1)
486 if (LLVM_Z3_INSTALL_DIR)
488 message(FATAL_ERROR "Z3 >= 4.7.1 has not been found in LLVM_Z3_INSTALL_DIR: ${LLVM_Z3_INSTALL_DIR}.")
493 message(FATAL_ERROR "LLVM_ENABLE_Z3_SOLVER cannot be enabled when Z3 is not available.")
499 set(LLVM_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}")
502 if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
503 set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
506 set(LLVM_TARGETS_TO_BUILD
507 ${LLVM_TARGETS_TO_BUILD}
508 ${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD})
509 list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)
511 option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
512 option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF)
513 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
514 option(LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." ON)
516 option(LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." OFF)
518 option(LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." ON)
519 option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
520 option(LLVM_STATIC_LINK_CXX_STDLIB "Statically link the standard library." OFF)
521 option(LLVM_ENABLE_LLD "Use lld as C and C++ linker." OFF)
522 option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
523 option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
525 option(LLVM_ENABLE_DUMP "Enable dump functions even when assertions are disabled" OFF)
526 option(LLVM_UNREACHABLE_OPTIMIZE "Optimize llvm_unreachable() as undefined behavior (default), guaranteed trap when OFF" ON)
528 if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
529 option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF)
531 option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
534 option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF)
536 # While adding scalable vector support to LLVM, we temporarily want to
537 # allow an implicit conversion of TypeSize to uint64_t, and to allow
538 # code to get the fixed number of elements from a possibly scalable vector.
539 # This CMake flag enables a more strict mode where it asserts that the type
540 # is not a scalable vector type.
542 # Enabling this flag makes it easier to find cases where the compiler makes
543 # assumptions on the size being 'fixed size', when building tests for
544 # SVE/SVE2 or other scalable vector architectures.
545 option(LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS
546 "Enable assertions that type is not scalable in implicit conversion from TypeSize to uint64_t and calls to getNumElements" OFF)
548 set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING
549 "Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF.")
551 option(LLVM_FORCE_USE_OLD_TOOLCHAIN
552 "Set to ON to force using an old, unsupported host toolchain." OFF)
554 set(LLVM_LOCAL_RPATH "" CACHE FILEPATH
555 "If set, an absolute path added as rpath on binaries that do not already contain an executable-relative rpath.")
557 option(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN
558 "Set to ON to only warn when using a toolchain which is about to be deprecated, instead of emitting an error." OFF)
560 option(LLVM_USE_INTEL_JITEVENTS
561 "Use Intel JIT API to inform Intel(R) VTune(TM) Amplifier XE 2011 about JIT code"
564 if( LLVM_USE_INTEL_JITEVENTS )
565 # Verify we are on a supported platform
566 if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
568 "Intel JIT API support is available on Linux and Windows only.")
570 endif( LLVM_USE_INTEL_JITEVENTS )
572 option(LLVM_USE_OPROFILE
573 "Use opagent JIT interface to inform OProfile about JIT code" OFF)
575 option(LLVM_EXTERNALIZE_DEBUGINFO
576 "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
578 set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING
579 "Sign executables and dylibs with the given identity or skip if empty (Darwin Only)")
581 # If enabled, verify we are on a platform that supports oprofile.
582 if( LLVM_USE_OPROFILE )
583 if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
584 message(FATAL_ERROR "OProfile support is available on Linux only.")
585 endif( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
586 endif( LLVM_USE_OPROFILE )
589 "Use perf JIT interface to inform perf about JIT code" OFF)
591 # If enabled, verify we are on a platform that supports perf.
593 if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
594 message(FATAL_ERROR "perf support is available on Linux only.")
595 endif( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
596 endif( LLVM_USE_PERF )
598 set(LLVM_USE_SANITIZER "" CACHE STRING
599 "Define the sanitizer used to build binaries and tests.")
600 option(LLVM_OPTIMIZE_SANITIZED_BUILDS "Pass -O1 on debug sanitizer builds" ON)
602 "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
604 "Compile flags set to enable UBSan. Only used if LLVM_USE_SANITIZER contains 'Undefined'.")
605 set(LLVM_LIB_FUZZING_ENGINE "" CACHE PATH
606 "Path to fuzzing library for linking with fuzz targets")
608 option(LLVM_USE_SPLIT_DWARF
609 "Use -gsplit-dwarf when compiling llvm and --gdb-index when linking." OFF)
611 # Define an option controlling whether we should build for 32-bit on 64-bit
612 # platforms, where supported.
613 if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT (WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
614 # TODO: support other platforms and toolchains.
615 option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
618 # Define the default arguments to use with 'lit', and an option for the user to
620 set(LIT_ARGS_DEFAULT "-sv")
621 if (MSVC_IDE OR XCODE)
622 set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
624 set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
626 # On Win32 hosts, provide an option to specify the path to the GnuWin32 tools.
627 if( WIN32 AND NOT CYGWIN )
628 set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")
631 set(LLVM_INTEGRATED_CRT_ALLOC "" CACHE PATH "Replace the Windows CRT allocator with any of {rpmalloc|mimalloc|snmalloc}. Only works with /MT enabled.")
632 if(LLVM_INTEGRATED_CRT_ALLOC)
634 message(FATAL_ERROR "LLVM_INTEGRATED_CRT_ALLOC is only supported on Windows.")
636 if(LLVM_USE_SANITIZER)
637 message(FATAL_ERROR "LLVM_INTEGRATED_CRT_ALLOC cannot be used along with LLVM_USE_SANITIZER!")
639 if(CMAKE_BUILD_TYPE AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
640 message(FATAL_ERROR "The Debug target isn't supported along with LLVM_INTEGRATED_CRT_ALLOC!")
644 # Define options to control the inclusion and default build behavior for
645 # components which may not strictly be necessary (tools, examples, and tests).
647 # This is primarily to support building smaller or faster project files.
648 option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON)
649 option(LLVM_BUILD_TOOLS
650 "Build the LLVM tools. If OFF, just generate build targets." ON)
652 option(LLVM_INCLUDE_UTILS "Generate build targets for the LLVM utils." ON)
653 option(LLVM_BUILD_UTILS
654 "Build LLVM utility binaries. If OFF, just generate build targets." ON)
656 option(LLVM_INCLUDE_RUNTIMES "Generate build targets for the LLVM runtimes." ON)
657 option(LLVM_BUILD_RUNTIMES
658 "Build the LLVM runtimes. If OFF, just generate build targets." ON)
660 option(LLVM_BUILD_RUNTIME
661 "Build the LLVM runtime libraries." ON)
662 option(LLVM_BUILD_EXAMPLES
663 "Build the LLVM example programs. If OFF, just generate build targets." OFF)
664 option(LLVM_INCLUDE_EXAMPLES "Generate build targets for the LLVM examples" ON)
666 if(LLVM_BUILD_EXAMPLES)
667 add_definitions(-DBUILD_EXAMPLES)
668 endif(LLVM_BUILD_EXAMPLES)
670 option(LLVM_BUILD_TESTS
671 "Build LLVM unit tests. If OFF, just generate build targets." OFF)
672 option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON)
673 option(LLVM_INCLUDE_GO_TESTS "Include the Go bindings tests in test build targets." OFF)
675 option(LLVM_BUILD_BENCHMARKS "Add LLVM benchmark targets to the list of default
676 targets. If OFF, benchmarks still could be built using Benchmarks target." OFF)
677 option(LLVM_INCLUDE_BENCHMARKS "Generate benchmark targets. If OFF, benchmarks can't be built." ON)
679 option (LLVM_BUILD_DOCS "Build the llvm documentation." OFF)
680 option (LLVM_INCLUDE_DOCS "Generate build targets for llvm documentation." ON)
681 option (LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm API documentation." OFF)
682 option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
683 option (LLVM_ENABLE_OCAMLDOC "Build OCaml bindings documentation." ON)
684 option (LLVM_ENABLE_BINDINGS "Build bindings." ON)
686 set(LLVM_INSTALL_DOXYGEN_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/llvm/doxygen-html"
687 CACHE STRING "Doxygen-generated HTML documentation install directory")
688 set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/llvm/ocaml-html"
689 CACHE STRING "OCamldoc-generated HTML documentation install directory")
691 option (LLVM_BUILD_EXTERNAL_COMPILER_RT
692 "Build compiler-rt as an external project." OFF)
694 option (LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO
695 "Show target and host info when tools are invoked with --version." ON)
697 # You can configure which libraries from LLVM you want to include in the
698 # shared library by setting LLVM_DYLIB_COMPONENTS to a semi-colon delimited
699 # list of LLVM components. All component names handled by llvm-config are valid.
700 if(NOT DEFINED LLVM_DYLIB_COMPONENTS)
701 set(LLVM_DYLIB_COMPONENTS "all" CACHE STRING
702 "Semicolon-separated list of components to include in libLLVM, or \"all\".")
706 option(LLVM_BUILD_LLVM_C_DYLIB "Build LLVM-C.dll (Windows only)" ON)
707 # Set this variable to OFF here so it can't be set with a command-line
709 set (LLVM_LINK_LLVM_DYLIB OFF)
710 if (BUILD_SHARED_LIBS)
711 message(FATAL_ERROR "BUILD_SHARED_LIBS options is not supported on Windows.")
714 option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF)
715 option(LLVM_BUILD_LLVM_C_DYLIB "Build libllvm-c re-export library (Darwin only)" OFF)
716 set(LLVM_BUILD_LLVM_DYLIB_default OFF)
717 if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB)
718 set(LLVM_BUILD_LLVM_DYLIB_default ON)
720 option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default})
723 if (LLVM_LINK_LLVM_DYLIB AND BUILD_SHARED_LIBS)
724 message(FATAL_ERROR "Cannot enable BUILD_SHARED_LIBS with LLVM_LINK_LLVM_DYLIB. We recommend disabling BUILD_SHARED_LIBS.")
727 option(LLVM_OPTIMIZED_TABLEGEN "Force TableGen to be built with optimization" OFF)
728 if(CMAKE_CROSSCOMPILING OR (LLVM_OPTIMIZED_TABLEGEN AND (LLVM_ENABLE_ASSERTIONS OR CMAKE_CONFIGURATION_TYPES)))
729 set(LLVM_USE_HOST_TOOLS ON)
732 option(LLVM_OMIT_DAGISEL_COMMENTS "Do not add comments to DAG ISel" ON)
733 if (CMAKE_BUILD_TYPE AND uppercase_CMAKE_BUILD_TYPE MATCHES "^(RELWITHDEBINFO|DEBUG)$")
734 set(LLVM_OMIT_DAGISEL_COMMENTS OFF)
738 option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE)
741 if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE OR
743 if(NOT LLVM_PROFILE_MERGE_POOL_SIZE)
744 # A pool size of 1-2 is probably sufficient on a SSD. 3-4 should be fine
745 # for spining disks. Anything higher may only help on slower mediums.
746 set(LLVM_PROFILE_MERGE_POOL_SIZE "4")
748 if(NOT LLVM_PROFILE_FILE_PATTERN)
749 if(NOT LLVM_PROFILE_DATA_DIR)
750 file(TO_NATIVE_PATH "${LLVM_BINARY_DIR}/profiles" LLVM_PROFILE_DATA_DIR)
752 file(TO_NATIVE_PATH "${LLVM_PROFILE_DATA_DIR}/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_PROFILE_FILE_PATTERN)
754 if(NOT LLVM_CSPROFILE_FILE_PATTERN)
755 if(NOT LLVM_CSPROFILE_DATA_DIR)
756 file(TO_NATIVE_PATH "${LLVM_BINARY_DIR}/csprofiles" LLVM_CSPROFILE_DATA_DIR)
758 file(TO_NATIVE_PATH "${LLVM_CSPROFILE_DATA_DIR}/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_CSPROFILE_FILE_PATTERN)
762 if (LLVM_BUILD_STATIC)
763 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
764 # Remove shared library suffixes from use in find_library
765 foreach (shared_lib_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_IMPORT_LIBRARY_SUFFIX})
766 list(FIND CMAKE_FIND_LIBRARY_SUFFIXES ${shared_lib_suffix} shared_lib_suffix_idx)
767 if(NOT ${shared_lib_suffix_idx} EQUAL -1)
768 list(REMOVE_AT CMAKE_FIND_LIBRARY_SUFFIXES ${shared_lib_suffix_idx})
773 # Use libtool instead of ar if you are both on an Apple host, and targeting Apple.
774 if(CMAKE_HOST_APPLE AND APPLE)
778 # Override the default target with an environment variable named by LLVM_TARGET_TRIPLE_ENV.
779 set(LLVM_TARGET_TRIPLE_ENV CACHE STRING "The name of environment variable to override default target. Disabled by blank.")
780 mark_as_advanced(LLVM_TARGET_TRIPLE_ENV)
782 # Per target dir not yet supported on Arm 32 bit due to arm vs armhf handling
783 if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
784 set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON)
786 set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF)
788 set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default} CACHE BOOL
789 "Enable per-target runtimes directory")
791 set(LLVM_PROFDATA_FILE "" CACHE FILEPATH
792 "Profiling data file to use when compiling in order to improve runtime performance.")
794 if(LLVM_INCLUDE_TESTS)
795 # Lit test suite requires at least python 3.6
796 set(LLVM_MINIMUM_PYTHON_VERSION 3.6)
798 # FIXME: it is unknown if this is the actual minimum bound
799 set(LLVM_MINIMUM_PYTHON_VERSION 3.0)
802 # Find python before including config-ix, since it needs to be able to search
803 # for python modules.
804 find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
805 COMPONENTS Interpreter)
807 # All options referred to from HandleLLVMOptions have to be specified
808 # BEFORE this include, otherwise options will not be correctly set on
812 # By default, we target the host, but this can be overridden at CMake
813 # invocation time. Except on 64-bit AIX, where the system toolchain
814 # expect 32-bit objects by default.
815 if("${LLVM_HOST_TRIPLE}" MATCHES "^powerpc64-ibm-aix")
816 string(REGEX REPLACE "^powerpc64" "powerpc" LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}")
818 set(LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}")
821 set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE_default}" CACHE STRING
822 "Default target for which LLVM will generate code." )
824 message(WARNING "TARGET_TRIPLE is deprecated and will be removed in a future release. "
825 "Please use LLVM_DEFAULT_TARGET_TRIPLE instead.")
826 set(LLVM_TARGET_TRIPLE "${TARGET_TRIPLE}")
828 set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
830 message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")
831 message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}")
834 if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB)
835 set(LLVM_ENABLE_PLUGINS_default ON)
837 set(LLVM_ENABLE_PLUGINS_default OFF)
840 set(LLVM_ENABLE_PLUGINS_default ${LLVM_ENABLE_PIC})
842 option(LLVM_ENABLE_PLUGINS "Enable plugin support" ${LLVM_ENABLE_PLUGINS_default})
844 set(LLVM_ENABLE_NEW_PASS_MANAGER TRUE CACHE BOOL
845 "Enable the new pass manager by default.")
846 if(NOT LLVM_ENABLE_NEW_PASS_MANAGER)
847 message(FATAL_ERROR "Enabling the legacy pass manager on the cmake level is"
848 " no longer supported.")
851 include(HandleLLVMOptions)
855 # Configure all of the various header file fragments LLVM uses which depend on
856 # configuration variables.
857 set(LLVM_ENUM_TARGETS "")
858 set(LLVM_ENUM_ASM_PRINTERS "")
859 set(LLVM_ENUM_ASM_PARSERS "")
860 set(LLVM_ENUM_DISASSEMBLERS "")
861 set(LLVM_ENUM_TARGETMCAS "")
862 foreach(t ${LLVM_TARGETS_TO_BUILD})
863 set( td ${LLVM_MAIN_SRC_DIR}/lib/Target/${t} )
865 list(FIND LLVM_ALL_TARGETS ${t} idx)
866 list(FIND LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ${t} idy)
867 # At this point, LLVMBUILDTOOL already checked all the targets passed in
868 # LLVM_TARGETS_TO_BUILD and LLVM_EXPERIMENTAL_TARGETS_TO_BUILD, so
869 # this test just makes sure that any experimental targets were passed via
870 # LLVM_EXPERIMENTAL_TARGETS_TO_BUILD, not LLVM_TARGETS_TO_BUILD.
871 if( idx LESS 0 AND idy LESS 0 )
872 message(FATAL_ERROR "The target `${t}' is experimental and must be passed "
873 "via LLVM_EXPERIMENTAL_TARGETS_TO_BUILD.")
875 set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${t})\n")
878 file(GLOB asmp_file "${td}/*AsmPrinter.cpp")
880 set(LLVM_ENUM_ASM_PRINTERS
881 "${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n")
883 if( EXISTS ${td}/AsmParser/CMakeLists.txt )
884 set(LLVM_ENUM_ASM_PARSERS
885 "${LLVM_ENUM_ASM_PARSERS}LLVM_ASM_PARSER(${t})\n")
887 if( EXISTS ${td}/Disassembler/CMakeLists.txt )
888 set(LLVM_ENUM_DISASSEMBLERS
889 "${LLVM_ENUM_DISASSEMBLERS}LLVM_DISASSEMBLER(${t})\n")
891 if( EXISTS ${td}/MCA/CMakeLists.txt )
892 set(LLVM_ENUM_TARGETMCAS
893 "${LLVM_ENUM_TARGETMCAS}LLVM_TARGETMCA(${t})\n")
897 # Provide an LLVM_ namespaced alias for use in #cmakedefine.
898 set(LLVM_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
900 # Produce the target definition files, which provide a way for clients to easily
901 # include various classes of targets.
903 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmPrinters.def.in
904 ${LLVM_INCLUDE_DIR}/llvm/Config/AsmPrinters.def
907 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmParsers.def.in
908 ${LLVM_INCLUDE_DIR}/llvm/Config/AsmParsers.def
911 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Disassemblers.def.in
912 ${LLVM_INCLUDE_DIR}/llvm/Config/Disassemblers.def
915 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.def.in
916 ${LLVM_INCLUDE_DIR}/llvm/Config/Targets.def
919 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/TargetMCAs.def.in
920 ${LLVM_INCLUDE_DIR}/llvm/Config/TargetMCAs.def
923 # They are not referenced. See set_output_directory().
924 set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/bin )
925 set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
926 set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
928 if(LLVM_INCLUDE_TESTS)
929 include(GetErrcMessages)
930 get_errc_messages(LLVM_LIT_ERRC_MESSAGES)
933 # For up-to-date instructions for installing the Tensorflow dependency, refer to
934 # the bot setup script: https://github.com/google/ml-compiler-opt/blob/main/buildbot/buildbot_init.sh
935 # In this case, the latest C API library is available for download from
936 # https://www.tensorflow.org/install/lang_c.
937 # We will expose the conditional compilation variable,
938 # LLVM_HAVE_TF_API, through llvm-config.h, so that a user of the LLVM library may
939 # also leverage the dependency.
940 set(TENSORFLOW_C_LIB_PATH "" CACHE PATH "Path to TensorFlow C library install")
941 if (TENSORFLOW_C_LIB_PATH)
942 find_library(tensorflow_c_api tensorflow PATHS ${TENSORFLOW_C_LIB_PATH}/lib NO_DEFAULT_PATH REQUIRED)
943 # Currently, the protobuf headers are distributed with the pip package that corresponds to the version
944 # of the C API library.
945 find_library(tensorflow_fx tensorflow_framework PATHS ${TENSORFLOW_C_LIB_PATH}/lib NO_DEFAULT_PATH REQUIRED)
946 set(LLVM_HAVE_TF_API "ON" CACHE BOOL "Full Tensorflow API available")
947 include_directories(${TENSORFLOW_C_LIB_PATH}/include)
948 if (NOT TF_PROTO_HEADERS)
949 message(STATUS "TF_PROTO_HEADERS not defined. Looking for tensorflow pip package.")
950 execute_process(COMMAND
951 ${Python3_EXECUTABLE} "-m" "pip" "show" "tensorflow"
952 OUTPUT_VARIABLE TF_PIP_OUT)
953 if ("${TF_PIP_OUT}" STREQUAL "")
954 message(FATAL ERROR "Tensorflow pip package is also required for 'development' mode (protobuf headers)")
956 string(REGEX MATCH "Location: ([^\n]*\n)" TF_PIP_LOC "${TF_PIP_OUT}")
957 string(REPLACE "Location: " "" TF_PIP ${TF_PIP_LOC})
958 string(STRIP ${TF_PIP} TF_PIP)
959 set(TF_PROTO_HEADERS "${TF_PIP}/tensorflow/include")
961 message(STATUS "Using Tensorflow headers under: ${TF_PROTO_HEADERS}")
962 include_directories(${TF_PROTO_HEADERS})
963 add_definitions("-DGOOGLE_PROTOBUF_NO_RTTI")
964 add_definitions("-D_GLIBCXX_USE_CXX11_ABI=0")
967 # For up-to-date instructions for installing the Tensorflow dependency, refer to
968 # the bot setup script: https://github.com/google/ml-compiler-opt/blob/main/buildbot/buildbot_init.sh
969 # Specifically, assuming python3 is installed:
970 # python3 -m pip install --upgrade pip && python3 -m pip install --user tf_nightly==2.3.0.dev20200528
971 # Then set TENSORFLOW_AOT_PATH to the package install - usually it's ~/.local/lib/python3.7/site-packages/tensorflow
973 set(TENSORFLOW_AOT_PATH "" CACHE PATH "Path to TensorFlow pip install dir")
975 if (NOT TENSORFLOW_AOT_PATH STREQUAL "")
976 set(LLVM_HAVE_TF_AOT "ON" CACHE BOOL "Tensorflow AOT available")
977 set(TENSORFLOW_AOT_COMPILER
978 "${TENSORFLOW_AOT_PATH}/../../../../bin/saved_model_cli"
979 CACHE PATH "Path to the Tensorflow AOT compiler")
980 include_directories(${TENSORFLOW_AOT_PATH}/include)
981 add_subdirectory(${TENSORFLOW_AOT_PATH}/xla_aot_runtime_src
982 ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/tf_runtime)
983 install(TARGETS tf_xla_runtime EXPORT LLVMExports
984 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT tf_xla_runtime)
985 set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS tf_xla_runtime)
986 # Once we add more modules, we should handle this more automatically.
987 if (DEFINED LLVM_OVERRIDE_MODEL_HEADER_INLINERSIZEMODEL)
988 set(LLVM_INLINER_MODEL_PATH "none")
989 elseif(NOT DEFINED LLVM_INLINER_MODEL_PATH
990 OR "${LLVM_INLINER_MODEL_PATH}" STREQUAL ""
991 OR "${LLVM_INLINER_MODEL_PATH}" STREQUAL "autogenerate")
992 set(LLVM_INLINER_MODEL_PATH "autogenerate")
993 set(LLVM_INLINER_MODEL_AUTOGENERATED 1)
995 if (DEFINED LLVM_OVERRIDE_MODEL_HEADER_REGALLOCEVICTMODEL)
996 set(LLVM_RAEVICT_MODEL_PATH "none")
997 elseif(NOT DEFINED LLVM_RAEVICT_MODEL_PATH
998 OR "${LLVM_RAEVICT_MODEL_PATH}" STREQUAL ""
999 OR "${LLVM_RAEVICT_MODEL_PATH}" STREQUAL "autogenerate")
1000 set(LLVM_RAEVICT_MODEL_PATH "autogenerate")
1001 set(LLVM_RAEVICT_MODEL_AUTOGENERATED 1)
1006 # Configure the three LLVM configuration header files.
1008 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/config.h.cmake
1009 ${LLVM_INCLUDE_DIR}/llvm/Config/config.h)
1011 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/llvm-config.h.cmake
1012 ${LLVM_INCLUDE_DIR}/llvm/Config/llvm-config.h)
1014 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/abi-breaking.h.cmake
1015 ${LLVM_INCLUDE_DIR}/llvm/Config/abi-breaking.h)
1017 # Add target for generating source rpm package.
1018 set(LLVM_SRPM_USER_BINARY_SPECFILE ${CMAKE_CURRENT_SOURCE_DIR}/llvm.spec.in
1019 CACHE FILEPATH ".spec file to use for srpm generation")
1020 set(LLVM_SRPM_BINARY_SPECFILE ${CMAKE_CURRENT_BINARY_DIR}/llvm.spec)
1021 set(LLVM_SRPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/srpm")
1023 get_source_info(${CMAKE_CURRENT_SOURCE_DIR} revision repository)
1024 string(LENGTH "${revision}" revision_length)
1025 set(LLVM_RPM_SPEC_REVISION "${revision}")
1028 ${LLVM_SRPM_USER_BINARY_SPECFILE}
1029 ${LLVM_SRPM_BINARY_SPECFILE} @ONLY)
1031 add_custom_target(srpm
1032 COMMAND cpack -G TGZ --config CPackSourceConfig.cmake -B ${LLVM_SRPM_DIR}/SOURCES
1033 COMMAND rpmbuild -bs --define '_topdir ${LLVM_SRPM_DIR}' ${LLVM_SRPM_BINARY_SPECFILE})
1034 set_target_properties(srpm PROPERTIES FOLDER "Misc")
1036 if(APPLE AND DARWIN_LTO_LIBRARY)
1037 set(CMAKE_EXE_LINKER_FLAGS
1038 "${CMAKE_EXE_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}")
1039 set(CMAKE_SHARED_LINKER_FLAGS
1040 "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}")
1041 set(CMAKE_MODULE_LINKER_FLAGS
1042 "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}")
1045 # Build with _XOPEN_SOURCE on AIX, as stray macros in _ALL_SOURCE mode tend to
1046 # break things. In this case we need to enable the large-file API as well.
1047 if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
1048 add_definitions("-D_XOPEN_SOURCE=700")
1049 add_definitions("-D_LARGE_FILE_API")
1051 # CMake versions less than 3.16 set default linker flags to include -brtl, as
1052 # well as setting -G when building libraries, so clear them out. Note we only
1053 # try to clear the form that CMake will set as part of its initial
1054 # configuration, it is still possible the user may force it as part of a
1056 if(CMAKE_VERSION VERSION_LESS 3.16)
1057 string(REGEX REPLACE "(^|[ \t]+)-Wl,-brtl([ \t]+|$)" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
1058 string(REGEX REPLACE "(^|[ \t]+)-Wl,-brtl([ \t]+|$)" " " CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
1059 string(REGEX REPLACE "(^|[ \t]+)-Wl,-brtl([ \t]+|$)" " " CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
1060 string(REGEX REPLACE "(^|[ \t]+)(-Wl,)?-G([ \t]+|$)" " " CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS
1061 "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}")
1062 string(REGEX REPLACE "(^|[ \t]+)(-Wl,)?-G([ \t]+|$)" " " CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS
1063 "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}")
1064 string(REGEX REPLACE "(^|[ \t]+)(-Wl,)?-G([ \t]+|$)" " " CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS
1065 "${CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS}")
1066 string(REGEX REPLACE "(^|[ \t]+)-Wl,-G," " -Wl," CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS
1067 "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}")
1068 string(REGEX REPLACE "(^|[ \t]+)-Wl,-G," " -Wl," CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS
1069 "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}")
1070 string(REGEX REPLACE "(^|[ \t]+)-Wl,-G," " -Wl," CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS
1071 "${CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS}")
1074 # Modules should be built with -shared -Wl,-G, so we can use runtime linking
1076 string(APPEND CMAKE_MODULE_LINKER_FLAGS " -shared -Wl,-G")
1078 # Also set the correct flags for building shared libraries.
1079 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -shared")
1082 # Build with _XOPEN_SOURCE on z/OS.
1083 if (CMAKE_SYSTEM_NAME MATCHES "OS390")
1084 add_definitions("-D_XOPEN_SOURCE=600")
1085 add_definitions("-D_OPEN_SYS") # Needed for process information.
1086 add_definitions("-D_OPEN_SYS_FILE_EXT") # Needed for EBCDIC I/O.
1089 # Build with _FILE_OFFSET_BITS=64 on Solaris to match g++ >= 9.
1090 if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
1091 add_definitions("-D_FILE_OFFSET_BITS=64")
1094 set(CMAKE_INCLUDE_CURRENT_DIR ON)
1096 include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR})
1098 # when crosscompiling import the executable targets from a file
1099 if(LLVM_USE_HOST_TOOLS)
1100 include(CrossCompile)
1101 llvm_create_cross_target(LLVM NATIVE "" Release)
1102 endif(LLVM_USE_HOST_TOOLS)
1103 if(LLVM_TARGET_IS_CROSSCOMPILE_HOST)
1104 # Dummy use to avoid CMake Warning: Manually-specified variables were not used
1105 # (this is a variable that CrossCompile sets on recursive invocations)
1108 if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
1109 # special hack for Solaris to handle crazy system sys/regset.h
1110 include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")
1111 endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
1113 # Make sure we don't get -rdynamic in every binary. For those that need it,
1114 # use export_executable_symbols(target).
1115 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
1117 set(LLVM_EXTRACT_SYMBOLS_FLAGS ""
1118 CACHE STRING "Additional options to pass to llvm/utils/extract_symbols.py.
1119 These cannot override the options set by cmake, but can add extra options
1125 include(LLVMDistributionSupport)
1127 if( MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
1128 # People report that -O3 is unreliable on MinGW. The traditional
1129 # build also uses -O2 for that reason:
1130 llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
1133 if(LLVM_INCLUDE_TESTS)
1134 umbrella_lit_testsuite_begin(check-all)
1137 # Put this before tblgen. Else we have a circular dependence.
1138 add_subdirectory(lib/Demangle)
1139 add_subdirectory(lib/Support)
1140 add_subdirectory(lib/TableGen)
1142 add_subdirectory(utils/TableGen)
1144 add_subdirectory(include/llvm)
1146 add_subdirectory(lib)
1148 if( LLVM_INCLUDE_UTILS )
1149 add_subdirectory(utils/FileCheck)
1150 add_subdirectory(utils/PerfectShuffle)
1151 add_subdirectory(utils/count)
1152 add_subdirectory(utils/not)
1153 add_subdirectory(utils/UnicodeData)
1154 add_subdirectory(utils/yaml-bench)
1155 add_subdirectory(utils/split-file)
1156 if( LLVM_INCLUDE_TESTS )
1157 add_subdirectory(utils/unittest)
1160 if ( LLVM_INCLUDE_TESTS )
1161 message(FATAL_ERROR "Including tests when not building utils will not work.
1162 Either set LLVM_INCLUDE_UTILS to On, or set LLVM_INCLUDE_TESTS to Off.")
1166 # Use LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION instead of LLVM_INCLUDE_UTILS because it is not really a util
1167 if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
1168 add_subdirectory(utils/LLVMVisualizers)
1171 foreach( binding ${LLVM_BINDINGS_LIST} )
1172 if( EXISTS "${LLVM_MAIN_SRC_DIR}/bindings/${binding}/CMakeLists.txt" )
1173 add_subdirectory(bindings/${binding})
1177 add_subdirectory(projects)
1179 if( LLVM_INCLUDE_TOOLS )
1180 add_subdirectory(tools)
1183 if( LLVM_INCLUDE_RUNTIMES )
1184 add_subdirectory(runtimes)
1187 if( LLVM_INCLUDE_EXAMPLES )
1188 add_subdirectory(examples)
1191 if( LLVM_INCLUDE_TESTS )
1192 if(EXISTS ${LLVM_MAIN_SRC_DIR}/projects/test-suite AND TARGET clang)
1193 include(LLVMExternalProjectUtils)
1194 llvm_ExternalProject_Add(test-suite ${LLVM_MAIN_SRC_DIR}/projects/test-suite
1200 add_subdirectory(utils/lit)
1201 add_subdirectory(test)
1202 add_subdirectory(unittests)
1205 # This utility is used to prevent crashing tests from calling Dr. Watson on
1207 add_subdirectory(utils/KillTheDoctor)
1210 umbrella_lit_testsuite_end(check-all)
1211 get_property(LLVM_ALL_LIT_DEPENDS GLOBAL PROPERTY LLVM_ALL_LIT_DEPENDS)
1212 get_property(LLVM_ALL_ADDITIONAL_TEST_DEPENDS
1213 GLOBAL PROPERTY LLVM_ALL_ADDITIONAL_TEST_DEPENDS)
1214 add_custom_target(test-depends
1215 DEPENDS ${LLVM_ALL_LIT_DEPENDS} ${LLVM_ALL_ADDITIONAL_TEST_DEPENDS})
1216 set_target_properties(test-depends PROPERTIES FOLDER "Tests")
1219 if (LLVM_INCLUDE_DOCS)
1220 add_subdirectory(docs)
1223 add_subdirectory(cmake/modules)
1225 # Do this last so that all lit targets have already been created.
1226 if (LLVM_INCLUDE_UTILS)
1227 add_subdirectory(utils/llvm-lit)
1230 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
1231 install(DIRECTORY include/llvm include/llvm-c
1232 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
1233 COMPONENT llvm-headers
1239 PATTERN "LICENSE.TXT"
1242 install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm ${LLVM_INCLUDE_DIR}/llvm-c
1243 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
1244 COMPONENT llvm-headers
1250 # Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def"
1251 PATTERN "CMakeFiles" EXCLUDE
1252 PATTERN "config.h" EXCLUDE
1255 if (LLVM_INSTALL_MODULEMAPS)
1256 install(DIRECTORY include/llvm include/llvm-c
1257 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
1258 COMPONENT llvm-headers
1260 PATTERN "module.modulemap"
1262 install(FILES include/llvm/module.install.modulemap
1263 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm"
1264 COMPONENT llvm-headers
1265 RENAME "module.extern.modulemap"
1267 endif(LLVM_INSTALL_MODULEMAPS)
1269 # Installing the headers needs to depend on generating any public
1270 # tablegen'd headers.
1271 add_custom_target(llvm-headers DEPENDS intrinsics_gen omp_gen)
1272 set_target_properties(llvm-headers PROPERTIES FOLDER "Misc")
1274 if (NOT LLVM_ENABLE_IDE)
1275 add_llvm_install_targets(install-llvm-headers
1276 DEPENDS llvm-headers
1277 COMPONENT llvm-headers)
1280 # Custom target to install all libraries.
1281 add_custom_target(llvm-libraries)
1282 set_target_properties(llvm-libraries PROPERTIES FOLDER "Misc")
1284 if (NOT LLVM_ENABLE_IDE)
1285 add_llvm_install_targets(install-llvm-libraries
1286 DEPENDS llvm-libraries
1287 COMPONENT llvm-libraries)
1290 get_property(LLVM_LIBS GLOBAL PROPERTY LLVM_LIBS)
1292 list(REMOVE_DUPLICATES LLVM_LIBS)
1293 foreach(lib ${LLVM_LIBS})
1294 add_dependencies(llvm-libraries ${lib})
1295 if (NOT LLVM_ENABLE_IDE)
1296 add_dependencies(install-llvm-libraries install-${lib})
1297 add_dependencies(install-llvm-libraries-stripped install-${lib}-stripped)
1303 # This must be at the end of the LLVM root CMakeLists file because it must run
1304 # after all targets are created.
1305 llvm_distribution_add_targets()
1306 process_llvm_pass_plugins(GEN_CONFIG)
1307 include(CoverageReport)
1309 # This allows us to deploy the Universal CRT DLLs by passing -DCMAKE_INSTALL_UCRT_LIBRARIES=ON to CMake
1310 if (MSVC AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_INSTALL_UCRT_LIBRARIES)
1311 include(InstallRequiredSystemLibraries)
1314 if (LLVM_INCLUDE_BENCHMARKS)
1315 # Override benchmark defaults so that when the library itself is updated these
1316 # modifications are not lost.
1317 set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable benchmark testing" FORCE)
1318 set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "Disable benchmark exceptions" FORCE)
1319 set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Don't install benchmark" FORCE)
1320 set(BENCHMARK_DOWNLOAD_DEPENDENCIES OFF CACHE BOOL "Don't download dependencies" FORCE)
1321 set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable Google Test in benchmark" FORCE)
1322 set(BENCHMARK_ENABLE_WERROR ${LLVM_ENABLE_WERROR} CACHE BOOL
1323 "Handle -Werror for Google Benchmark based on LLVM_ENABLE_WERROR" FORCE)
1324 # Since LLVM requires C++11 it is safe to assume that std::regex is available.
1325 set(HAVE_STD_REGEX ON CACHE BOOL "OK" FORCE)
1326 add_subdirectory(${LLVM_THIRD_PARTY_DIR}/benchmark
1327 ${CMAKE_CURRENT_BINARY_DIR}/third-party/benchmark)
1328 add_subdirectory(benchmarks)
1331 if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS)
1332 add_subdirectory(utils/llvm-locstats)