CMake

Enable Javascript to display Table of Contents.

Base Examples

Typically you have a CMakeLists.txt base file which references to the sub-folders:
cmake_minimum_required(VERSION 2.8)

project(test_project)

# place binaries of all sub-directories in the root directory
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

add_subdirectory(sources)
add_subdirectory(ext_libdate)
Here you can either have libraries, so your CMakeLists.txt could look like this:
# create a library called libdate.a
add_library (date tz.cpp)

# links libcurl to libdate library
target_link_libraries(date LINK_PRIVATE curl)

# adds this folder to the include path (this "date/tz.h" would succeed)
target_include_directories(date PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
Or you will have executables, so CMakeLists.txt could look like this:
# creating executable
add_executable(date_test main.cpp)

# adjust compilation with defines
add_definitions(-DUSE_OS_TZDB=1)

# linking executable with libdate.a
target_link_libraries(date_test LINK_PUBLIC date)
Calling make VERBOSE=1 will show the regular compile output.

Calling cmake -DCMAKE_BUILD_TYPE=Debug .. creates a debug build.

Source: cmake.org