mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 02:17:27 +08:00
Xcode: Fix detection of Swift compiler location for Xcode 14.3
Previously we tried to match output from `xcodebuild` to detect the path to the `swiftc` tool. This approach is used for C and CXX for historical reasons, but is unnecessary for Swift. We know the name of the tool, so we can just ask `xcrun --find swiftc`. Fixes: #24666
This commit is contained in:
@@ -15,7 +15,14 @@ if("${CMAKE_GENERATOR}" STREQUAL "Xcode")
|
|||||||
message(FATAL_ERROR "Swift language not supported by Xcode ${XCODE_VERSION}")
|
message(FATAL_ERROR "Swift language not supported by Xcode ${XCODE_VERSION}")
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_Swift_COMPILER_XCODE_TYPE sourcecode.swift)
|
set(CMAKE_Swift_COMPILER_XCODE_TYPE sourcecode.swift)
|
||||||
_cmake_find_compiler_path(Swift)
|
execute_process(COMMAND xcrun --find swiftc
|
||||||
|
OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
ERROR_VARIABLE _xcrun_err RESULT_VARIABLE _xcrun_result)
|
||||||
|
if(_xcrun_result EQUAL 0 AND EXISTS "${_xcrun_out}")
|
||||||
|
set(CMAKE_Swift_COMPILER "${_xcrun_out}")
|
||||||
|
else()
|
||||||
|
_cmake_find_compiler_path(Swift)
|
||||||
|
endif()
|
||||||
elseif("${CMAKE_GENERATOR}" MATCHES "^Ninja")
|
elseif("${CMAKE_GENERATOR}" MATCHES "^Ninja")
|
||||||
if(CMAKE_Swift_COMPILER)
|
if(CMAKE_Swift_COMPILER)
|
||||||
_cmake_find_compiler_path(Swift)
|
_cmake_find_compiler_path(Swift)
|
||||||
@@ -52,9 +59,6 @@ if(NOT CMAKE_Swift_COMPILER_ID_RUN)
|
|||||||
if("${CMAKE_GENERATOR}" STREQUAL "Xcode")
|
if("${CMAKE_GENERATOR}" STREQUAL "Xcode")
|
||||||
list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple)
|
list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple)
|
||||||
set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler")
|
set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler")
|
||||||
|
|
||||||
set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwift[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift")
|
|
||||||
set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_INDEX 2)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Try to identify the compiler.
|
# Try to identify the compiler.
|
||||||
|
Reference in New Issue
Block a user