cmake生成Xcode项目时报错“No CMAKE_C_COMPILER could be found

原因是在命令行xcodeselect指向的是/Library/Developer/CommandLineTools生成xcode项目时,需要xcodeselect指向/Applications/Xcode.app/Contents/Developer

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

参考链接https://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error/17980786#17980786

如果设置xcodeselect之后仍旧报错“No CMAKE_C_COMPILER could be found”, 解决方案是:

cmake ../ -GXcode -DCMAKE_C_COMPILER="$(xcrun -find cc)" -DCMAKE_CXX_COMPILER="$(xcrun -find c++)"

如果CMake的输出log提示下面错误时, 可以通过升级CMake版本解决

error: An empty identity is not valid when signing a binary for the product type ‘Commandline Tool’. (in target ‘CompilerIdCXX’ from project ‘CompilerIdCXX’)”

Xcode 14 beta: CMake not able to resolve CMAKE_C_COMPILER and CMAKE_CXX_COMPILER – Stack Overflow

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注