A basic C++ library template utilizing CMake and Conan.
- 🎣 Dependency management with Conan
- 🍭 Build configuration with CMake
- 🧩 Automatic publishing of artifacts to Artifactory with Github Actions
- 📑 Automatic publishing of Doxygen documentation with Github Actions
- 🚀 Preconfigured for Unit-Testing with Catch2
To use this library in you project, you can install it in the following ways:
# Add artifactory repository as remote:
conan remote add jothepro-conan-public https://jothepro.jfrog.io/artifactory/api/conan/conan-public
# Install a release of `mylibrary`
conan install --remote jothepro-conan-public mylibrary/0.1.7@jothepro/stable
If you don't want to build & run tests when building from source, set the CONAN_RUN_TESTS variable:
install --remote jothepro-conan-public mylibrary/0.1.7@jothepro/stable -e CONAN_RUN_TESTS=0
Pre-Releases are available in the beta
channel:
conan install --remote jothepro-conan-public mylibrary/0.1.8@jothepro/beta
- Conan >= 1.30
- CMake >= 3.15
- Doxygen 1.9.1 (optional)
- Commandline:
# Create build folder for out-of-source build mkdir build && cd build # Install Dependencies with Conan conan install .. # Configure, Build & Test conan build ..
- Clion: Install the Conan Plugin before configuring & building the project as usual.
This template uses Catch2 for testing. The Unit-tests are defined in test
.
- Commandline: To run just the unit-tests, you can run
conan build .. --test
. - CLion: Execute the
MyLibraryTest
target
This template uses Doxygen for documenation.
To generate the docs, run doxygen Doxyfile
or execute the doxygen
target defined in the CMakeLists.txt
.
This template uses Github Actions for automating the release of a new library version.
- The workflow
configureBuildTestCreateAndUpload.yaml
configures, builds, tests the library automatically on each push. When a new release is created in Github, the resulting artifact is automatically uploaded to a public artifactory repository - The workflow
publish-pages.yaml
automatically builds and publishes the documentation to Github Pages when a new release is created in Github.
.
├── CMakeLists.txt (1)
├── Doxyfile (2)
├── LICENSE (3)
├── README.md (4)
├── conanfile.py (5)
├── docs (6)
│ ├── doxygen-awesome-css (7)
│ ├── doxygen-custom (8)
│ │ └── ...
│ ├── example-page.dox (9)
│ └── img (10)
│ └── ...
├── lib (11)
│ ├── CMakeLists.txt (12)
│ ├── src (13)
│ │ └── example.cpp (14)
│ └── include (15)
│ └── MyLibrary (16)
│ └── example.hpp (17)
├── test (18)
│ ├── CMakeLists.txt (19)
│ └── mylibrarytest.cpp (20)
└── test_package (21)
├── CMakeLists.txt (22)
├── conanfile.py (23)
└── example.cpp (24)
- Root
CMakeLists.txt
. Includes Library Sources (11) and unit tests (18). - Doxyfile for documentation generation.
CMakeLists.txt
(1) defines a targetdoxygen
to build the documentation. - License file.
- The Readme you currently read.
- Conanfile. Used to install dependencies & publishing the package.
- Documentation subdirectory. Generated docs will pe placed under
docs/html
. - Submodule containing the custom-css for doxygen.
- Project-specific doxygen customizations.
- Example documentation file. All
.dox
files in this dir will be automatically included in the documentation. - Images for documentation.
- Library sources folder.
CMakeLists.txt
for library.- Source files folder.
- Private source file.
- Public headers folder.
- Library namespace.
- Public header file example.
- Unit tests folder.
CMakeLists.txt
that defines unit tests.- Example unit test file.
- Conan linking test directory.
- CMakeLists.txt that defines an example project that links the library.
- Conanfile that defines linking test.
- Example sources that require the library to build & run successfully.
This template is inspired by these talks: