You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级macOS 11.6/Xcode 13.0后CMake构建Xcode项目时编译器无法识别问题求助

CMake fails to detect C/C++ compilers after updating macOS 11.6/Xcode 13.0 (Anaconda conflict suspected)

I've been using CMake to build Xcode projects for years, but after recently updating to macOS 11.6 and Xcode 13.0 (with Command Line Tools 13.0), CMake suddenly stopped working entirely. I've already tried several troubleshooting steps to avoid redundant suggestions:

  • Ran sudo xcode-select --reset with no effect;
  • Manually specified CMake variables like cmake .. -DCMAKE_C_COMPILER="/usr/bin/cc", but the CMakeError.log still shows "Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.";
  • Tested multiple C compiler locations on my system (including clang), none worked;
  • Reset CC, CXX, CLANG and other environment variables to different paths, the problem persists.

I suspect this issue is related to my installed Anaconda, so I created a minimal test project to isolate the problem:

Test Project Files

main.cpp

#include <iostream>
int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.14)
project(untitled)
set(CMAKE_CXX_STANDARD 11)
add_executable(untitled main.cpp)

Command Execution & Error Output

When running cmake .. -G Xcode in the project's build subdirectory, I get the following error:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_CXX_COMPILER could be found.

-- Configuring incomplete, errors occurred!
See also "../Test/build/CMakeFiles/CMakeOutput.log".
See also "../Test/build/CMakeFiles/CMakeError.log".

Key Content from CMakeError.log

The opening lines of CMakeError.log reveal the critical issue:

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: 
Build flags: -march=core2;-mtune=haswell;-mssse3;-ftree-vectorize;-fPIC;-fPIE;-fstack-protector-strong;-O2;-pipe;-isystem;/opt/anaconda3/include
Id flags: 
The output was: 65
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

note: Using new build system
note: Planning
note: Analyze workspace
...
clang-10: error: invalid Darwin version number: macos11.3
clang-10: error: invalid version number in '-target x86_64-apple-macos11.3'
...

It looks like the clang-10 version from Anaconda is failing to handle the macOS 11.3 version number, since older Anaconda clang builds don't support newer macOS version number formats. How can I resolve this conflict and get CMake to properly use the compiler bundled with Xcode?

内容的提问来源于stack exchange,提问作者RBM

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 17:39:09