CMake - Installation On Windows
Here is a quick way to get started into development with CMake on Windows x64.
1. Getting Started
1.1. Downloads
1.2. Installation
- Install CMake in
C:\Program Files\Cmake
. - Copy the
minGW64
folder intoC:\
. - Add the following binary paths to the
PATH
variable:C:\minGW64\bin
C:\Program Files\Cmake\bin
1.3. First Project
- The simplest project to build is a
Hello world
program. Hence we will add amain.cpp
source:
#include <iostream>
int main() {
std::cout << "Hello World!\n";
return 0;
}
- The corresponding
cmake
instruction would be the fileCMakeLists.txt
:
cmake_minimum_required(VERSION 3.10)
# Project Name
project(HelloWorld)
# Add an executable with sources
add_executable(
${PROJECT_NAME} main.cpp
)
- To build the project now you should run the following commands
# compile
mkdir build
cd build
cmake .. -G "MinGW Makefiles" # Makefile for minGW
mingw32-make
# clean
cd ..
rmdir /s /q build
2. More
- Check out the CMake Brief reference for an overview of the commands.
- Check out how to integrate various C++ libraries.
- Check out how to publish your own CMake Library professionally.
This post is licensed under
CC BY 4.0
by the author.