CMake
CMake 是由美国软件工程师 Bill Hoffman 开发的跨平台自动化构建系统,最初版本发布于 2000 年,使用 C++ 编写并采用自由软件许可;其设计初衷是为 ITK 项目提供构建支持,后逐渐成为广泛使用的构建工具,支持生成多种平台下的原生构建文件(如 Makefile、Visual Studio 工程等),由 Kitware 公司维护并持续开发。
Integrate with VSCode
extensions for CMakeLists.txt
- ms-vscode.cmake-tools: project build
- twxs.cmake: colorize, auto-completion, quick help
- xaver.clang-format: formatter
Hello world
Folder layout: forfiles hello/
text
.vscode/
build/
"CMakeLists.txt
src/main.cCMakeLists.txt
cmake
cmake_minimum_required(VERSION 3.20)
project(
hello
VERSION 25.10.31
LANGUAGES C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_TYPE Debug)
add_executable(hello src/main.c)Build it
shell
mkdir build
cmake -G "Visual Studio 14 2015" -A x64 -B build
cmake --build build修改编译器为 gcc,配置 Debug 为 Release,重新编译
shell
rmdir /Q /S build
cmake -G "Unix Makefiles" -DDCMAKE_C_COMPILER=gcc -B build
cmake --build build --config ReleaseFAQs
disable VxKex for cmake on win7
cmake.exe - properties
- Advanced options - Disable VxKex for child processes
