cmake -G Xcode .. No CMAKE_C_CO
2021-10-11 本文已影响0人
蛋Dan
使用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++