cmake_minimum_required(VERSION 3.10)
# set DEBUG
set(CMAKE_DEBUG_POSTFIX d)
SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
# set the project name
project(leetcode VERSION1.0)
# add the executable
add_executable(leetcode main.cpp)
set_target_properties(leetcode PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
来自:https://cmake.org/cmake/help/latest/guide/tutorial/index.html