Skip to content

Commit 268a37e

Browse files
[libc] Find Python 3 in standalone
1 parent 0adff0a commit 268a37e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

libc/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ endif()
88
include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
99
NO_POLICY_SCOPE)
1010

11+
# If we are not building as a part of LLVM, build libc as an
12+
# standalone project, using LLVM as an external library:
13+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
14+
project(libc)
15+
set(LIBC_BUILT_STANDALONE TRUE)
16+
endif()
17+
1118
if (LIBC_CMAKE_VERBOSE_LOGGING)
1219
get_directory_property(LIBC_OLD_PREPROCESSOR_DEFS COMPILE_DEFINITIONS)
1320
foreach(OLD_DEF ${LIBC_OLD_PREPROCESSOR_DEFS})
@@ -30,6 +37,14 @@ endif()
3037
# Default to C++17
3138
set(CMAKE_CXX_STANDARD 17)
3239

40+
if(LIBC_BUILT_STANDALONE)
41+
# Python 3 is required and needs to be manually imported in
42+
# a standalone build.
43+
# NOTE: We specifically need pyyaml in order for hdrgen to work.
44+
find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
45+
COMPONENTS Interpreter)
46+
endif()
47+
3348
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
3449

3550
# The top-level source directory.

0 commit comments

Comments
 (0)