Skip to content

Commit e8cbdec

Browse files
committed
Moved SwiftFoundation_MODULE_TRIPLE to top scope
1 parent c408a9f commit e8cbdec

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ else()
6767
endif()
6868
FetchContent_MakeAvailable(SwiftFoundationICU SwiftFoundation)
6969

70+
# Precompute module triple for installation
71+
if(NOT SwiftFoundation_MODULE_TRIPLE)
72+
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
73+
if(CMAKE_Swift_COMPILER_TARGET)
74+
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
75+
endif()
76+
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
77+
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple")
78+
set(SwiftFoundation_MODULE_TRIPLE "${module_triple}" CACHE STRING "swift module triple used for installed swiftmodule and swiftinterface files")
79+
mark_as_advanced(SwiftFoundation_MODULE_TRIPLE)
80+
endif()
81+
7082
# System dependencies (fail fast if dependencies are missing)
7183
find_package(LibXml2 REQUIRED)
7284
find_package(CURL REQUIRED)

cmake/modules/FoundationSwiftSupport.cmake

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,6 @@ function(_foundation_install_target module)
3535
set(module_name ${module})
3636
endif()
3737

38-
if(NOT SwiftFoundation_MODULE_TRIPLE)
39-
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
40-
if(CMAKE_Swift_COMPILER_TARGET)
41-
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
42-
endif()
43-
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
44-
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple")
45-
set(SwiftFoundation_MODULE_TRIPLE "${module_triple}" CACHE STRING "swift module triple used for installed swiftmodule and swiftinterface files")
46-
mark_as_advanced(SwiftFoundation_MODULE_TRIPLE)
47-
endif()
48-
4938
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc
5039
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule
5140
RENAME ${SwiftFoundation_MODULE_TRIPLE}.swiftdoc)

0 commit comments

Comments
 (0)