流程
https://www.jianshu.com/p/4fccc8fc2321
1.準備main.cpp文件
#include <iostream>
int main()
{
printf("hello word!");
return 0;
}
2.編輯CMakeLists.txt
PROJECT(main)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
AUX_SOURCE_DIRECTORY(. DIR_SRCS)
ADD_EXECUTABLE(main ${DIR_SRCS})
3.執行命令:
cmake -G "Xcode" .
存在問題:
轉自:https://www.jianshu.com/p/3d1693a66837
使用cmake生成xcode的項目
cmake .. -G "Xcode"
結果報如下錯誤
-- 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.
後來使用如下命令解決
sudo xcode-select --switch /Applications/Xcode.app/
重試時記得清空build下的文件