I have a lot of side projects, most of which are written in C and C++. They are small and fun… at least until they are not. As development progresses, it is getting more and more difficult to manage all project interconnections – and this sucks all the fun out. To fix this problem, I decided to create a CMake module that would help me manage the sources and maintain the project in a manageable way. I took ideas that I read in the book Clean Architecture by R.C.Martin and tried to create a tool that would operate with the main concept from the book – components, individually- buildable units.
Table of Contents
What is it?
abcmake or Andrei’s Build CMake subsystem is a CMake module providing a set of functions focused on working with a project as a set of components – individually buildable units. It works with sources as with a set of interconnected components. It allows the registering of several components and makes them accessible by other components via Project Name. If you don’t need some complex directory structure all the headers, sources, and other components will be discovered and linked automatically:
Default project structure
-------------------------
+[Root Project]
|
|--+[components] <------- nested abcmake projects
| |
| |--+[component1]
| | |---[include]
| | |---[components]
| | |---[src]
| | |---ab.cmake
| | '--CMakeLists.txt
| |
| |--+[component2]
| ...
|
|---[include] <---- public headers
|---[src] <-------- src and private headers
|---ab.cmake
'--CMakeLists.txt
The module consists of 4 functions:
add_main_component
add_component
register_components
target_link_components
The main component – is an executable, and the rest – are libraries. It provides a clean and understandable output, so I know what exactly components I’m linking:
Sources and Examples
Detailed descriptions with examples and Quick Start are available in the repository: