Skip to content

Latest commit

 

History

History
28 lines (25 loc) · 1023 Bytes

cmake.md

File metadata and controls

28 lines (25 loc) · 1023 Bytes

Getting Started with CMake

CMake is a build system for C, C++ and more, which works on any major operating system and has integration in most IDEs. It is the most common cross-platform build system for C and C++ projects.

Basic CMake C++ 17 Project

cmake_minimum_required(VERSION 3.5)
project(stuff)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_executable(my_exe main.cpp util.cpp util.h)

Building CMake Projects

cmake -E make_directory build # or use mkdir
cmake -B build # -G for custom generator
cmake --build build # output is now in build/
build/my_exe # run (file suffix may vary)

Also See

Installing CMake
Latest CMake Documentation
Introduction to modern CMake
<:stackoverflow:874353689031233606> Difference between using Makefile and CMake [...]