A starting point for a new CMake-based C++ project.
The following dependencies are mandatory:
- C++ compiler
- CMake (3.12 or greater)
The following dependencies are optional:
Example snippet for building this project:
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX="/apps/CXXTemplate/" ..
cmake --build . -- VERBOSE=1 -j8 all test install
CMake options for configuring this project:
CMake Variable name | Description | Default |
---|---|---|
BUILD_TESTING |
Enable automated testing. | OFF |
BUILD_DOCUMENTATION |
Build documentation. | OFF |
To use this template:
- Create a new repository using CXXTemplate as the selected template project.
- Replace occurances of "CXXTemplate" with the new project name:
find . -name ".git" -prune -o -type f -exec sed -i "s/CXXTemplate/YOUR_PROJECT_NAME/g" {} +
- Remove any un-wanted source directories or files (such as the example library and programs under
src/
).
Convenience functions and macros are available to build libraries, documentation, programs, tests, or export the project:
cpp_library
Example usagecpp_executable
Example usagecpp_test
Example usageexport_project
Example usage
See cmake/macros for available tools.