1. 每个文件夹下创建一个CMakeLists.txt
2. CMakeLists.txt 中配置如下内容:
cmake_minimum_required(VERSION 3.10)
project(project_name)
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -o0 -wall -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -o3 -wall")
INCLUDE_DIRECTORIES(需要的头文件)
add_executable(main main.cpp)
target_link_libraries(man 依赖的库) // 注意依赖库的顺序
INSTALL(TARGETS main DESTINATION ${PROJECT_SOURCE_DIR}/Bin)
3. 创建一个单独的build文件夹
cd ./build
cmake -DCMAKE_BUILD_TYPE=Release ..
make install