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