CMake Generator Documentation
CMake/generator.py is a generator script for ALib CMakeLists.txt
Usage
-
-w --write
: Write files (false by default) -
-m --main
: Generate main CMakeLists.txt -
-p --packages
: Specify packages to build. For multiple packages, use -p multiple times -
--no-deps
: Don't generate dependencies of specified packages. By default, if only some projects are to be built, we compute their dependencies and build them. -
-show-deps
: Only show dependencies of packages selected by-p
. Dont generate. -
-v --version
: Show ALIB version
Example
- Generate whole project (dry run):
./CMake/generator.py -m
- Generate whole project:
./CMake/generator.py -mw
- Generate only projects
alib2std
andalib2measure
and mainCMakeLists
:./CMake/generator.py -mw -p alib2algo -p alib2measure --no-deps
- Generate only project
alib2cli
, its dependencies and mainCMakeLists
:./CMake/generator.py -mw -p alib2cli
How it works
The generator scans source directory of alib.
It looks for file called project.conf
(configurable) inside any subdirectory.
If found, then this subdirectory is a subproject of alib project.
Documentation of conf files
generate.conf
Generator configuration file consists of these sections:
First section is Versioning
. Keys:
-
major
: major version of ALIB -
minor
: minor -
patch
: patch - together they form the version of ALIB, eg. 1.0.1
Second section is General
. Keys:
-
ProjectConfFile
: specifies name of project configuration file -
PathToSources
: Path to ALIB sources root dir, relative to the position ofgenerate.py
Further sections are prefixed with CMake:
.
Section CMake:Sources
. Keys:
-
ExcludeSources
: File extensions which are excluded from project compilation files. -
InstallSources
: File extensions which are included into include sources of project. Can be also 'EMPTY', which means that we want to include files with no extensions likevector
-
SourcesDir
: Path to the project sources. Relative to project root. -
TestSourcesDir
: Path to the sources of test binary. Relative to project root.
Section CMake:Deps:{dep}
. Keys:
- include: what should be specified inside
target_include_directories
. - link: what should be specified inside
target_link_libraries
project.conf
Project configuration file consists of these sections:
First section is General
.
Keys:
-
category
. Acceptable values are defined ingenerate.conf
in the sectionCMake:Categories
. If value is missing or invalid, it is an error.
Second section is Dependencies
.
Keys:
-
project
: List of other ALIB projects that should be regarded as a dependency for this project. CMake is linking these projects. -
system
: List of dependencies outside ALIB project. Elements of this list are configured in sectionCMake:Deps:{key}
either in this project configuration file or ingenerate.conf
.
Section CMake
: For every key:value pair, we generate (SET key value)
to CMakeLists.txt of this project.
Another sections with name CMake:Deps:{key}
are the same as in project.conf
.
If the section is configured here, it has higher priority than the same section in generate.conf
.