[libc-commits] [libc] [libc] Find Python 3 in standalone (PR #118871)

via libc-commits libc-commits at lists.llvm.org
Thu Dec 5 13:11:50 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Tristan Ross (RossComputerGuy)

<details>
<summary>Changes</summary>

`Python3_Executable` wasn't defined when libc is trying to be built in standalone mode. Also adds a `project` define so CMake quits complaining.

---
Full diff: https://github.com/llvm/llvm-project/pull/118871.diff


1 Files Affected:

- (modified) libc/CMakeLists.txt (+12) 


``````````diff
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 5196735bef4e76..cfe3e347980a37 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -8,6 +8,13 @@ endif()
 include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
   NO_POLICY_SCOPE)
 
+# If we are not building as a part of LLVM, build libc as an
+# standalone project, using LLVM as an external library:
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  project(libc)
+  set(LIBC_BUILT_STANDALONE TRUE)
+endif()
+
 if (LIBC_CMAKE_VERBOSE_LOGGING)
   get_directory_property(LIBC_OLD_PREPROCESSOR_DEFS COMPILE_DEFINITIONS)
   foreach(OLD_DEF ${LIBC_OLD_PREPROCESSOR_DEFS})
@@ -30,6 +37,11 @@ endif()
 # Default to C++17
 set(CMAKE_CXX_STANDARD 17)
 
+if(LIBC_BUILT_STANDALONE)
+  find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+    COMPONENTS Interpreter)
+endif()
+
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
 
 # The top-level source directory.

``````````

</details>


https://github.com/llvm/llvm-project/pull/118871


More information about the libc-commits mailing list