llvm-project
80 строк · 2.8 Кб
1if (NOT DEFINED LLVM_PATH)
2set(LLVM_PATH ${CMAKE_CURRENT_LIST_DIR}/../../llvm CACHE PATH "" FORCE)
3endif()
4
5if(NOT IS_DIRECTORY ${LLVM_PATH})
6message(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_DIR "${LLVM_PATH}/cmake/modules")
17set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
18set(LLVM_LIBRARY_OUTPUT_INTDIR "${CMAKE_CURRENT_BINARY_DIR}/lib")
19
20if (EXISTS "${LLVM_CMAKE_DIR}")
21list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
22elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules")
23list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
24else()
25message(FATAL_ERROR "Neither ${LLVM_CMAKE_DIR} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found. "
26"This is not a supported configuration.")
27endif()
28
29message(STATUS "Configuring for standalone build.")
30
31# By default, we target the host, but this can be overridden at CMake invocation time.
32include(GetHostTriple)
33get_host_triple(LLVM_INFERRED_HOST_TRIPLE)
34set(LLVM_HOST_TRIPLE "${LLVM_INFERRED_HOST_TRIPLE}" CACHE STRING "Host on which LLVM binaries will run")
35set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING "Target triple used by default.")
36
37# Add LLVM Functions --------------------------------------------------------
38if (WIN32)
39set(LLVM_ON_UNIX 0)
40set(LLVM_ON_WIN32 1)
41else()
42set(LLVM_ON_UNIX 1)
43set(LLVM_ON_WIN32 0)
44endif()
45
46include(AddLLVM OPTIONAL)
47
48# LLVM Options --------------------------------------------------------------
49if (NOT DEFINED LLVM_INCLUDE_TESTS)
50set(LLVM_INCLUDE_TESTS ON)
51endif()
52if (NOT DEFINED LLVM_INCLUDE_DOCS)
53set(LLVM_INCLUDE_DOCS ON)
54endif()
55if (NOT DEFINED LLVM_ENABLE_SPHINX)
56set(LLVM_ENABLE_SPHINX OFF)
57endif()
58
59if (LLVM_INCLUDE_TESTS)
60# Required LIT Configuration ------------------------------------------------
61# Define the default arguments to use with 'lit', and an option for the user
62# to override.
63set(LLVM_DEFAULT_EXTERNAL_LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
64set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
65if (MSVC OR XCODE)
66set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
67endif()
68set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
69endif()
70
71# Required doc configuration
72if (LLVM_ENABLE_SPHINX)
73find_package(Sphinx REQUIRED)
74endif()
75
76if (LLVM_ON_UNIX AND NOT APPLE)
77set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
78else()
79set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
80endif()
81