认识Make、Makefile、CMake和CMakeLists_海盗的帽子的博客-CSDN博客_makefile和cmakelist
通过 CMakeLists.txt 编译 hello.cpp
>> hello.cpp #include <stdio.h>int main(int argc,char* argcv[]) {int a = 20;int b = 10;printf("%d+%d",a,b);return 0;}>> 在同目录下编写 CMakeLists.txtPROJECT (HELLO)SET(SRC_LIST hello.cpp)MESSAGE(STATUS "this is BINARY dir" ${HELLO_BINDARY_DIR})MESSAGE(STATUS "this is SOURCE dir" ${HELLO_SOURCE_DIR})MESSAGE(STATUS "this is PRPOJECT_SOURCE" ${PRPOJECT_SOURCE_DIR})ADD_EXECUTABLE(hello.out ${SRC_LIST})>> 执行 cmake CMakeLists.txt 生成 Makefile 文件>> 执行 make 命令编译 hello.cpp 生成 hello.o