流程
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下的文件