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