cmake
1.cmake_minimum_required(VERSION 3.7.1) cmake最低版本 2.project Sets the name of the project, and stores it in the variable PROJECT_NAME . When called from the top-level CMakeLists.txt also stores the project name in the variable CMAKE_PROJECT_NAME . 3.set(SOURCE_FILES main.c) 用 SOURCE_FILES 代替文件main.c 4.message(STATUS "This is BINARY dir " ${PROJECT_BINARY_DIR}) ${PROJECT_BINARY_DIR} :CMakeLists.txt所在目录,在终端会打印如下内容: This is BINARY dir /home/zzz/WorkSpace/Program/learning-cmake/hello-world 5.add_executable(hello-world ${SOURCE_FILES}) hello-world :最后生成可执行文件名称 6.add_subdirectory(src) 添加一个子目录去编译 7