Skip to content

Commit 39ddc67

Browse files
authored
[build] copy Python detection code into StandaloneOverlays.cmake (#31234)
This is to support workflows that do not rely on reading the main CMakeLists.txt. Based upon #30992, #31020 Addresses rdar://62245784
1 parent f883ca6 commit 39ddc67

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmake/modules/StandaloneOverlay.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ include(SwiftConfigureSDK)
115115
include(SwiftComponents)
116116
include(DarwinSDKs)
117117

118+
find_package(Python2 COMPONENTS Interpreter REQUIRED)
119+
find_package(Python3 COMPONENTS Interpreter)
120+
if(NOT Python3_Interpreter_FOUND)
121+
message(WARNING "Python3 not found, using python2 as a fallback")
122+
add_executable(Python3::Interpreter IMPORTED)
123+
set_target_properties(Python3::Interpreter PROPERTIES
124+
IMPORTED_LOCATION ${Python2_EXECUTABLE})
125+
endif()
118126

119127
# Without this line, installing components is broken. This needs refactoring.
120128
swift_configure_components()

0 commit comments

Comments
 (0)