cmake ed

Table of Contents

Basics ed

project
project(<project>)
# or
project(<project> VERSION 1.0)
cmake_minimum_required(VERSION 3.10)
# c++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
Creates variables

executable
add_executable(<target> a.cpp b.cpp ...)

link
target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> <item>...)
item:options:

configure file
configure_file(config.h.in config.h)
Replaces @<project>_VERSION@ by 1.0

include
include(<file>)
# or
include(<module>)
  • stops and processes the sub CMakeLists.txt

subdirectory
add_subdirectory(<source-dir>)
# or
add_subdirectory(<source-dir> <binary-output-dir>)
  • stops and processes the sub CMakeLists.txt

find
find_package(<package> [REQUIRED] [QUIET])
  • creates variable <package>_FOUND

Categories: Programmieren