A modern C++ project template with CMake integration, testing support, and proper packaging. Use this template to kickstart your C++ library development with best practices.
- Modern CMake setup with proper export/import configuration
- FetchContent support for easy integration
- Google Test integration for unit testing
- CPack configuration for multiple platforms
- GitHub Actions CI/CD ready
- Proper library versioning and symbol visibility
- CMake 3.15 or higher
- C++17 compatible compiler
- Git
- (Optional) Google Test for running tests
include(FetchContent)
FetchContent_Declare(
MyProject
GIT_REPOSITORY https://github.com/username/MyProject.git
GIT_TAG v1.0.0 # Specify a version tag
)
FetchContent_MakeAvailable(MyProject)
# Link against the library
target_link_libraries(your_target PRIVATE MyProject::mylib)find_package(MyProject REQUIRED)
target_link_libraries(your_target PRIVATE MyProject::mylib)git clone https://github.com/username/MyProject.git
cd MyProject
mkdir build && cd build
cmake ..
cmake --build .cmake .. -DMYPROJECT_BUILD_TESTS=ON
cmake --build .
ctest --output-on-failure#include <mylib/mylib.hpp>
int main() {
mylib::Calculator calc;
double result = calc.add(5.0, 3.0);
return 0;
}.
├── .github/ # GitHub specific files (workflows, templates)
├── app/ # Example application
├── lib/ # Library source code
│ ├── include/ # Public headers
│ ├── src/ # Implementation files
│ └── cmake/ # CMake configuration files
└── tests/ # Test files
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
- Click "Use this template" on GitHub
- Replace "MyProject" with your project name in:
- CMakeLists.txt files
- README.md
- .github/workflows/ci.yml
- Update library headers and implementation
- Update tests for your functionality
- Update documentation
- Modern CMake practices
- C++ best practices
- GitHub Actions for CI/CD