• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1cmake_minimum_required(VERSION 3.13.4)
2
3if(POLICY CMP0068)
4  cmake_policy(SET CMP0068 NEW)
5  set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
6endif()
7
8if(POLICY CMP0075)
9  cmake_policy(SET CMP0075 NEW)
10endif()
11
12if(POLICY CMP0077)
13  cmake_policy(SET CMP0077 NEW)
14endif()
15
16project(LLVM_RUNTIMES)
17
18find_package(Python3 COMPONENTS Interpreter)
19if(NOT Python3_Interpreter_FOUND)
20  message(WARNING "Python3 not found, using python2 as a fallback")
21  find_package(Python2 COMPONENTS Interpreter REQUIRED)
22  if(Python2_VERSION VERSION_LESS 2.7)
23    message(SEND_ERROR "Python 2.7 or newer is required")
24  endif()
25
26  # Treat python2 as python3
27  add_executable(Python3::Interpreter IMPORTED)
28  set_target_properties(Python3::Interpreter PROPERTIES
29    IMPORTED_LOCATION ${Python2_EXECUTABLE})
30  set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
31endif()
32
33# This needs to be set before we add any Lit target for `add_lit_target` to
34# select the right Lit to run the tests.
35set(LLVM_LIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/bin")
36
37# Automatically define a few variables that are normally set globally by LLVM.
38# This is to keep some amount of similarity between the global LLVM build and
39# this minimal build.
40set(LLVM_UMBRELLA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../..")
41list(APPEND CMAKE_MODULE_PATH "${LLVM_UMBRELLA_ROOT}/libcxx/cmake/Modules")
42include(HandleOutOfTreeLLVM)
43
44# Override the external Lit to make sure we use the one we generate below.
45# TODO: We can remove this once we start relying on the in-tree version of Lit
46#       in HandleOutOfTreeLLVM.
47set(LLVM_DEFAULT_EXTERNAL_LIT "")
48
49# Include individual runtime projects
50set(LLVM_ENABLE_PROJECTS "" CACHE STRING "Semicolon-separated list of runtimes to build.")
51foreach(project IN LISTS LLVM_ENABLE_PROJECTS)
52  add_subdirectory("${LLVM_UMBRELLA_ROOT}/${project}" "${CMAKE_CURRENT_BINARY_DIR}/${project}")
53endforeach()
54
55# Generate the llvm-lit wrapper, needed for testing. This must be done after
56# the projects have been added, since the wraper is only generated correctly
57# if the test suites have already been added with add_lit_target.
58add_subdirectory("${LLVM_UMBRELLA_ROOT}/llvm/utils/llvm-lit" "${CMAKE_CURRENT_BINARY_DIR}/llvm-lit")
59