Android ndk uses cmake, Qt6 use cmake by default. It's such an important tool in C++ world now. Let's have a look how to use it.

Quick start

Cmake's configuration is in CMakeLists.txt file

cmake_minimum_required(VERSION 3.5)

project(play-cc LANGUAGES CXX)


add_executable(play-cc src/main.cpp)

Generate a build in folder build with: cmake -B build .

Build with: cmake --build build

Open IDE with cmake --open build

find_package(SDL2 REQUIRED)
target_include_directories(play-cc PRIVATE ${SDL2_INCLUDE_DIR})
target_link_libraries(play-cc PRIVATE ${SDL2_LIBRARY})

Use vcpkg

Use cmake with vcpkg need to include the toolchain file located under your vcpkg installation.


or add command line argument -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake

DEFINE for cmake

target_compile_definitions(main PRIVATE UNICODE FOO=1 BAR=1)

Set arch

Generate a build with cmake -B build . -T host=x64 -A x64

Set build mode

cmake –-build build --config Release

cmake --build build --config Debug