Boilerplate for establishing a new C++ project using CMake.
-
Add a
your-project-name
directory to the include and src directories, this is where you will put your.hpp
and.cpp
files respectively. -
Add at least one source file to be compiled.
-
Add the source files to the
${LIB_NAME}
target in theadd_library
call of the root CMakeLists.txt. -
Add additional tests as
.cpp
files under thetest
directory. Update the${ALL_TESTS}
variable to include the name/path of the new test, without the.cpp
extension. -
Build with
cmake .
orcmake . -GNinja
to use ninja instead.
Tests use the gtest framework. If gtest is not installed on your system, tests will not be enabled.
- If built with
make
, tests can be ran withmake test
. Verbose tests can be ran withctest --verbose
. - If built with
ninja
, tests can be ran withninja test
.