This is a minimal cross-platform C++17+ project template using CMake. It's designed as a professional-grade starting point for C++ projects, especially useful for beginners and intermediate developers who want a simple, clean build system.
This template is configured for C++ projects only (LANGUAGES CXX). It does not support C, Python, or other languages.
- Cross-platform (Linux, macOS, Windows)
- Minimal
main.cppentry point - Clean, modern CMake build system
- Commented lines to support future scaling
- Organized layout:
src/,include/,external/,assets/ - Compatible with language servers (e.g., Clangd)
cpp-template/
+-- CMakeLists.txt # Top-level build config
+-- README.md # Project documentation
+-- LICENSE # MIT License
+-- .gitignore # Ignores build files, binaries, and metadata
+-- src/ # Source files (main.cpp entry point)
+-- include/ # (Optional) Public headers
+-- external/ # (Optional) Vendored third-party libraries
+-- assets/ # Images, diagrams, or documentation media
+-- build/ # CMake build output (ignored by Git)
git clone https://github.com/<your-username>/cpp-template.git
cd cpp-templateEdit CMakeLists.txt and change this line:
project(<your_project_name> LANGUAGES CXX)To something like:
project(my_app LANGUAGES CXX)This sets the name of the compiled binary (e.g., ./my_app).
Write your code in src/main.cpp, or expand the src/ directory with additional .cpp files.
You can also place public headers in the include/ directory if needed.
You can link libraries one of two ways:
If a library is installed via your system's package manager (dnf, apt, brew, etc.), you can use:
find_package(library_name REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE library_name::library_name)Replace library_name with the name of the library and CMake target. Replace ${PROJECT_NAME} with your actual project name.
To keep everything local to your project, you can clone the library source into external/:
git clone --depth 1 https://github.com/your/library.git external/library_nameThen add this to CMakeLists.txt:
add_subdirectory(external/library_name)
target_link_libraries(${PROJECT_NAME} PRIVATE library_name::library_name)Repeat this pattern for any additional libraries you want to include locally.
Once you've written or updated your code in src/, you can build and run it:
mkdir build
cd build
cmake ..
make
./my_app # Replace with your actual binary nameThis project is licensed under the MIT License. See LICENSE for details.
