The project provides a set of macros to help bootstrap the creation of new projects.

A typical top level CMakeLists.txt file starts with these lines:

# 1
	cmake_minimum_required(VERSION 3.0.0)
	# 2
	project("ProjName" VERSION "0.0.1" LANGUAGES C CXX)
	# 3
	list (APPEND CMAKE_MODULE_PATH "$ENV{CMAKE_MODULE_PATH}")
	IF(WIN32)
		string(REPLACE "\\" "/" CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}")
	ENDIF()
	# 4
	include(pile_support)

It declares minimum CMake version (1) and provides a name for the project using standard project CMake command (2). This defines following variables with obvious content:

By default Cmake does not inspect the content of CMAKE_MODULE_PATH environment variable, thus forcing the user to employ the -D... command line option. If such an environment variable was defined we can make use of it using script in 3; we take into account the fact that CMake expects it to have forward-slashes as path delimiters even in Windows environments.

Previous point is important because we need a way to find pile_support CMake script (4). It will make sure to include all other CMake helpers provided by the project.


The main part of the top-level CMake script has following format:

pileProject("1")

	pileProjectCommon()

	# add sub-directories here ...
	
	pileProjectEnd()

The pileProject macro adds a number of variables:

PROJECT_NAME:
the name of the project (CamelCased, with spaces)
PROJECT_NAME_UNIX:
the name of the project (low case, no spaces)
PROJECT_NAME_UPPER:
the name of the project (high case, no spaces)
<PROJECT-NAME>_MAJOR_VERSION:
major version
<PROJECT-NAME>_MINOR_VERSION:
minor version
<PROJECT-NAME>_PATCH_VERSION:
pathc/build number
<PROJECT-NAME>_SETTINGS_VERSION:
the version for settings
<PROJECT-NAME>_VERSION:
a string in the form "1.2.3"
TARGET_COMPILER_MSVC:
The compiler to be used is Microsoft compiler?
TARGET_SYSTEM_WIN32:
target system is Windows?
TARGET_SYSTEM_UNIX:
are we targeting unix?
<PROJECT-NAME>_DEBUG:
is this a debug build or a release build?
The module search path is ammended to include a cmake directory at the top level of the hierarchy.

The pileProjectCommon invokes all common macros listed below. The user may choose to use only a subset of these macros.

The pileProjectEnd looks for a configuration file called config.h.in and, if it exists, uses the standard CMake configure_file command on it.
If a Doxyfile.in file exists and the user enabled appropriate option it is also run through same standard mechanism, Doxygeen is located and a target is created for building the documentation.
The macro also includes CPack, so all relevant variables should be assigned values before the invocation.