____ __ __ _ _ _ _
/ ___| \/ | __ _| | _____ / \ __| | __| | ___ _ __
| | | |\/| |/ _` | |/ / _ \ / _ \ / _` |/ _` |/ _ \| '_ \
| |___| | | | (_| | < __/ / ___ \ (_| | (_| | (_) | | | |
\____|_| |_|\__,_|_|\_\___| /_/ \_\__,_|\__,_|\___/|_| |_|
CMake Addon production ready extension for C/C++ project making it easy to split the project into modules and submodules which are dynamic and static libraries, includes package manager CPM & Conan, doxygen docs system, provides useful build/install systems and test system.
- Standardize of the C/C++ project structure
- Reduce the number of instructions for building a project
- Improve the internal organization of the project
- Improve support for modern coding standards
- Improve module reusability
- Improve convenience TDD
- Improve CPack integration
- Improve library & executable versioning
- Make it easy to set up a project building & installation
- Add support for auto-generated documentation
- Add capability for dockerization
- Add automated formatting of C/C++ & CMake code (integrate clang-format & cmake-format)
- Add CMake & pkg-config integration
- Use improved package manager Conan
<library-name> # library that application uses
├── include # library definitions
| └── <library-name> # definition namespace
| ├── header.h(pp)
| └── ...
├── src # source code
| ├── source.c(pp)
| └── ...
├── tests # unit tests
| ├── main.cpp
| └── test_***.cpp # expected source files with `test_` prefix
└── CMakeLists.txt # expected `create_module` function
- Name of module will be equal to
- CMakeLists.txt contains module declaration
- Module should contain following dirs:
- include
- include/
- src
- tests
- version.h.in contains module version macros that can be used to identify version of module
create_module(
TYPE library_static # or library (shared), or executable
VERSION 0.0.1
DESCRIPTION Logging module
DEPENDENCIES CONAN_PKG::magic_enum # libraries that links to module
EXPORT # make sense only for libraries
CMAKE NO # install module and export binaries via cmake
PKGCONF YES # install module and export binaries via pkg-config
)
- Module TYPE divides into 3 types: library (shared library, DLL), library_static (static library), executable (ELF, EXE)
- VERSION helps to identify version of every single module
- DESCRIPTION used to generate description for package
- DEPENDENCIES links other modules & libraries to current module
- EXPORT label generates CMake & pkg-config files that helps
to find packages and single components
- CMAKE label exports module as CMake package
- PKGCONF label exports module as pkg-config package
- Recommended to use cmake addon as a git submodule
git submodule add https://github.com/edelwud/cmake-addon cmake
- Need to add
cmake/main.cmake
file to root CMakeLists.txt file
include(cmake/main.cmake)
- Recommended to use CMake
initialize_project
function in root CMakeLists.txt file
initialize_project(${CMAKE_CURRENT_SOURCE_DIR})
<application-name>
directory in root should contain executable module,libs
directory in root should contain library modules which includes into project withadd_subdirectory
function
LICENSE GPL-3.0