CMake는 다양한 빌드 작업을 수행하기 위한 명령어들을 제공한다. 아래는 자주 사용되는 주요 CMake 명령어들과 그 설명이다.

project

project(<name> [LANGUAGES <languages>])

add_executable

add_executable(<name> [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] <source1> [source2 ...])

add_library

add_library(<name> [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] <source1> [source2 ...])

target_link_libraries(<target> [item1 [item2 [...]]])

set

set(<variable> <value> [CACHE <type> <docstring> [FORCE]])

find_package

find_package(<package> [version] [EXACT] [QUIET] [REQUIRED] [components...])

include_directories

include_directories([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...])

add_subdirectory

add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL])

message

message([<mode>] "message text" [...])

if / elseif / else / endif

if(expression) ... [elseif(expression) ...] [else() ...] endif()

foreach / endforeach

foreach(loop_var [items]) ... endforeach()

while / endwhile

while(condition) ... endwhile()

configure_file

configure_file(<input> <output> [COPYONLY] [ESCAPE_QUOTES] [@ONLY])

install

install(TARGETS targets... [EXPORT export-name] [RUNTIME|LIBRARY|ARCHIVE|FRAMEWORK|BUNDLE|PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE] [DESTINATION <dir>] [...])

cmake_minimum_required

cmake_minimum_required(VERSION version [...])

list

list(<operation> <list> <args>...)


관련 자료: