Xcode 14 beta:CMake 无法解析 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER

Bil*_*ngs 3 xcode cmake xcode14

尝试cmake使用以下命令运行创建 Xcode 项目:

cmake -G Xcode ..
Run Code Online (Sandbox Code Playgroud)

它在 Xcode 13 及以下版本下完美运行。但在 Xcode 14 beta 下,如果突然失败,我会得到以下输出:

-- Found Git: /usr/bin/git (found version "2.32.1 (Apple Git-133)")
-- Found PythonInterp: /usr/local/bin/python3 (found suitable version "3.9", minimum required is "3")
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:17 (project):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:17 (project):
  No CMAKE_CXX_COMPILER could be found.
Run Code Online (Sandbox Code Playgroud)

更多详细信息CMakeFiles/CMakeError.log包括:

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.

error: An empty identity is not valid when signing a binary for the product type 'Command-line Tool'. (in target 'CompilerIdC' from project 'CompilerIdC')
Run Code Online (Sandbox Code Playgroud)

这是怎么回事,我该如何解决?

小智 7

至少更新到 cmake v3.23.3;cmake 将在内部将 CODE_SIGN_IDENTITY 设置为“-”。在 v3.23.3 之前,尝试设置 CODE_SIGN_IDENTITY="-" 仍会产生空标识错误。