CMakeLists.txt文件(1)初步入门

(1)使用CMakeList.txt编译一个程序的基本步骤:

在代码cpp文件以及CmakeLists.txt文件目录下,执行以下指令:

mkdir build
cd build
cmake ..
make

(2)CMakeLists.txt文件的一般格式

举例存在以下helloworld.cpp文件:

#include<iostream>
using namespace std;
int main(int argc,char**argv)
{
    cout<<"Hello world !"<<endl;
    return 0;
}

CMakeLists.txt文件:
 

cmake_minimum_required(VERSION 2.8.3)    #非必须的
project(helloworld)
set(SRC_LIST helloworld.cpp)
message(STATUS "This is BINARY dir"${helloworld_BINARY_DIR})
add_executable(helloworld ${SRC_LIST})

猜你喜欢

转载自blog.csdn.net/liuzubing/article/details/81253219