1,创建文件夹 lession_1
2,在文件夹编写两个文件 main.cpp CmakeLists.txt 文件内容分别是:
#include <stdio.h>
int main()
{
printf("hello world. \n");
}
cmake_minimum_required (VERSION 2.6)
PROJECT (HELLO)
SET(SRC_LIST main.cpp)
MESSAGE(STATUS "This is BINARY dir" ${HELLO_BINARY_DIR})
MESSAGE(STATUS "This is SOURCE dir" ${HELLO_SOURCE_DIR})
ADD_EXECUTABLE(hello ${SRC_LIST})
3,cd到lession_1目录下执行以下指令:
cmake.
make
4,基本语法如下
PROJECT(projectname [CXX] [C] [Java])
SET(VAR [VALUE] [CACHE TYPE DOCSTRING [FORCE]])
MESSAGE([SEND_ERROR | STATUS | FATAL_ERROR] "message to display"...)
5,总结,这种方式叫内部构建。