1if (NOT DEFINED LLVM_PATH)
2  set(LLVM_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../llvm CACHE PATH "" FORCE)
3endif()
4
5if(NOT IS_DIRECTORY ${LLVM_PATH})
6  message(FATAL_ERROR
7    "The provided LLVM_PATH (${LLVM_PATH}) is not a valid directory. Note that "
8    "building libc++ outside of the monorepo is not supported anymore. Please "
9    "use a Standalone build against the monorepo, a Runtimes build or a classic "
10    "monorepo build.")
11endif()
12
13set(LLVM_INCLUDE_DIR ${LLVM_PATH}/include CACHE PATH "Path to llvm/include")
14set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree")
15set(LLVM_MAIN_SRC_DIR ${LLVM_PATH})
16set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules")
17
18if (EXISTS "${LLVM_CMAKE_PATH}")
19  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
20elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules")
21  list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
22else()
23  message(FATAL_ERROR "Neither ${LLVM_CMAKE_PATH} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found. "
24                      "This is not a supported configuration.")
25endif()
26
27message(STATUS "Configuring for standalone build.")
28
29# Add LLVM Functions --------------------------------------------------------
30if (WIN32)
31  set(LLVM_ON_UNIX 0)
32  set(LLVM_ON_WIN32 1)
33else()
34  set(LLVM_ON_UNIX 1)
35  set(LLVM_ON_WIN32 0)
36endif()
37
38include(AddLLVM OPTIONAL)
39
40# LLVM Options --------------------------------------------------------------
41if (NOT DEFINED LLVM_INCLUDE_TESTS)
42  set(LLVM_INCLUDE_TESTS ON)
43endif()
44if (NOT DEFINED LLVM_INCLUDE_DOCS)
45  set(LLVM_INCLUDE_DOCS ON)
46endif()
47if (NOT DEFINED LLVM_ENABLE_SPHINX)
48  set(LLVM_ENABLE_SPHINX OFF)
49endif()
50
51if (LLVM_INCLUDE_TESTS)
52  # Required LIT Configuration ------------------------------------------------
53  # Define the default arguments to use with 'lit', and an option for the user
54  # to override.
55  set(LLVM_DEFAULT_EXTERNAL_LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
56  set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
57  if (MSVC OR XCODE)
58    set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
59  endif()
60  set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
61endif()
62
63# Required doc configuration
64if (LLVM_ENABLE_SPHINX)
65  find_package(Sphinx REQUIRED)
66endif()
67
68if (LLVM_ON_UNIX AND NOT APPLE)
69  set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
70else()
71  set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
72endif()
73