课题
我们希望使用CMake将以下源代码编译为单个可执行文件
#include <cstdlib>
#include <iostream>
#include <string>
std::string say_hello() {
return std::string("Hello, CMake world!");
}
int main() {
std::cout << say_hello() << std::endl;
return EXIT_SUCCESS;
}
具体实施
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(recipe-01)
add_executable(hello-world "hello.cpp")
你答对了吗?
Tips: cmake -H. -Bbuild -H 表示当前目录中搜索根 CMakeLists.txt 文件 -Bbuild 告诉CMake在一个名为 build 的目录中生成所有的文件
Come on! We'll get on all fours And then we will crawl in the grass Until lost in my mind