下载地址
./bootstrap make sudo make install //验证版本 cmake --version
|
首先我们编写一个main.cpp文件,一个简单的helloworld程序
#include<iostream> int main() { std::cout<<"hello world!"<<std::endl; return 0; }
|
然后编写CMakeLists.txt文件
cmake_minimum_required(VERSION 2.8) #工程名 project(HELLOWORLD) #包含原程序,即把给定目录下的源程序复制给变量DIR_SRC #将指定路径下的源文件储存在指定的变量中 aux_source_directory(DIR_SRC ./) #生成程序 add_executable(helloworld ${DIR_SRC})
|
编译
$mkdir build $cd build $cmake .. $make $./helloworld
|