본문으로 건너뛰기

CMake

설치

asdf plugin add cmake
asdf plugin add ninja

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 -G Ninja -S . -B build
cmake --build build
# cmake --build build --target install
cmake --install build