File: HandleOutOfTreeLLVM.cmake

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-6~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,418,812 kB
  • sloc: cpp: 5,290,827; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,900; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,892; xml: 953; cs: 573; fortran: 539
file content (78 lines) | stat: -rw-r--r-- 2,735 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
if (NOT DEFINED LLVM_PATH)
  set(LLVM_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../llvm CACHE PATH "" FORCE)
endif()

if(NOT IS_DIRECTORY ${LLVM_PATH})
  message(FATAL_ERROR
    "The provided LLVM_PATH (${LLVM_PATH}) is not a valid directory. Note that "
    "building libc++ outside of the monorepo is not supported anymore. Please "
    "use a Standalone build against the monorepo, a Runtimes build or a classic "
    "monorepo build.")
endif()

set(LLVM_INCLUDE_DIR ${LLVM_PATH}/include CACHE PATH "Path to llvm/include")
set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree")
set(LLVM_MAIN_SRC_DIR ${LLVM_PATH})
set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules")

if (EXISTS "${LLVM_CMAKE_PATH}")
  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules")
  list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
else()
  message(FATAL_ERROR "Neither ${LLVM_CMAKE_PATH} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found. "
                      "This is not a supported configuration.")
endif()

message(STATUS "Configuring for standalone build.")

# By default, we target the host, but this can be overridden at CMake invocation time.
include(GetHostTriple)
get_host_triple(LLVM_INFERRED_HOST_TRIPLE)
set(LLVM_HOST_TRIPLE "${LLVM_INFERRED_HOST_TRIPLE}" CACHE STRING "Host on which LLVM binaries will run")
set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING "Target triple used by default.")

# Add LLVM Functions --------------------------------------------------------
if (WIN32)
  set(LLVM_ON_UNIX 0)
  set(LLVM_ON_WIN32 1)
else()
  set(LLVM_ON_UNIX 1)
  set(LLVM_ON_WIN32 0)
endif()

include(AddLLVM OPTIONAL)

# LLVM Options --------------------------------------------------------------
if (NOT DEFINED LLVM_INCLUDE_TESTS)
  set(LLVM_INCLUDE_TESTS ON)
endif()
if (NOT DEFINED LLVM_INCLUDE_DOCS)
  set(LLVM_INCLUDE_DOCS ON)
endif()
if (NOT DEFINED LLVM_ENABLE_SPHINX)
  set(LLVM_ENABLE_SPHINX OFF)
endif()

if (LLVM_INCLUDE_TESTS)
  # Required LIT Configuration ------------------------------------------------
  # Define the default arguments to use with 'lit', and an option for the user
  # to override.
  set(LLVM_DEFAULT_EXTERNAL_LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
  set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
  if (MSVC OR XCODE)
    set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
  endif()
  set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
endif()

# Required doc configuration
if (LLVM_ENABLE_SPHINX)
  find_package(Sphinx REQUIRED)
endif()

if (LLVM_ON_UNIX AND NOT APPLE)
  set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
else()
  set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
endif()