This is a starter C++ project that demonstrates a clean, modern project structure using CMake for building and GoogleTest for unit testing.
- CMake Build System: Uses modern CMake practices for a cross-platform build experience.
- Unit Testing: Integrated with GoogleTest for easy and robust testing.
- Structured Layout: Separates source code, header files, and tests for better organization.
The project follows a standard directory layout:
test-hello/
├── CMakeLists.txt
├── README.md
├── include/
│ └── functions.h
├── src/
│ ├── functions.cpp
│ └── main.cpp
└── test/
└── main_test.cpp
- A C++17 compliant compiler (e.g., GCC, Clang, MSVC).
- CMake (version 3.16 or higher).
To compile and run this project, follow these steps from the project's root directory (/home/rajat/vector/test-hello).
First, create a build directory and run CMake to configure the project. This only needs to be done once, or whenever you change CMakeLists.txt.
cmake -B buildCompile the source code to create the executables.
cmake --build buildThe main executable hello will be located in the build directory.
./build/helloTo run the tests, navigate into the build directory and use ctest. The --verbose flag provides more detailed output.
cd build
ctest --verbose