官网教程:https://cmake.org/cmake/help/latest/guide/tutorial/index.html#
永远需要记住,第一手资料永远是重要的!
A Basic Starting Point (Step 1)
一个简单的起点
对于一个简单的项目,一个三行的CMakeLists.txt文件就能搞定。创建一个CMakeLists.txt文件在项目路径下。CMakeLists.txt内容如下:
cmake_minimum_required(VERSION 3.10) # set the project name project(Tutorial) # add the executable add_executable(Tutorial tutorial.cxx)
Note that this example uses lower case commands in the CMakeLists file. Upper, lower, and mixed case commands are supported by CMake. The source code for tutorial.cxx
is provided in the Step1
directory and can be used to compute the square root of a number.
这是官网的原话,也是其他中文教程里翻译的内容。即第一个例子是计算平方根的。