Skip to main content

CMake


Installation

Download: https://cmake.org/download

sudo apt install libssl-dev
cd cmake-<version>
./bootstrap \
&& make -j$(expr $(expr $(nproc) \* 6) \/ 5) \
&& sudo make install

Project tree

project
โ”œโ”€โ”€ CMakeLists.txt
โ””โ”€โ”€ main.cpp

CMakeLists.txt

CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
set(PROJECT_NAME "example")
project(${PROJECT_NAME} LANGUAGES CXX)

set(TARGET_NAME "${PROJECT_NAME}_main")

set(SOURCE
"main.cpp"
)

add_executable(${TARGET_NAME} ${SOURCE})

Help

cmake --help-variable CMAKE_SYSROOT_COMPILE
cmake --help-variable-list

Build

cmake -S . -B build
cmake --build build -j$(expr $(expr $(nproc) \* 6) \/ 5)
cmake --install build