cmake -G Xcode .. No CMAKE_C_COMPILER could be found. MAC

使用cmake生成xcode的项目, 报错

➜  build git:(master) cmake -G Xcode ..
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
CMake Error at CMakeLists.txt:37 (project):
  No CMAKE_C_COMPILER could be found.



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

找不到 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER

解决办法:

用xcrun -find c++ 找CMAKE_CXX_COMPILER:

➜  build git:(master) xcrun -find c++
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++

用xcrun -find cc 找CMAKE_C_COMPILER:

➜  build git:(master) xcrun -find cc
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

然后执行 cmake -G Xcode .. 时, 指定编译器地址即可

cmake -G Xcode ..  -D CMAKE_C_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -D CMAKE_CXX_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容