This is a modern CMake template, which contains a single library.
- Test with GoogleTest
- Benchmark with Google benchmark
- Code formatting with ClangFormat
- Simple installing and exporting
- CMake (version 3.14 or later)
- C++ Compiler (such as GCC, Clang or MSVC)
Clone the repository
$ git clone https://github.com/paakmau/modern-cmake-template
Navigate to project directory.
$ cd modern-cpp-template
Create a directory for build, and then navigate to it.
$ mkdir build
$ cd build
Generate the project buildsystem.
$ cmake .. -DCMAKE_BUILD_TYPE=Release
Build the project.
$ cmake --build . --config Release
Run tests.
$ ctest
The project can be installed as follows.
$ cmake --install . --config Release
There're two ways to import this library.
Copy the whole project to a directory used for placing external dependencies, such as extern
.
Put a add_subdirectory(modern-cpp-template)
in CMakeLists.txt
.
The library can be linked like target_link_libraries(<Other Target> PRIVATE Demo::Demo)
.
Install the library as described above.
Put a find_package(Demo 0.0.1 REQUIRED)
in CMakeLists.txt
.
Link the library like target_link_libraries(<Other Target> PRIVATE Demo::Demo)
.