1 if (NOT DEFINED LLVM_PATH)
2 set(LLVM_PATH ${CMAKE_CURRENT_LIST_DIR}/../../llvm CACHE PATH "" FORCE)
5 if(NOT IS_DIRECTORY ${LLVM_PATH})
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 "
13 set(LLVM_INCLUDE_DIR ${LLVM_PATH}/include CACHE PATH "Path to llvm/include")
14 set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree")
15 set(LLVM_MAIN_SRC_DIR ${LLVM_PATH})
16 set(LLVM_CMAKE_DIR "${LLVM_PATH}/cmake/modules")
17 set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
18 set(LLVM_LIBRARY_OUTPUT_INTDIR "${CMAKE_CURRENT_BINARY_DIR}/lib")
20 if (EXISTS "${LLVM_CMAKE_DIR}")
21 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
22 elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules")
23 list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
25 message(FATAL_ERROR "Neither ${LLVM_CMAKE_DIR} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found. "
26 "This is not a supported configuration.")
29 message(STATUS "Configuring for standalone build.")
31 # By default, we target the host, but this can be overridden at CMake invocation time.
32 include(GetHostTriple)
33 get_host_triple(LLVM_INFERRED_HOST_TRIPLE)
34 set(LLVM_HOST_TRIPLE "${LLVM_INFERRED_HOST_TRIPLE}" CACHE STRING "Host on which LLVM binaries will run")
35 set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING "Target triple used by default.")
37 # Add LLVM Functions --------------------------------------------------------
46 include(AddLLVM OPTIONAL)
48 # LLVM Options --------------------------------------------------------------
49 if (NOT DEFINED LLVM_INCLUDE_TESTS)
50 set(LLVM_INCLUDE_TESTS ON)
52 if (NOT DEFINED LLVM_INCLUDE_DOCS)
53 set(LLVM_INCLUDE_DOCS ON)
55 if (NOT DEFINED LLVM_ENABLE_SPHINX)
56 set(LLVM_ENABLE_SPHINX OFF)
59 if (LLVM_INCLUDE_TESTS)
60 # Required LIT Configuration ------------------------------------------------
61 # Define the default arguments to use with 'lit', and an option for the user
63 set(LLVM_DEFAULT_EXTERNAL_LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
64 set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
66 set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
68 set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
71 # Required doc configuration
72 if (LLVM_ENABLE_SPHINX)
73 find_package(Sphinx REQUIRED)
76 if (LLVM_ON_UNIX AND NOT APPLE)
77 set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
79 set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)