1# See docs/CMake.html for instructions about how to build LLVM with CMake. 2 3cmake_minimum_required(VERSION 3.13.4) 4if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0") 5 message(WARNING 6 "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the " 7 "minimum version of CMake required to build LLVM will become 3.20.0, and " 8 "using an older CMake will become an error. Please upgrade your CMake to " 9 "at least 3.20.0 now to avoid issues in the future!") 10endif() 11 12set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) 13include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake 14 NO_POLICY_SCOPE) 15 16set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) 17 18if(NOT DEFINED LLVM_VERSION_MAJOR) 19 set(LLVM_VERSION_MAJOR 16) 20endif() 21if(NOT DEFINED LLVM_VERSION_MINOR) 22 set(LLVM_VERSION_MINOR 0) 23endif() 24if(NOT DEFINED LLVM_VERSION_PATCH) 25 set(LLVM_VERSION_PATCH 6) 26endif() 27if(NOT DEFINED LLVM_VERSION_SUFFIX) 28 set(LLVM_VERSION_SUFFIX) 29endif() 30 31if (NOT PACKAGE_VERSION) 32 set(PACKAGE_VERSION 33 "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}") 34endif() 35 36if(NOT DEFINED LLVM_SHLIB_SYMBOL_VERSION) 37 # "Symbol version prefix for libLLVM.so" 38 set(LLVM_SHLIB_SYMBOL_VERSION "LLVM_${LLVM_VERSION_MAJOR}") 39endif() 40 41if ((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.") 46endif() 47 48if (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") 52endif() 53 54project(LLVM 55 VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH} 56 LANGUAGES C CXX ASM) 57 58if (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}") 61endif() 62 63# Must go after `DEFINED LLVM_LIBDIR_SUFFIX` check. 64set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" ) 65 66# Must go after `project(..)`. 67include(GNUInstallDirs) 68 69# This C++ standard is required to build LLVM. 70set(LLVM_REQUIRED_CXX_STANDARD 17) 71 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. 74if($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) 77endif() 78 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. 81if(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}.") 83endif() 84 85set(CMAKE_CXX_STANDARD ${LLVM_REQUIRED_CXX_STANDARD} CACHE STRING "C++ standard to conform to") 86set(CMAKE_CXX_STANDARD_REQUIRED YES) 87 88if (CYGWIN) 89 # Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in 90 # c++xx mode. 91 set(CMAKE_CXX_EXTENSIONS YES) 92else() 93 set(CMAKE_CXX_EXTENSIONS NO) 94endif() 95 96if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 97 message(FATAL_ERROR " 98No build type selected. You need to pass -DCMAKE_BUILD_TYPE=<type> in order to configure LLVM. 99Available 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. 104Learn more about these options in our documentation at https://llvm.org/docs/CMake.html#cmake-build-type 105") 106endif() 107 108# Set default build type for cmake's try_compile module. 109# CMake 3.17 or newer sets CMAKE_DEFAULT_BUILD_TYPE to one of the 110# items from CMAKE_CONFIGURATION_TYPES. Logic below can be further 111# simplified once LLVM's minimum CMake version is updated to 3.17. 112if(CMAKE_DEFAULT_BUILD_TYPE) 113 set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_DEFAULT_BUILD_TYPE}) 114else() 115 if(CMAKE_CONFIGURATION_TYPES) 116 list(GET CMAKE_CONFIGURATION_TYPES 0 CMAKE_TRY_COMPILE_CONFIGURATION) 117 elseif(CMAKE_BUILD_TYPE) 118 set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE}) 119 endif() 120endif() 121 122# Side-by-side subprojects layout: automatically set the 123# LLVM_EXTERNAL_${project}_SOURCE_DIR using LLVM_ALL_PROJECTS 124# This allows an easy way of setting up a build directory for llvm and another 125# one for llvm+clang+... using the same sources. 126set(LLVM_ALL_PROJECTS "bolt;clang;clang-tools-extra;compiler-rt;cross-project-tests;libc;libclc;lld;lldb;mlir;openmp;polly;pstl") 127# The flang project is not yet part of "all" projects (see C++ requirements) 128set(LLVM_EXTRA_PROJECTS "flang") 129# List of all known projects in the mono repo 130set(LLVM_KNOWN_PROJECTS "${LLVM_ALL_PROJECTS};${LLVM_EXTRA_PROJECTS}") 131set(LLVM_ENABLE_PROJECTS "" CACHE STRING 132 "Semicolon-separated list of projects to build (${LLVM_KNOWN_PROJECTS}), or \"all\".") 133# Make sure expansion happens first to not handle "all" in rest of the checks. 134if( LLVM_ENABLE_PROJECTS STREQUAL "all" ) 135 set( LLVM_ENABLE_PROJECTS ${LLVM_ALL_PROJECTS}) 136endif() 137foreach(proj ${LLVM_ENABLE_PROJECTS}) 138 if (NOT proj STREQUAL "llvm" AND NOT "${proj}" IN_LIST LLVM_KNOWN_PROJECTS) 139 MESSAGE(FATAL_ERROR "${proj} isn't a known project: ${LLVM_KNOWN_PROJECTS}. Did you mean to enable it as a runtime in LLVM_ENABLE_RUNTIMES?") 140 endif() 141endforeach() 142 143if ("flang" IN_LIST LLVM_ENABLE_PROJECTS) 144 if (NOT "mlir" IN_LIST LLVM_ENABLE_PROJECTS) 145 message(STATUS "Enabling MLIR as a dependency to flang") 146 list(APPEND LLVM_ENABLE_PROJECTS "mlir") 147 endif() 148 149 if (NOT "clang" IN_LIST LLVM_ENABLE_PROJECTS) 150 message(FATAL_ERROR "Clang is not enabled, but is required for the Flang driver") 151 endif() 152endif() 153 154# Select the runtimes to build 155# 156# As we migrate runtimes to using the bootstrapping build, the set of default runtimes 157# should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above. 158set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind") 159set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc") 160set(LLVM_ENABLE_RUNTIMES "" CACHE STRING 161 "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.") 162if(LLVM_ENABLE_RUNTIMES STREQUAL "all") 163 set(LLVM_ENABLE_RUNTIMES ${LLVM_DEFAULT_RUNTIMES}) 164endif() 165foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES) 166 if (NOT "${proj}" IN_LIST LLVM_SUPPORTED_RUNTIMES) 167 message(FATAL_ERROR "Runtime \"${proj}\" is not a supported runtime. Supported runtimes are: ${LLVM_SUPPORTED_RUNTIMES}") 168 endif() 169endforeach() 170 171# LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the 172# `LLVM_ENABLE_PROJECTS` CMake cache variable. This exists for 173# several reasons: 174# 175# * As an indicator that the `LLVM_ENABLE_PROJECTS` list is now the single 176# source of truth for which projects to build. This means we will ignore user 177# supplied `LLVM_TOOL_<project>_BUILD` CMake cache variables and overwrite 178# them. 179# 180# * The case where the user previously had `LLVM_ENABLE_PROJECTS` set to a 181# non-empty list but now the user wishes to disable building all other projects 182# by setting `LLVM_ENABLE_PROJECTS` to an empty string. In that case we still 183# need to set the `LLVM_TOOL_${upper_proj}_BUILD` variables so that we disable 184# building all the projects that were previously enabled. 185set(LLVM_ENABLE_PROJECTS_USED OFF CACHE BOOL "") 186mark_as_advanced(LLVM_ENABLE_PROJECTS_USED) 187 188if (LLVM_ENABLE_PROJECTS_USED OR NOT LLVM_ENABLE_PROJECTS STREQUAL "") 189 set(LLVM_ENABLE_PROJECTS_USED ON CACHE BOOL "" FORCE) 190 foreach(proj ${LLVM_KNOWN_PROJECTS} ${LLVM_EXTERNAL_PROJECTS}) 191 string(TOUPPER "${proj}" upper_proj) 192 string(REGEX REPLACE "-" "_" upper_proj ${upper_proj}) 193 if ("${proj}" IN_LIST LLVM_ENABLE_PROJECTS) 194 message(STATUS "${proj} project is enabled") 195 set(SHOULD_ENABLE_PROJECT TRUE) 196 set(PROJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}") 197 if(NOT EXISTS "${PROJ_DIR}" OR NOT IS_DIRECTORY "${PROJ_DIR}") 198 message(FATAL_ERROR "LLVM_ENABLE_PROJECTS requests ${proj} but directory not found: ${PROJ_DIR}") 199 endif() 200 if( LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR STREQUAL "" ) 201 set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}" CACHE PATH "" FORCE) 202 else() 203 set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}" CACHE PATH "") 204 endif() 205 elseif ("${proj}" IN_LIST LLVM_EXTERNAL_PROJECTS) 206 message(STATUS "${proj} project is enabled") 207 set(SHOULD_ENABLE_PROJECT TRUE) 208 else() 209 message(STATUS "${proj} project is disabled") 210 set(SHOULD_ENABLE_PROJECT FALSE) 211 endif() 212 # Force `LLVM_TOOL_${upper_proj}_BUILD` variables to have values that 213 # corresponds with `LLVM_ENABLE_PROJECTS`. This prevents the user setting 214 # `LLVM_TOOL_${upper_proj}_BUILD` variables externally. At some point 215 # we should deprecate allowing users to set these variables by turning them 216 # into normal CMake variables rather than cache variables. 217 set(LLVM_TOOL_${upper_proj}_BUILD 218 ${SHOULD_ENABLE_PROJECT} 219 CACHE 220 BOOL "Whether to build ${upper_proj} as part of LLVM" FORCE 221 ) 222 endforeach() 223endif() 224unset(SHOULD_ENABLE_PROJECT) 225 226# Build llvm with ccache if the package is present 227set(LLVM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build") 228if(LLVM_CCACHE_BUILD) 229 find_program(CCACHE_PROGRAM ccache) 230 if(CCACHE_PROGRAM) 231 set(LLVM_CCACHE_MAXSIZE "" CACHE STRING "Size of ccache") 232 set(LLVM_CCACHE_DIR "" CACHE STRING "Directory to keep ccached data") 233 set(LLVM_CCACHE_PARAMS "CCACHE_CPP2=yes CCACHE_HASHDIR=yes" 234 CACHE STRING "Parameters to pass through to ccache") 235 236 if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows") 237 set(CCACHE_PROGRAM "${LLVM_CCACHE_PARAMS} ${CCACHE_PROGRAM}") 238 if (LLVM_CCACHE_MAXSIZE) 239 set(CCACHE_PROGRAM "CCACHE_MAXSIZE=${LLVM_CCACHE_MAXSIZE} ${CCACHE_PROGRAM}") 240 endif() 241 if (LLVM_CCACHE_DIR) 242 set(CCACHE_PROGRAM "CCACHE_DIR=${LLVM_CCACHE_DIR} ${CCACHE_PROGRAM}") 243 endif() 244 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM}) 245 else() 246 if(LLVM_CCACHE_MAXSIZE OR LLVM_CCACHE_DIR OR 247 NOT LLVM_CCACHE_PARAMS MATCHES "CCACHE_CPP2=yes CCACHE_HASHDIR=yes") 248 message(FATAL_ERROR "Ccache configuration through CMake is not supported on Windows. Please use environment variables.") 249 endif() 250 # RULE_LAUNCH_COMPILE should work with Ninja but currently has issues 251 # with cmd.exe and some MSVC tools other than cl.exe 252 set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) 253 set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) 254 endif() 255 else() 256 message(FATAL_ERROR "Unable to find the program ccache. Set LLVM_CCACHE_BUILD to OFF") 257 endif() 258endif() 259 260set(LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS "" CACHE STRING 261 "Optional arguments for the native tool used in CMake --build invocations for external projects.") 262mark_as_advanced(LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS) 263 264option(LLVM_DEPENDENCY_DEBUGGING "Dependency debugging mode to verify correctly expressed library dependencies (Darwin only)" OFF) 265 266# Some features of the LLVM build may be disallowed when dependency debugging is 267# enabled. In particular you cannot use ccache because we want to force compile 268# operations to always happen. 269if(LLVM_DEPENDENCY_DEBUGGING) 270 if(NOT CMAKE_HOST_APPLE) 271 message(FATAL_ERROR "Dependency debugging is only currently supported on Darwin hosts.") 272 endif() 273 if(LLVM_CCACHE_BUILD) 274 message(FATAL_ERROR "Cannot enable dependency debugging while using ccache.") 275 endif() 276endif() 277 278option(LLVM_ENABLE_DAGISEL_COV "Debug: Prints tablegen patterns that were used for selecting" OFF) 279option(LLVM_ENABLE_GISEL_COV "Enable collection of GlobalISel rule coverage" OFF) 280if(LLVM_ENABLE_GISEL_COV) 281 set(LLVM_GISEL_COV_PREFIX "${CMAKE_BINARY_DIR}/gisel-coverage-" CACHE STRING "Provide a filename prefix to collect the GlobalISel rule coverage") 282endif() 283 284# Add path for custom modules 285list(INSERT CMAKE_MODULE_PATH 0 286 "${CMAKE_CURRENT_SOURCE_DIR}/cmake" 287 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" 288 "${LLVM_COMMON_CMAKE_UTILS}/Modules" 289 ) 290 291# Generate a CompilationDatabase (compile_commands.json file) for our build, 292# for use by clang_complete, YouCompleteMe, etc. 293set(CMAKE_EXPORT_COMPILE_COMMANDS 1) 294 295option(LLVM_INSTALL_BINUTILS_SYMLINKS 296 "Install symlinks from the binutils tool names to the corresponding LLVM tools." OFF) 297 298option(LLVM_INSTALL_CCTOOLS_SYMLINKS 299 "Install symlinks from the cctools tool names to the corresponding LLVM tools." OFF) 300 301# By default we use symlinks on Unix platforms and copy binaries on Windows 302# If you have the correct setup on Windows you can use this option to enable 303# symlinks and save a lot of diskspace. 304option(LLVM_USE_SYMLINKS "Use symlinks instead of copying binaries" ${CMAKE_HOST_UNIX}) 305 306option(LLVM_INSTALL_UTILS "Include utility binaries in the 'install' target." OFF) 307 308option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF) 309 310# Unfortunatly Clang is too eager to search directories for module maps, which can cause the 311# installed version of the maps to be found when building LLVM from source. Therefore we turn off 312# the installation by default. See llvm.org/PR31905. 313option(LLVM_INSTALL_MODULEMAPS "Install the modulemap files in the 'install' target." OFF) 314 315option(LLVM_USE_FOLDERS "Enable solution folders in Visual Studio. Disable for Express versions." ON) 316if ( LLVM_USE_FOLDERS ) 317 set_property(GLOBAL PROPERTY USE_FOLDERS ON) 318endif() 319 320include(VersionFromVCS) 321 322option(LLVM_APPEND_VC_REV 323 "Embed the version control system revision in LLVM" ON) 324 325option(LLVM_TOOL_LLVM_DRIVER_BUILD "Enables building the llvm multicall tool" OFF) 326 327set(PACKAGE_NAME LLVM) 328set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") 329set(PACKAGE_BUGREPORT "https://github.com/llvm/llvm-project/issues/") 330 331set(BUG_REPORT_URL "${PACKAGE_BUGREPORT}" CACHE STRING 332 "Default URL where bug reports are to be submitted.") 333 334# Configure CPack. 335if(NOT DEFINED CPACK_PACKAGE_INSTALL_DIRECTORY) 336 set(CPACK_PACKAGE_INSTALL_DIRECTORY "LLVM") 337endif() 338if(NOT DEFINED CPACK_PACKAGE_VENDOR) 339 set(CPACK_PACKAGE_VENDOR "LLVM") 340endif() 341set(CPACK_PACKAGE_VERSION_MAJOR ${LLVM_VERSION_MAJOR}) 342set(CPACK_PACKAGE_VERSION_MINOR ${LLVM_VERSION_MINOR}) 343set(CPACK_PACKAGE_VERSION_PATCH ${LLVM_VERSION_PATCH}) 344set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION}) 345set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT") 346if(WIN32 AND NOT UNIX) 347 set(CPACK_NSIS_COMPRESSOR "/SOLID lzma \r\n SetCompressorDictSize 32") 348 if(NOT DEFINED CPACK_PACKAGE_INSTALL_REGISTRY_KEY) 349 set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "LLVM") 350 endif() 351 set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_logo.bmp") 352 set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico") 353 set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico") 354 set(CPACK_NSIS_MODIFY_PATH "ON") 355 set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON") 356 if( CMAKE_CL_64 ) 357 if(NOT DEFINED CPACK_NSIS_INSTALL_ROOT) 358 set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") 359 endif() 360 endif() 361endif() 362include(CPack) 363 364# Sanity check our source directory to make sure that we are not trying to 365# generate an in-source build (unless on MSVC_IDE, where it is ok), and to make 366# sure that we don't have any stray generated files lying around in the tree 367# (which would end up getting picked up by header search, instead of the correct 368# versions). 369if( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE ) 370 message(FATAL_ERROR "In-source builds are not allowed. 371Please create a directory and run cmake from there, passing the path 372to this source directory as the last argument. 373This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. 374Please delete them.") 375endif() 376 377string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) 378 379if (CMAKE_BUILD_TYPE AND 380 NOT uppercase_CMAKE_BUILD_TYPE MATCHES "^(DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL)$") 381 message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") 382endif() 383 384# LLVM_INSTALL_PACKAGE_DIR needs to be declared prior to adding the tools 385# subdirectory in order to have the value available for llvm-config. 386include(GNUInstallPackageDir) 387set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING 388 "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") 389 390set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING 391 "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") 392mark_as_advanced(LLVM_TOOLS_INSTALL_DIR) 393 394set(LLVM_UTILS_INSTALL_DIR "${LLVM_TOOLS_INSTALL_DIR}" CACHE STRING 395 "Path to install LLVM utilities (enabled by LLVM_INSTALL_UTILS=ON) (defaults to LLVM_TOOLS_INSTALL_DIR)") 396mark_as_advanced(LLVM_UTILS_INSTALL_DIR) 397 398set(LLVM_EXAMPLES_INSTALL_DIR "examples" CACHE STRING 399 "Path for examples subdirectory (enabled by LLVM_BUILD_EXAMPLES=ON) (defaults to 'examples')") 400mark_as_advanced(LLVM_EXAMPLES_INSTALL_DIR) 401 402# They are used as destination of target generators. 403set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) 404set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) 405if(WIN32 OR CYGWIN) 406 # DLL platform -- put DLLs into bin. 407 set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) 408else() 409 set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) 410endif() 411 412# Each of them corresponds to llvm-config's. 413set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir 414set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) # --libdir 415set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root 416set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir 417set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) # --prefix 418 419 420# Note: LLVM_CMAKE_DIR does not include generated files 421set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules) 422set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples) 423set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include) 424 425# List of all targets to be built by default: 426set(LLVM_ALL_TARGETS 427 AArch64 428 AMDGPU 429 ARM 430 AVR 431 BPF 432 Hexagon 433 Lanai 434 LoongArch 435 Mips 436 MSP430 437 NVPTX 438 PowerPC 439 RISCV 440 Sparc 441 SystemZ 442 VE 443 WebAssembly 444 X86 445 XCore 446 ) 447 448# List of targets with JIT support: 449set(LLVM_TARGETS_WITH_JIT X86 PowerPC AArch64 ARM Mips SystemZ) 450 451set(LLVM_TARGETS_TO_BUILD "all" 452 CACHE STRING "Semicolon-separated list of targets to build, or \"all\".") 453 454set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD "" 455 CACHE STRING "Semicolon-separated list of experimental targets to build.") 456 457option(BUILD_SHARED_LIBS 458 "Build all libraries as shared libraries instead of static" OFF) 459 460option(LLVM_ENABLE_BACKTRACES "Enable embedding backtraces on crash." ON) 461if(LLVM_ENABLE_BACKTRACES) 462 set(ENABLE_BACKTRACES 1) 463endif() 464 465option(LLVM_ENABLE_UNWIND_TABLES "Emit unwind tables for the libraries" ON) 466 467option(LLVM_ENABLE_CRASH_OVERRIDES "Enable crash overrides." ON) 468if(LLVM_ENABLE_CRASH_OVERRIDES) 469 set(ENABLE_CRASH_OVERRIDES 1) 470endif() 471 472option(LLVM_ENABLE_CRASH_DUMPS "Turn on memory dumps on crashes. Currently only implemented on Windows." OFF) 473 474set(WINDOWS_PREFER_FORWARD_SLASH_DEFAULT OFF) 475if (MINGW) 476 # Cygwin doesn't identify itself as Windows, and thus gets path::Style::posix 477 # as native path style, regardless of what this is set to. 478 set(WINDOWS_PREFER_FORWARD_SLASH_DEFAULT ON) 479endif() 480option(LLVM_WINDOWS_PREFER_FORWARD_SLASH "Prefer path names with forward slashes on Windows." ${WINDOWS_PREFER_FORWARD_SLASH_DEFAULT}) 481 482option(LLVM_ENABLE_FFI "Use libffi to call external functions from the interpreter" OFF) 483set(FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so") 484set(FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for ffi.h or ffi/ffi.h") 485 486set(LLVM_TARGET_ARCH "host" 487 CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.") 488 489option(LLVM_ENABLE_TERMINFO "Use terminfo database if available." ON) 490 491set(LLVM_ENABLE_LIBXML2 "ON" CACHE STRING "Use libxml2 if available. Can be ON, OFF, or FORCE_ON") 492 493option(LLVM_ENABLE_LIBEDIT "Use libedit if available." ON) 494 495option(LLVM_ENABLE_LIBPFM "Use libpfm for performance counters if available." ON) 496 497# On z/OS, threads cannot be used because TLS is not supported. 498if (CMAKE_SYSTEM_NAME MATCHES "OS390") 499 option(LLVM_ENABLE_THREADS "Use threads if available." OFF) 500else() 501 option(LLVM_ENABLE_THREADS "Use threads if available." ON) 502endif() 503 504set(LLVM_ENABLE_ZLIB "ON" CACHE STRING "Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON") 505 506set(LLVM_ENABLE_ZSTD "ON" CACHE STRING "Use zstd for compression/decompression if available. Can be ON, OFF, or FORCE_ON") 507 508set(LLVM_USE_STATIC_ZSTD FALSE CACHE BOOL "Use static version of zstd. Can be TRUE, FALSE") 509 510set(LLVM_ENABLE_CURL "OFF" CACHE STRING "Use libcurl for the HTTP client if available. Can be ON, OFF, or FORCE_ON") 511 512set(LLVM_ENABLE_HTTPLIB "OFF" CACHE STRING "Use cpp-httplib HTTP server library if available. Can be ON, OFF, or FORCE_ON") 513 514set(LLVM_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.") 515 516option(LLVM_ENABLE_Z3_SOLVER 517 "Enable Support for the Z3 constraint solver in LLVM." 518 ${LLVM_ENABLE_Z3_SOLVER_DEFAULT} 519) 520 521if (LLVM_ENABLE_Z3_SOLVER) 522 find_package(Z3 4.7.1) 523 524 if (LLVM_Z3_INSTALL_DIR) 525 if (NOT Z3_FOUND) 526 message(FATAL_ERROR "Z3 >= 4.7.1 has not been found in LLVM_Z3_INSTALL_DIR: ${LLVM_Z3_INSTALL_DIR}.") 527 endif() 528 endif() 529 530 if (NOT Z3_FOUND) 531 message(FATAL_ERROR "LLVM_ENABLE_Z3_SOLVER cannot be enabled when Z3 is not available.") 532 endif() 533 534 set(LLVM_WITH_Z3 1) 535endif() 536 537set(LLVM_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}") 538 539 540if( LLVM_TARGETS_TO_BUILD STREQUAL "all" ) 541 set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} ) 542endif() 543 544set(LLVM_TARGETS_TO_BUILD 545 ${LLVM_TARGETS_TO_BUILD} 546 ${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}) 547list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD) 548 549option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON) 550option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF) 551if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 552 option(LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." ON) 553else() 554 option(LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." OFF) 555endif() 556option(LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." ON) 557option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF) 558option(LLVM_STATIC_LINK_CXX_STDLIB "Statically link the standard library." OFF) 559option(LLVM_ENABLE_LLD "Use lld as C and C++ linker." OFF) 560option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) 561option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) 562 563option(LLVM_ENABLE_DUMP "Enable dump functions even when assertions are disabled" OFF) 564option(LLVM_UNREACHABLE_OPTIMIZE "Optimize llvm_unreachable() as undefined behavior (default), guaranteed trap when OFF" ON) 565 566if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" ) 567 option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF) 568else() 569 option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) 570endif() 571 572option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF) 573 574# While adding scalable vector support to LLVM, we temporarily want to 575# allow an implicit conversion of TypeSize to uint64_t, and to allow 576# code to get the fixed number of elements from a possibly scalable vector. 577# This CMake flag enables a more strict mode where it asserts that the type 578# is not a scalable vector type. 579# 580# Enabling this flag makes it easier to find cases where the compiler makes 581# assumptions on the size being 'fixed size', when building tests for 582# SVE/SVE2 or other scalable vector architectures. 583option(LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS 584 "Enable assertions that type is not scalable in implicit conversion from TypeSize to uint64_t and calls to getNumElements" OFF) 585 586set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING 587 "Enable abi-breaking checks. Can be WITH_ASSERTS, FORCE_ON or FORCE_OFF.") 588 589option(LLVM_FORCE_USE_OLD_TOOLCHAIN 590 "Set to ON to force using an old, unsupported host toolchain." OFF) 591 592set(LLVM_LOCAL_RPATH "" CACHE FILEPATH 593 "If set, an absolute path added as rpath on binaries that do not already contain an executable-relative rpath.") 594 595option(LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN 596 "Set to ON to only warn when using a toolchain which is about to be deprecated, instead of emitting an error." OFF) 597 598option(LLVM_USE_INTEL_JITEVENTS 599 "Use Intel JIT API to inform Intel(R) VTune(TM) Amplifier XE 2011 about JIT code" 600 OFF) 601 602if( LLVM_USE_INTEL_JITEVENTS ) 603 # Verify we are on a supported platform 604 if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) 605 message(FATAL_ERROR 606 "Intel JIT API support is available on Linux and Windows only.") 607 endif() 608endif( LLVM_USE_INTEL_JITEVENTS ) 609 610option(LLVM_USE_OPROFILE 611 "Use opagent JIT interface to inform OProfile about JIT code" OFF) 612 613option(LLVM_EXTERNALIZE_DEBUGINFO 614 "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF) 615 616set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING 617 "Sign executables and dylibs with the given identity or skip if empty (Darwin Only)") 618 619# If enabled, verify we are on a platform that supports oprofile. 620if( LLVM_USE_OPROFILE ) 621 if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) 622 message(FATAL_ERROR "OProfile support is available on Linux only.") 623 endif( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) 624endif( LLVM_USE_OPROFILE ) 625 626option(LLVM_USE_PERF 627 "Use perf JIT interface to inform perf about JIT code" OFF) 628 629# If enabled, verify we are on a platform that supports perf. 630if( LLVM_USE_PERF ) 631 if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) 632 message(FATAL_ERROR "perf support is available on Linux only.") 633 endif( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) 634endif( LLVM_USE_PERF ) 635 636set(LLVM_USE_SANITIZER "" CACHE STRING 637 "Define the sanitizer used to build binaries and tests.") 638option(LLVM_OPTIMIZE_SANITIZED_BUILDS "Pass -O1 on debug sanitizer builds" ON) 639set(LLVM_UBSAN_FLAGS 640 "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all" 641 CACHE STRING 642 "Compile flags set to enable UBSan. Only used if LLVM_USE_SANITIZER contains 'Undefined'.") 643set(LLVM_LIB_FUZZING_ENGINE "" CACHE PATH 644 "Path to fuzzing library for linking with fuzz targets") 645 646option(LLVM_USE_SPLIT_DWARF 647 "Use -gsplit-dwarf when compiling llvm and --gdb-index when linking." OFF) 648 649# Define an option controlling whether we should build for 32-bit on 64-bit 650# platforms, where supported. 651if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT (WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")) 652 # TODO: support other platforms and toolchains. 653 option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF) 654endif() 655 656# Define the default arguments to use with 'lit', and an option for the user to 657# override. 658set(LIT_ARGS_DEFAULT "-sv") 659if (MSVC_IDE OR XCODE) 660 set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") 661endif() 662set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") 663 664# On Win32 hosts, provide an option to specify the path to the GnuWin32 tools. 665if( WIN32 AND NOT CYGWIN ) 666 set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") 667endif() 668set(LLVM_NATIVE_TOOL_DIR "" CACHE PATH "Path to a directory containing prebuilt matching native tools (such as llvm-tblgen)") 669 670set(LLVM_INTEGRATED_CRT_ALLOC "" CACHE PATH "Replace the Windows CRT allocator with any of {rpmalloc|mimalloc|snmalloc}. Only works with /MT enabled.") 671if(LLVM_INTEGRATED_CRT_ALLOC) 672 if(NOT WIN32) 673 message(FATAL_ERROR "LLVM_INTEGRATED_CRT_ALLOC is only supported on Windows.") 674 endif() 675 if(LLVM_USE_SANITIZER) 676 message(FATAL_ERROR "LLVM_INTEGRATED_CRT_ALLOC cannot be used along with LLVM_USE_SANITIZER!") 677 endif() 678 if(CMAKE_BUILD_TYPE AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") 679 message(FATAL_ERROR "The Debug target isn't supported along with LLVM_INTEGRATED_CRT_ALLOC!") 680 endif() 681endif() 682 683# Define options to control the inclusion and default build behavior for 684# components which may not strictly be necessary (tools, examples, and tests). 685# 686# This is primarily to support building smaller or faster project files. 687option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON) 688option(LLVM_BUILD_TOOLS 689 "Build the LLVM tools. If OFF, just generate build targets." ON) 690 691option(LLVM_INCLUDE_UTILS "Generate build targets for the LLVM utils." ON) 692option(LLVM_BUILD_UTILS 693 "Build LLVM utility binaries. If OFF, just generate build targets." ON) 694 695option(LLVM_INCLUDE_RUNTIMES "Generate build targets for the LLVM runtimes." ON) 696option(LLVM_BUILD_RUNTIMES 697 "Build the LLVM runtimes. If OFF, just generate build targets." ON) 698 699option(LLVM_BUILD_RUNTIME 700 "Build the LLVM runtime libraries." ON) 701option(LLVM_BUILD_EXAMPLES 702 "Build the LLVM example programs. If OFF, just generate build targets." OFF) 703option(LLVM_INCLUDE_EXAMPLES "Generate build targets for the LLVM examples" ON) 704 705if(LLVM_BUILD_EXAMPLES) 706 add_compile_definitions(BUILD_EXAMPLES) 707endif(LLVM_BUILD_EXAMPLES) 708 709option(LLVM_BUILD_TESTS 710 "Build LLVM unit tests. If OFF, just generate build targets." OFF) 711option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON) 712 713option(LLVM_BUILD_BENCHMARKS "Add LLVM benchmark targets to the list of default 714targets. If OFF, benchmarks still could be built using Benchmarks target." OFF) 715option(LLVM_INCLUDE_BENCHMARKS "Generate benchmark targets. If OFF, benchmarks can't be built." ON) 716 717option (LLVM_BUILD_DOCS "Build the llvm documentation." OFF) 718option (LLVM_INCLUDE_DOCS "Generate build targets for llvm documentation." ON) 719option (LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm API documentation." OFF) 720option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF) 721option (LLVM_ENABLE_OCAMLDOC "Build OCaml bindings documentation." ON) 722option (LLVM_ENABLE_BINDINGS "Build bindings." ON) 723 724set(LLVM_INSTALL_DOXYGEN_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/llvm/doxygen-html" 725 CACHE STRING "Doxygen-generated HTML documentation install directory") 726set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/llvm/ocaml-html" 727 CACHE STRING "OCamldoc-generated HTML documentation install directory") 728 729option (LLVM_BUILD_EXTERNAL_COMPILER_RT 730 "Build compiler-rt as an external project." OFF) 731 732option (LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO 733 "Show target and host info when tools are invoked with --version." ON) 734 735# You can configure which libraries from LLVM you want to include in the 736# shared library by setting LLVM_DYLIB_COMPONENTS to a semi-colon delimited 737# list of LLVM components. All component names handled by llvm-config are valid. 738if(NOT DEFINED LLVM_DYLIB_COMPONENTS) 739 set(LLVM_DYLIB_COMPONENTS "all" CACHE STRING 740 "Semicolon-separated list of components to include in libLLVM, or \"all\".") 741endif() 742 743if(MSVC) 744 option(LLVM_BUILD_LLVM_C_DYLIB "Build LLVM-C.dll (Windows only)" ON) 745 # Set this variable to OFF here so it can't be set with a command-line 746 # argument. 747 set (LLVM_LINK_LLVM_DYLIB OFF) 748 if (BUILD_SHARED_LIBS) 749 message(FATAL_ERROR "BUILD_SHARED_LIBS options is not supported on Windows.") 750 endif() 751else() 752 option(LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF) 753 option(LLVM_BUILD_LLVM_C_DYLIB "Build libllvm-c re-export library (Darwin only)" OFF) 754 set(LLVM_BUILD_LLVM_DYLIB_default OFF) 755 if(LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB) 756 set(LLVM_BUILD_LLVM_DYLIB_default ON) 757 endif() 758 option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${LLVM_BUILD_LLVM_DYLIB_default}) 759endif() 760 761if (LLVM_LINK_LLVM_DYLIB AND BUILD_SHARED_LIBS) 762 message(FATAL_ERROR "Cannot enable BUILD_SHARED_LIBS with LLVM_LINK_LLVM_DYLIB. We recommend disabling BUILD_SHARED_LIBS.") 763endif() 764 765option(LLVM_OPTIMIZED_TABLEGEN "Force TableGen to be built with optimization" OFF) 766if(CMAKE_CROSSCOMPILING OR (LLVM_OPTIMIZED_TABLEGEN AND (LLVM_ENABLE_ASSERTIONS OR CMAKE_CONFIGURATION_TYPES))) 767 set(LLVM_USE_HOST_TOOLS ON) 768endif() 769 770option(LLVM_OMIT_DAGISEL_COMMENTS "Do not add comments to DAG ISel" ON) 771if (CMAKE_BUILD_TYPE AND uppercase_CMAKE_BUILD_TYPE MATCHES "^(RELWITHDEBINFO|DEBUG)$") 772 set(LLVM_OMIT_DAGISEL_COMMENTS OFF) 773endif() 774 775if (MSVC_IDE) 776 option(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE) 777endif() 778 779if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE OR 780 LLVM_ENABLE_IR_PGO) 781 if(NOT LLVM_PROFILE_MERGE_POOL_SIZE) 782 # A pool size of 1-2 is probably sufficient on a SSD. 3-4 should be fine 783 # for spining disks. Anything higher may only help on slower mediums. 784 set(LLVM_PROFILE_MERGE_POOL_SIZE "4") 785 endif() 786 if(NOT LLVM_PROFILE_FILE_PATTERN) 787 if(NOT LLVM_PROFILE_DATA_DIR) 788 file(TO_NATIVE_PATH "${LLVM_BINARY_DIR}/profiles" LLVM_PROFILE_DATA_DIR) 789 endif() 790 file(TO_NATIVE_PATH "${LLVM_PROFILE_DATA_DIR}/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_PROFILE_FILE_PATTERN) 791 endif() 792 if(NOT LLVM_CSPROFILE_FILE_PATTERN) 793 if(NOT LLVM_CSPROFILE_DATA_DIR) 794 file(TO_NATIVE_PATH "${LLVM_BINARY_DIR}/csprofiles" LLVM_CSPROFILE_DATA_DIR) 795 endif() 796 file(TO_NATIVE_PATH "${LLVM_CSPROFILE_DATA_DIR}/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_CSPROFILE_FILE_PATTERN) 797 endif() 798endif() 799 800if (LLVM_BUILD_STATIC) 801 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") 802 # Remove shared library suffixes from use in find_library 803 foreach (shared_lib_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_IMPORT_LIBRARY_SUFFIX}) 804 list(FIND CMAKE_FIND_LIBRARY_SUFFIXES ${shared_lib_suffix} shared_lib_suffix_idx) 805 if(NOT ${shared_lib_suffix_idx} EQUAL -1) 806 list(REMOVE_AT CMAKE_FIND_LIBRARY_SUFFIXES ${shared_lib_suffix_idx}) 807 endif() 808 endforeach() 809endif() 810 811# Use libtool instead of ar if you are both on an Apple host, and targeting Apple. 812if(CMAKE_HOST_APPLE AND APPLE) 813 include(UseLibtool) 814endif() 815 816# Override the default target with an environment variable named by LLVM_TARGET_TRIPLE_ENV. 817set(LLVM_TARGET_TRIPLE_ENV CACHE STRING "The name of environment variable to override default target. Disabled by blank.") 818mark_as_advanced(LLVM_TARGET_TRIPLE_ENV) 819 820# Per target dir not yet supported on Arm 32 bit due to arm vs armhf handling 821if(CMAKE_SYSTEM_NAME MATCHES "BSD|Linux" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") 822 set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON) 823else() 824 set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF) 825endif() 826set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default} CACHE BOOL 827 "Enable per-target runtimes directory") 828 829set(LLVM_PROFDATA_FILE "" CACHE FILEPATH 830 "Profiling data file to use when compiling in order to improve runtime performance.") 831 832if(LLVM_INCLUDE_TESTS) 833 # Lit test suite requires at least python 3.6 834 set(LLVM_MINIMUM_PYTHON_VERSION 3.6) 835else() 836 # FIXME: it is unknown if this is the actual minimum bound 837 set(LLVM_MINIMUM_PYTHON_VERSION 3.0) 838endif() 839 840# Find python before including config-ix, since it needs to be able to search 841# for python modules. 842find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED 843 COMPONENTS Interpreter) 844 845# All options referred to from HandleLLVMOptions have to be specified 846# BEFORE this include, otherwise options will not be correctly set on 847# first cmake run 848include(config-ix) 849 850# By default, we target the host, but this can be overridden at CMake 851# invocation time. Except on 64-bit AIX, where the system toolchain 852# expect 32-bit objects by default. 853if("${LLVM_HOST_TRIPLE}" MATCHES "^powerpc64-ibm-aix") 854 string(REGEX REPLACE "^powerpc64" "powerpc" LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}") 855else() 856 # Only set default triple when native target is enabled. 857 if (LLVM_NATIVE_TARGET) 858 set(LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}") 859 endif() 860endif() 861 862include(SetTargetTriple) 863set_llvm_target_triple() 864 865if(WIN32 OR CYGWIN) 866 if(BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB) 867 set(LLVM_ENABLE_PLUGINS_default ON) 868 else() 869 set(LLVM_ENABLE_PLUGINS_default OFF) 870 endif() 871else() 872 set(LLVM_ENABLE_PLUGINS_default ${LLVM_ENABLE_PIC}) 873endif() 874option(LLVM_ENABLE_PLUGINS "Enable plugin support" ${LLVM_ENABLE_PLUGINS_default}) 875 876set(LLVM_ENABLE_NEW_PASS_MANAGER TRUE CACHE BOOL 877 "Enable the new pass manager by default.") 878if(NOT LLVM_ENABLE_NEW_PASS_MANAGER) 879 message(FATAL_ERROR "Enabling the legacy pass manager on the cmake level is" 880 " no longer supported.") 881endif() 882 883include(HandleLLVMOptions) 884 885###### 886 887# Configure all of the various header file fragments LLVM uses which depend on 888# configuration variables. 889set(LLVM_ENUM_TARGETS "") 890set(LLVM_ENUM_ASM_PRINTERS "") 891set(LLVM_ENUM_ASM_PARSERS "") 892set(LLVM_ENUM_DISASSEMBLERS "") 893set(LLVM_ENUM_TARGETMCAS "") 894set(LLVM_ENUM_EXEGESIS "") 895foreach(t ${LLVM_TARGETS_TO_BUILD}) 896 set( td ${LLVM_MAIN_SRC_DIR}/lib/Target/${t} ) 897 898 list(FIND LLVM_ALL_TARGETS ${t} idx) 899 list(FIND LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ${t} idy) 900 # At this point, LLVMBUILDTOOL already checked all the targets passed in 901 # LLVM_TARGETS_TO_BUILD and LLVM_EXPERIMENTAL_TARGETS_TO_BUILD, so 902 # this test just makes sure that any experimental targets were passed via 903 # LLVM_EXPERIMENTAL_TARGETS_TO_BUILD, not LLVM_TARGETS_TO_BUILD. 904 if( idx LESS 0 AND idy LESS 0 ) 905 message(FATAL_ERROR "The target `${t}' is experimental and must be passed " 906 "via LLVM_EXPERIMENTAL_TARGETS_TO_BUILD.") 907 else() 908 set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${t})\n") 909 endif() 910 911 file(GLOB asmp_file "${td}/*AsmPrinter.cpp") 912 if( asmp_file ) 913 set(LLVM_ENUM_ASM_PRINTERS 914 "${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n") 915 endif() 916 if( EXISTS ${td}/AsmParser/CMakeLists.txt ) 917 set(LLVM_ENUM_ASM_PARSERS 918 "${LLVM_ENUM_ASM_PARSERS}LLVM_ASM_PARSER(${t})\n") 919 endif() 920 if( EXISTS ${td}/Disassembler/CMakeLists.txt ) 921 set(LLVM_ENUM_DISASSEMBLERS 922 "${LLVM_ENUM_DISASSEMBLERS}LLVM_DISASSEMBLER(${t})\n") 923 endif() 924 if( EXISTS ${td}/MCA/CMakeLists.txt ) 925 set(LLVM_ENUM_TARGETMCAS 926 "${LLVM_ENUM_TARGETMCAS}LLVM_TARGETMCA(${t})\n") 927 endif() 928 if( EXISTS ${LLVM_MAIN_SRC_DIR}/tools/llvm-exegesis/lib/${t}/CMakeLists.txt ) 929 set(LLVM_ENUM_EXEGESIS 930 "${LLVM_ENUM_EXEGESIS}LLVM_EXEGESIS(${t})\n") 931 endif() 932endforeach(t) 933 934# Provide an LLVM_ namespaced alias for use in #cmakedefine. 935set(LLVM_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) 936 937# Produce the target definition files, which provide a way for clients to easily 938# include various classes of targets. 939configure_file( 940 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmPrinters.def.in 941 ${LLVM_INCLUDE_DIR}/llvm/Config/AsmPrinters.def 942 ) 943configure_file( 944 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmParsers.def.in 945 ${LLVM_INCLUDE_DIR}/llvm/Config/AsmParsers.def 946 ) 947configure_file( 948 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Disassemblers.def.in 949 ${LLVM_INCLUDE_DIR}/llvm/Config/Disassemblers.def 950 ) 951configure_file( 952 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.def.in 953 ${LLVM_INCLUDE_DIR}/llvm/Config/Targets.def 954 ) 955configure_file( 956 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/TargetMCAs.def.in 957 ${LLVM_INCLUDE_DIR}/llvm/Config/TargetMCAs.def 958 ) 959configure_file( 960 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/TargetExegesis.def.in 961 ${LLVM_INCLUDE_DIR}/llvm/Config/TargetExegesis.def 962 ) 963 964# They are not referenced. See set_output_directory(). 965set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} ) 966set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_LIBRARY_DIR} ) 967set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_LIBRARY_DIR} ) 968 969if(LLVM_INCLUDE_TESTS) 970 include(GetErrcMessages) 971 get_errc_messages(LLVM_LIT_ERRC_MESSAGES) 972endif() 973 974# For up-to-date instructions for installing the TFLite dependency, refer to 975# the bot setup script: https://github.com/google/ml-compiler-opt/blob/main/buildbot/buildbot_init.sh 976set(LLVM_HAVE_TFLITE "" CACHE BOOL "Use tflite") 977if (LLVM_HAVE_TFLITE) 978 find_package(tensorflow-lite REQUIRED) 979endif() 980 981# For up-to-date instructions for installing the Tensorflow dependency, refer to 982# the bot setup script: https://github.com/google/ml-compiler-opt/blob/main/buildbot/buildbot_init.sh 983# Specifically, assuming python3 is installed: 984# python3 -m pip install --upgrade pip && python3 -m pip install --user tf_nightly==2.3.0.dev20200528 985# Then set TENSORFLOW_AOT_PATH to the package install - usually it's ~/.local/lib/python3.7/site-packages/tensorflow 986# 987set(TENSORFLOW_AOT_PATH "" CACHE PATH "Path to TensorFlow pip install dir") 988 989if (NOT TENSORFLOW_AOT_PATH STREQUAL "") 990 set(LLVM_HAVE_TF_AOT "ON" CACHE BOOL "Tensorflow AOT available") 991 set(TENSORFLOW_AOT_COMPILER 992 "${TENSORFLOW_AOT_PATH}/../../../../bin/saved_model_cli" 993 CACHE PATH "Path to the Tensorflow AOT compiler") 994 include_directories(${TENSORFLOW_AOT_PATH}/include) 995 add_subdirectory(${TENSORFLOW_AOT_PATH}/xla_aot_runtime_src 996 ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/tf_runtime) 997 install(TARGETS tf_xla_runtime EXPORT LLVMExports 998 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT tf_xla_runtime) 999 set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS tf_xla_runtime) 1000 # Once we add more modules, we should handle this more automatically. 1001 if (DEFINED LLVM_OVERRIDE_MODEL_HEADER_INLINERSIZEMODEL) 1002 set(LLVM_INLINER_MODEL_PATH "none") 1003 elseif(NOT DEFINED LLVM_INLINER_MODEL_PATH 1004 OR "${LLVM_INLINER_MODEL_PATH}" STREQUAL "" 1005 OR "${LLVM_INLINER_MODEL_PATH}" STREQUAL "autogenerate") 1006 set(LLVM_INLINER_MODEL_PATH "autogenerate") 1007 set(LLVM_INLINER_MODEL_AUTOGENERATED 1) 1008 endif() 1009 if (DEFINED LLVM_OVERRIDE_MODEL_HEADER_REGALLOCEVICTMODEL) 1010 set(LLVM_RAEVICT_MODEL_PATH "none") 1011 elseif(NOT DEFINED LLVM_RAEVICT_MODEL_PATH 1012 OR "${LLVM_RAEVICT_MODEL_PATH}" STREQUAL "" 1013 OR "${LLVM_RAEVICT_MODEL_PATH}" STREQUAL "autogenerate") 1014 set(LLVM_RAEVICT_MODEL_PATH "autogenerate") 1015 set(LLVM_RAEVICT_MODEL_AUTOGENERATED 1) 1016 endif() 1017 1018endif() 1019 1020# Configure the three LLVM configuration header files. 1021configure_file( 1022 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/config.h.cmake 1023 ${LLVM_INCLUDE_DIR}/llvm/Config/config.h) 1024configure_file( 1025 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/llvm-config.h.cmake 1026 ${LLVM_INCLUDE_DIR}/llvm/Config/llvm-config.h) 1027configure_file( 1028 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/abi-breaking.h.cmake 1029 ${LLVM_INCLUDE_DIR}/llvm/Config/abi-breaking.h) 1030 1031# Add target for generating source rpm package. 1032set(LLVM_SRPM_USER_BINARY_SPECFILE ${CMAKE_CURRENT_SOURCE_DIR}/llvm.spec.in 1033 CACHE FILEPATH ".spec file to use for srpm generation") 1034set(LLVM_SRPM_BINARY_SPECFILE ${CMAKE_CURRENT_BINARY_DIR}/llvm.spec) 1035set(LLVM_SRPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/srpm") 1036 1037get_source_info(${CMAKE_CURRENT_SOURCE_DIR} revision repository) 1038string(LENGTH "${revision}" revision_length) 1039set(LLVM_RPM_SPEC_REVISION "${revision}") 1040 1041configure_file( 1042 ${LLVM_SRPM_USER_BINARY_SPECFILE} 1043 ${LLVM_SRPM_BINARY_SPECFILE} @ONLY) 1044 1045add_custom_target(srpm 1046 COMMAND cpack -G TGZ --config CPackSourceConfig.cmake -B ${LLVM_SRPM_DIR}/SOURCES 1047 COMMAND rpmbuild -bs --define '_topdir ${LLVM_SRPM_DIR}' ${LLVM_SRPM_BINARY_SPECFILE}) 1048set_target_properties(srpm PROPERTIES FOLDER "Misc") 1049 1050if(APPLE AND DARWIN_LTO_LIBRARY) 1051 set(CMAKE_EXE_LINKER_FLAGS 1052 "${CMAKE_EXE_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}") 1053 set(CMAKE_SHARED_LINKER_FLAGS 1054 "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}") 1055 set(CMAKE_MODULE_LINKER_FLAGS 1056 "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-lto_library -Wl,${DARWIN_LTO_LIBRARY}") 1057endif() 1058 1059# Build with _XOPEN_SOURCE on AIX, as stray macros in _ALL_SOURCE mode tend to 1060# break things. In this case we need to enable the large-file API as well. 1061if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX") 1062 add_compile_definitions(_XOPEN_SOURCE=700) 1063 add_compile_definitions(_LARGE_FILE_API) 1064 1065 # CMake versions less than 3.16 set default linker flags to include -brtl, as 1066 # well as setting -G when building libraries, so clear them out. Note we only 1067 # try to clear the form that CMake will set as part of its initial 1068 # configuration, it is still possible the user may force it as part of a 1069 # compound option. 1070 if(CMAKE_VERSION VERSION_LESS 3.16) 1071 string(REGEX REPLACE "(^|[ \t]+)-Wl,-brtl([ \t]+|$)" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") 1072 string(REGEX REPLACE "(^|[ \t]+)-Wl,-brtl([ \t]+|$)" " " CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") 1073 string(REGEX REPLACE "(^|[ \t]+)-Wl,-brtl([ \t]+|$)" " " CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}") 1074 string(REGEX REPLACE "(^|[ \t]+)(-Wl,)?-G([ \t]+|$)" " " CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS 1075 "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}") 1076 string(REGEX REPLACE "(^|[ \t]+)(-Wl,)?-G([ \t]+|$)" " " CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS 1077 "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}") 1078 string(REGEX REPLACE "(^|[ \t]+)(-Wl,)?-G([ \t]+|$)" " " CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS 1079 "${CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS}") 1080 string(REGEX REPLACE "(^|[ \t]+)-Wl,-G," " -Wl," CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS 1081 "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}") 1082 string(REGEX REPLACE "(^|[ \t]+)-Wl,-G," " -Wl," CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS 1083 "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}") 1084 string(REGEX REPLACE "(^|[ \t]+)-Wl,-G," " -Wl," CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS 1085 "${CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS}") 1086 endif() 1087 1088 # Modules should be built with -shared -Wl,-G, so we can use runtime linking 1089 # with plugins. 1090 string(APPEND CMAKE_MODULE_LINKER_FLAGS " -shared -Wl,-G") 1091 1092 # Also set the correct flags for building shared libraries. 1093 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -shared") 1094endif() 1095 1096# Build with _XOPEN_SOURCE on z/OS. 1097if (CMAKE_SYSTEM_NAME MATCHES "OS390") 1098 add_compile_definitions(_XOPEN_SOURCE=600) 1099 add_compile_definitions(_OPEN_SYS) # Needed for process information. 1100 add_compile_definitions(_OPEN_SYS_FILE_EXT) # Needed for EBCDIC I/O. 1101endif() 1102 1103# Build with _FILE_OFFSET_BITS=64 on Solaris to match g++ >= 9. 1104if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "SunOS") 1105 add_compile_definitions(_FILE_OFFSET_BITS=64) 1106endif() 1107 1108set(CMAKE_INCLUDE_CURRENT_DIR ON) 1109 1110include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}) 1111 1112# when crosscompiling import the executable targets from a file 1113if(LLVM_USE_HOST_TOOLS) 1114 include(CrossCompile) 1115 llvm_create_cross_target(LLVM NATIVE "" Release) 1116endif(LLVM_USE_HOST_TOOLS) 1117if(LLVM_TARGET_IS_CROSSCOMPILE_HOST) 1118# Dummy use to avoid CMake Warning: Manually-specified variables were not used 1119# (this is a variable that CrossCompile sets on recursive invocations) 1120endif() 1121 1122if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS ) 1123 # special hack for Solaris to handle crazy system sys/regset.h 1124 include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris") 1125endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS ) 1126 1127# Make sure we don't get -rdynamic in every binary. For those that need it, 1128# use export_executable_symbols(target). 1129set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") 1130 1131set(LLVM_EXTRACT_SYMBOLS_FLAGS "" 1132 CACHE STRING "Additional options to pass to llvm/utils/extract_symbols.py. 1133 These cannot override the options set by cmake, but can add extra options 1134 such as --tools.") 1135 1136include(AddLLVM) 1137include(TableGen) 1138 1139include(LLVMDistributionSupport) 1140 1141if( MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) 1142 # People report that -O3 is unreliable on MinGW. The traditional 1143 # build also uses -O2 for that reason: 1144 llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2") 1145endif() 1146 1147if(LLVM_INCLUDE_TESTS) 1148 umbrella_lit_testsuite_begin(check-all) 1149endif() 1150 1151# Put this before tblgen. Else we have a circular dependence. 1152add_subdirectory(lib/Demangle) 1153add_subdirectory(lib/Support) 1154add_subdirectory(lib/TableGen) 1155 1156add_subdirectory(utils/TableGen) 1157 1158add_subdirectory(include/llvm) 1159 1160add_subdirectory(lib) 1161 1162if( LLVM_INCLUDE_UTILS ) 1163 add_subdirectory(utils/FileCheck) 1164 add_subdirectory(utils/PerfectShuffle) 1165 add_subdirectory(utils/count) 1166 add_subdirectory(utils/not) 1167 add_subdirectory(utils/UnicodeData) 1168 add_subdirectory(utils/yaml-bench) 1169 add_subdirectory(utils/split-file) 1170 if( LLVM_INCLUDE_TESTS ) 1171 add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest) 1172 endif() 1173else() 1174 if ( LLVM_INCLUDE_TESTS ) 1175 message(FATAL_ERROR "Including tests when not building utils will not work. 1176 Either set LLVM_INCLUDE_UTILS to On, or set LLVM_INCLUDE_TESTS to Off.") 1177 endif() 1178endif() 1179 1180# Use LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION instead of LLVM_INCLUDE_UTILS because it is not really a util 1181if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION) 1182 add_subdirectory(utils/LLVMVisualizers) 1183endif() 1184 1185foreach( binding ${LLVM_BINDINGS_LIST} ) 1186 if( EXISTS "${LLVM_MAIN_SRC_DIR}/bindings/${binding}/CMakeLists.txt" ) 1187 add_subdirectory(bindings/${binding}) 1188 endif() 1189endforeach() 1190 1191add_subdirectory(projects) 1192 1193if( LLVM_INCLUDE_TOOLS ) 1194 add_subdirectory(tools) 1195endif() 1196 1197if( LLVM_INCLUDE_RUNTIMES ) 1198 add_subdirectory(runtimes) 1199endif() 1200 1201if( LLVM_INCLUDE_EXAMPLES ) 1202 add_subdirectory(examples) 1203endif() 1204 1205if( LLVM_INCLUDE_TESTS ) 1206 if(EXISTS ${LLVM_MAIN_SRC_DIR}/projects/test-suite AND TARGET clang) 1207 include(LLVMExternalProjectUtils) 1208 llvm_ExternalProject_Add(test-suite ${LLVM_MAIN_SRC_DIR}/projects/test-suite 1209 USE_TOOLCHAIN 1210 EXCLUDE_FROM_ALL 1211 NO_INSTALL 1212 ALWAYS_CLEAN) 1213 endif() 1214 add_subdirectory(utils/lit) 1215 add_subdirectory(test) 1216 add_subdirectory(unittests) 1217 1218 if (WIN32) 1219 # This utility is used to prevent crashing tests from calling Dr. Watson on 1220 # Windows. 1221 add_subdirectory(utils/KillTheDoctor) 1222 endif() 1223 1224 umbrella_lit_testsuite_end(check-all) 1225 get_property(LLVM_ALL_LIT_DEPENDS GLOBAL PROPERTY LLVM_ALL_LIT_DEPENDS) 1226 get_property(LLVM_ALL_ADDITIONAL_TEST_DEPENDS 1227 GLOBAL PROPERTY LLVM_ALL_ADDITIONAL_TEST_DEPENDS) 1228 add_custom_target(test-depends 1229 DEPENDS ${LLVM_ALL_LIT_DEPENDS} ${LLVM_ALL_ADDITIONAL_TEST_DEPENDS}) 1230 set_target_properties(test-depends PROPERTIES FOLDER "Tests") 1231endif() 1232 1233if (LLVM_INCLUDE_DOCS) 1234 add_subdirectory(docs) 1235endif() 1236 1237add_subdirectory(cmake/modules) 1238 1239# Do this last so that all lit targets have already been created. 1240if (LLVM_INCLUDE_UTILS) 1241 add_subdirectory(utils/llvm-lit) 1242endif() 1243 1244if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) 1245 install(DIRECTORY include/llvm include/llvm-c 1246 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" 1247 COMPONENT llvm-headers 1248 FILES_MATCHING 1249 PATTERN "*.def" 1250 PATTERN "*.h" 1251 PATTERN "*.td" 1252 PATTERN "*.inc" 1253 PATTERN "LICENSE.TXT" 1254 ) 1255 1256 install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm ${LLVM_INCLUDE_DIR}/llvm-c 1257 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" 1258 COMPONENT llvm-headers 1259 FILES_MATCHING 1260 PATTERN "*.def" 1261 PATTERN "*.h" 1262 PATTERN "*.gen" 1263 PATTERN "*.inc" 1264 # Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def" 1265 PATTERN "CMakeFiles" EXCLUDE 1266 PATTERN "config.h" EXCLUDE 1267 ) 1268 1269 if (LLVM_INSTALL_MODULEMAPS) 1270 install(DIRECTORY include/llvm include/llvm-c 1271 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" 1272 COMPONENT llvm-headers 1273 FILES_MATCHING 1274 PATTERN "module.modulemap" 1275 ) 1276 install(FILES include/llvm/module.install.modulemap 1277 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm" 1278 COMPONENT llvm-headers 1279 RENAME "module.extern.modulemap" 1280 ) 1281 endif(LLVM_INSTALL_MODULEMAPS) 1282 1283 # Installing the headers needs to depend on generating any public 1284 # tablegen'd headers. 1285 add_custom_target(llvm-headers DEPENDS intrinsics_gen omp_gen) 1286 set_target_properties(llvm-headers PROPERTIES FOLDER "Misc") 1287 1288 if (NOT LLVM_ENABLE_IDE) 1289 add_llvm_install_targets(install-llvm-headers 1290 DEPENDS llvm-headers 1291 COMPONENT llvm-headers) 1292 endif() 1293 1294 # Custom target to install all libraries. 1295 add_custom_target(llvm-libraries) 1296 set_target_properties(llvm-libraries PROPERTIES FOLDER "Misc") 1297 1298 if (NOT LLVM_ENABLE_IDE) 1299 add_llvm_install_targets(install-llvm-libraries 1300 DEPENDS llvm-libraries 1301 COMPONENT llvm-libraries) 1302 endif() 1303 1304 get_property(LLVM_LIBS GLOBAL PROPERTY LLVM_LIBS) 1305 if(LLVM_LIBS) 1306 list(REMOVE_DUPLICATES LLVM_LIBS) 1307 foreach(lib ${LLVM_LIBS}) 1308 add_dependencies(llvm-libraries ${lib}) 1309 if (NOT LLVM_ENABLE_IDE) 1310 add_dependencies(install-llvm-libraries install-${lib}) 1311 add_dependencies(install-llvm-libraries-stripped install-${lib}-stripped) 1312 endif() 1313 endforeach() 1314 endif() 1315endif() 1316 1317# This must be at the end of the LLVM root CMakeLists file because it must run 1318# after all targets are created. 1319llvm_distribution_add_targets() 1320process_llvm_pass_plugins(GEN_CONFIG) 1321include(CoverageReport) 1322 1323# This allows us to deploy the Universal CRT DLLs by passing -DCMAKE_INSTALL_UCRT_LIBRARIES=ON to CMake 1324if (MSVC AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_INSTALL_UCRT_LIBRARIES) 1325 include(InstallRequiredSystemLibraries) 1326endif() 1327 1328if (LLVM_INCLUDE_BENCHMARKS) 1329 # Override benchmark defaults so that when the library itself is updated these 1330 # modifications are not lost. 1331 set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable benchmark testing" FORCE) 1332 set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "Disable benchmark exceptions" FORCE) 1333 set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Don't install benchmark" FORCE) 1334 set(BENCHMARK_DOWNLOAD_DEPENDENCIES OFF CACHE BOOL "Don't download dependencies" FORCE) 1335 set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable Google Test in benchmark" FORCE) 1336 set(BENCHMARK_ENABLE_WERROR ${LLVM_ENABLE_WERROR} CACHE BOOL 1337 "Handle -Werror for Google Benchmark based on LLVM_ENABLE_WERROR" FORCE) 1338 # Since LLVM requires C++11 it is safe to assume that std::regex is available. 1339 set(HAVE_STD_REGEX ON CACHE BOOL "OK" FORCE) 1340 add_subdirectory(${LLVM_THIRD_PARTY_DIR}/benchmark 1341 ${CMAKE_CURRENT_BINARY_DIR}/third-party/benchmark) 1342 add_subdirectory(benchmarks) 1343endif() 1344 1345if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) 1346 add_subdirectory(utils/llvm-locstats) 1347endif() 1348