hello world
CMakeLists.txt main.cc
CMakeLists.txt
cmake_minimum_required(VERSION 3.22)
project(
CppProject
VERSION 1.0.0
LANGUAGES C CXX
)
add_executable(Executable main.cc)
빌드 수행
$ cd build
$ cmake ..
$ cmake -S <path-to-source> -B <path-to-build>
$ cmake -S .. -B .
$ cmake ..
- Makefile 생성 확인
--build <위치>
: <위치>에 대해 빌드 수행
make 명령
쓰거나, $ cmake --build .
로 빌드 수행
$ cmake --build .
$ cmake .
: update
CMake project
를 파싱한적 있다면, 아래의 명령으로 업데이트 가능하다.
build $ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dhyang/cpp/build
-G
: Generator 설정
* Unix Makefiles = Generates standard UNIX makefiles.
Ninja = Generates build.ninja files.
Ninja Multi-Config = Generates build-<Config>.ninja files.
Watcom WMake = Generates Watcom WMake makefiles.
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
CodeLite - Ninja = Generates CodeLite project files.
CodeLite - Unix Makefiles = Generates CodeLite project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
Kate - Ninja = Generates Kate project files.
Kate - Unix Makefiles = Generates Kate project files.
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
Sublime Text 2 - Unix Makefiles
= Generates Sublime Text 2 project files.
cd build
cmake -S .. -B . -G "Unix Makefiles"
cmake .. -G "Unix Makefiles"
cd build
cmake -S .. -B . -G "Visual Studio 16 2019"
cmake .. -G "Visual Studio 16 2019"
cd build
cmake -S .. -B . -G "Ninja"
cmake .. -G "Ninja"