{"id":14449547,"url":"https://github.com/MhmRhm/SeeMake","last_synced_at":"2025-08-28T03:31:55.806Z","repository":{"id":255094881,"uuid":"848524654","full_name":"MhmRhm/SeeMake","owner":"MhmRhm","description":"A feature-packed, ready-to-use CMake template with testing, static and dynamic checks, coverage reports, and a tutorial.","archived":false,"fork":false,"pushed_at":"2025-03-02T02:36:43.000Z","size":56,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-19T21:50:08.402Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MhmRhm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-27T23:26:29.000Z","updated_at":"2025-04-16T23:00:21.000Z","dependencies_parsed_at":"2024-08-28T00:46:51.561Z","dependency_job_id":"cf5ebac6-e933-4ee4-814b-3322b6cae2c6","html_url":"https://github.com/MhmRhm/SeeMake","commit_stats":null,"previous_names":["mhmrhm/seemake"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MhmRhm/SeeMake","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MhmRhm%2FSeeMake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MhmRhm%2FSeeMake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MhmRhm%2FSeeMake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MhmRhm%2FSeeMake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MhmRhm","download_url":"https://codeload.github.com/MhmRhm/SeeMake/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MhmRhm%2FSeeMake/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272430634,"owners_count":24933899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-01T08:01:21.448Z","updated_at":"2025-08-28T03:31:55.795Z","avatar_url":"https://github.com/MhmRhm.png","language":"CMake","readme":"# SeeMake\n\nA feature-packed, ready-to-use, cross-platform CMake template with testing,\nstatic and dynamic checks, coverage reports, and more.\n\nThis template comes with a [tutorial](https://mhmrhm.github.io/tutorials/posts/see-make/)\nand a [working example](https://github.com/MhmRhm/FTowerX), so be sure to read on.\n\n1. [Included Features](#included-eatures)\n2. [Before You Begin](#before-you-begin)\n3. [Using Dev Containers](#using-dev-containers)\n4. [Setting Up Linux](#setting-up-linux)\n5. [Setting Up Windows](#setting-up-windows)\n6. [Setting Up Mac](#setting-up-mac)\n7. [Final Step](#final-step)\n8. [First Step](#first-step)\n\n## Included Features:\n\n- **Well-Structured and Easy to Extend**: The template is organized for easy\ncustomization and expansion.\n- **One-Command Workflow**: Configure, build, test, and package your project with\na single command.\n- **Minimal Demo Code**: Includes examples to build an object library, one static\nand one shared library, and an executable that links against them.\n- **Out-of-the-Box Support**: Comes with GoogleTest, Google Benchmark, and\nBoost.Test, with demo code for each.\n- **Simple Dependency Management**: Most dependencies are fetched using CMake's\nFetchContent, so there's no need to manually build and install Boost or Google\nlibraries.\n- **Static and Dynamic Checks**: Uses Memcheck and Cppcheck to perform dynamic\nand static checks.\n- **Git Information**: Easily include Git details like commit hash and branch\nname in your binary.\n- **Automated Coverage Reports**: Generates test coverage reports automatically.\n- **Automated Documentation**: Generates documentation with UML diagrams\nautomatically.\n- **Code Formatting**: Automatically formats and styles your code before each\nbuild.\n- **Easy Installation**: Install targets with a single command, with well-defined\ninstall targets and demo code.\n- **Simple Packaging**: Create installers and packages for your libraries and\nexecutables with one command.\n- **CMake Config Files**: Generates CMake config files so others can easily link\nagainst your project.\n- **Cross-Platform Support**: All that on Windows, Linux and macOS!\n(Dynamic checks for macOS is still a work in progress)\n\nThis work is based on material from\n[Modern CMake for C++](https://github.com/PacktPublishing/Modern-CMake-for-Cpp)\nby Rafał Świdziński, which is licensed under the MIT license. It is one of the\nmost useful books I have read.\n\nFor those using this template who want a deeper understanding, I’ve provided a\ntutorial on this template at\n[DotBashHistory](https://mhmrhm.github.io/tutorials/posts/see-make/).\nI highly recommend that you review the tutorial or at least examine each file in\nthis template to understand them. You will likely need to modify these files at\nsome point.\n\nI also have another project that implements the Model-View-Controller (MVC)\ndesign pattern, using this template as a foundation. You can check it out in\naction [here](https://github.com/MhmRhm/FTowerX).\n\n## Before You Begin\n\nI assume you will read this file in full before building the template. Below, I\nwill outline the necessary steps to prepare your system for the build.\n\nBefore continuing, note that this template uses CMake's FetchContent to include\nmost dependencies. For large repositories like Boost, this process can take some\ntime.\n\nModify the `test/CMakeLists.txt` to enable Boost:\n\n```diff\n--- a/test/CMakeLists.txt\n+++ b/test/CMakeLists.txt\n@@ -1,4 +1,4 @@\n include(Testing)\n \n add_subdirectory(libsee)\n-# add_subdirectory(see)\n+add_subdirectory(see)\n```\n\nIf you clean the build directory by running for example:\n\n```bash\ncmake --build --preset linux-default-release --target clean\n```\n\nor by deleting the `CMakeCache.txt` file, the next build will not trigger\nFetchContent. However, if you delete the entire build directory, the dependencies\nwill be downloaded again. For large libraries, you might consider building them\nseparately and then linking against them to avoid long download times. The latest\nversion of CMake provides improved output during the content fetching process.\n\nI've noticed that sometimes tests aren't discovered automatically when running a\nworkflow for the first time using the VSCode CMake extension. If this happens,\ntry running the configuration and build steps separately.\n\n```bash\ncmake --list-presets\ncmake --preset linux-default-release\n\ncmake --build --list-presets\ncmake --build --preset linux-default-release\n```\n\nGenerating test coverage reports requires debug symbols, so coverage targets\nwon't build for Release configurations.\n\nKeep in mind that on Windows, the file path length cannot exceed 260 characters.\nTo avoid issues, avoid using lengthy folder names.\n\nOne last thing, I've encountered a situation on Windows where having Strawberry\nPerl installed can interfere with or disable Cppcheck. Just something to keep in\nmind.\n\n## Using Dev Containers\n\nThe easiest way to use this template is by installing the VSCode's Dev\nContainers extension and opening the project directory in it.\n\nEverything will work out of the box except for `cmake/BuildInfo.cmake`. Running\na `git status` command will indicate this issue. To fix it, simply run the\nfollowing command inside the container terminal:\n\n```bash\ngit config --global --add safe.directory /workspaces/SeeMake\n```\n\nThat's it! You can start developing.\n\n## Setting Up Linux\n\nTo get started, you'll need to install Git and CMake. You can install CMake\neither from the default repositories or by adding the Kitware repository, which\nprovides the latest CMake versions.\n\nFor the latest version of CMake, visit the\n[Kitware APT Repository](https://apt.kitware.com).\n\nTo install CMake and Git from the repositories, run:\n\n```bash\nsudo apt-get install git cmake\n```\n\nNext, install the compiler and debugger by running:\n\n```bash\nsudo apt-get install build-essential gdb\n```\n\nThis template includes a `CMakePresets.json` file with predefined workflows. To\nstart, run the following command and review the output. If any packages are\nmissing, you can install them, clean the build, and repeat the process:\n\n```bash\ncmake --workflow --list-presets\ncmake --workflow --preset linux-default-release\ncmake --build --preset linux-default-release --target clean\n```\n\nIn CMake, a workflow combines configuration, building, testing, and packaging\nsteps. The command above executes all these steps in one go.\n\nTo install all necessary packages, use:\n\n```bash\nsudo apt-get install doxygen graphviz mscgen dia\nsudo apt-get install clang-format\nsudo apt-get install valgrind gawk\nsudo apt-get install cppcheck\nsudo apt-get install lcov\n```\n\nThe following tools are used in this project:\n\n- **Doxygen** and **Graphviz**: Generate project documentation with UML graphs.\n- **Clang-Format**: Automatically applies standard formatting to the files.\n- **Valgrind**: Checks for memory leaks during tests.\n- **Cppcheck**: Performs static analysis to find potential bugs.\n- **Lcov**: Generates coverage reports for tests in Debug.\n\nMany of these reports are available in HTML format and can be easily served. To\nserve a report, navigate to the corresponding directory and run:\n\n```bash\npython3 -m http.server \u003cport-number\u003e\n```\n\nThen, open the provided address in your browser to view the report.\n\nExamples:\n\n1. **Documentation**:\n   ```bash\n   cmake --build --preset linux-default-debug --target doxygen-libsee_static\n   cd ../SeeMake-build-linux-default-debug/doxygen-libsee_static/\n   python3 -m http.server 8172\n   # Go to localhost:8172 in your browser to view the documentation\n   ```\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://i.postimg.cc/rsvX50sQ/temp-Image-T6-RQPP.avif\" alt=\"Documentation\"\u003e\u003c/img\u003e\u003c/p\u003e\n\n2. **Memory Check Report**:\n   ```bash\n   cmake --build --preset linux-default-debug --target memcheck-google_test_libsee\n   cd ../SeeMake-build-linux-default-debug/valgrind-google_test_libsee/\n   python3 -m http.server 8172\n   # Go to localhost:8172 to view the test results\n   ```\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://i.postimg.cc/MZ48C45V/temp-Imageg-Xd-Bd-Z.avif\" alt=\"Valgrind\"\u003e\u003c/img\u003e\u003c/p\u003e\n\n3. **Coverage Report**:\n   ```bash\n   cmake --build --preset linux-default-debug --target coverage-google_test_libsee\n   cd ../SeeMake-build-linux-default-debug/coverage-google_test_libsee/\n   python3 -m http.server 8172\n   # Go to localhost:8172 to view the test coverage report\n   ```\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://i.postimg.cc/kGVPVFJ2/temp-Image-GHm5hw.avif\" alt=\"Coverage\"\u003e\u003c/img\u003e\u003c/p\u003e\n\n## Setting Up Windows\n\nSetting up on Windows is quite different from Linux. On Windows, you’ll need to\nmanually find and install the required packages, making sure to add them to your\nsystem's Path. Most software you install will have an option to add it to the\nPath during installation, so no worries there. For any software that doesn't\noffer that option, it's handled in the `CMakePresets.json` file.\n\nThe main task on Windows is to carefully download and install the required\nsoftware to set up this template. If you're developing on Windows on ARM, be sure\nto download the correct binary from the software provider. Some offer custom\nbuilds specifically for ARM architecture.\n\nHere’s the list of software you need to download and install:\n\n1. **[Git](https://git-scm.com/download/win)**: The default settings should be\nfine. I usually change the default branch name to \"main\" and disable Git GUI.\n   \n2. **[CMake](https://cmake.org/download/)**: Ensure that the installer adds CMake\nto the Path.\n\n3. **[Visual Studio 2022](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022)**:\nSelect the \"Desktop development with C++\" option.\n\nThis template includes a `CMakePresets.json` file with predefined workflows. To\nstart, run the following command and review the output. If any packages are\nmissing, you can install them, clean the build, and repeat the\nprocess:\n\n```bash\ncmake --workflow --list-presets\ncmake --workflow --preset windows-default-release\ncmake --build --preset windows-default-release --target clean\n```\n\n4. **[Doxygen](https://www.doxygen.nl/download.html)**: Standard installation.\n\n5. **[Graphviz](https://graphviz.org/download/)**: Make sure you choose the\noption to add this to the Path.\n\n6. **[LLVM](https://releases.llvm.org/download.html)**: There are many options.\nFor my Windows VM on Apple Silicon, I chose `LLVM-18.1.8-woa64.exe`. This package\ninstalls `llvm-cov`, `clang-format` and Clang compilers. Make sure you select the\noption to add it to the Path. On Windows coverage reports are available only with\n`windows-clang-debug` preset.\n\nTo generate coverage reports on Windows:\n\n```bash\ncmake --build --preset windows-clang-debug --target coverage-google_test_libsee\ncd ../SeeMake-build-windows-clang-debug/coverage-google_test_libsee/\npython3 -m http.server 8172\n# Go to localhost:8172 to view the test coverage report\n```\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://i.postimg.cc/pyMHjh1R/temp-Image-Pk-EGql.avif\" alt=\"Coverage\"\u003e\u003c/img\u003e\u003c/p\u003e\n\n7. **[Cppcheck](https://cppcheck.sourceforge.io/)**: Standard installation.\n\n8. **[NSIS](https://nsis.sourceforge.io/Download)**: Standard installation.\n\n9. **[Ninja](https://ninja-build.org/)**: Copy the executable to\n`C:/Program Files/ninja/`.\n\n## Setting Up Mac\n\nMac support at the moment lacks dynamic checks. To set up Mac for this template,\nfollow these steps (replace the `\u003cuser\u003e` with correct value):\n\n1. **Install Homebrew:**\n\n   Run the following command to install Homebrew, the macOS package manager:\n\n   ```zsh\n   /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"\n   (echo; echo 'eval \"$(/opt/homebrew/bin/brew shellenv)\"') \u003e\u003e /Users/\u003cuser\u003e/.zprofile\n   eval \"$(/opt/homebrew/bin/brew shellenv)\"\n   ```\n\n2. **Install required dependencies:**\n\n   Use Homebrew to install the necessary tools:\n\n   ```zsh\n   brew install git cmake\n   brew install cppcheck\n   brew install clang-format\n   brew install doxygen graphviz\n   ```\n\n3. **Set up LLVM for coverage reports:**\n\n   Since coverage reports require LLVM tools, we need to add them to the system's\n   PATH. You have two options:\n\n   **Option 1: Use LLVM tools without changing the default Apple Clang compiler**  \n   Add LLVM tools (`llvm-cov` and `llvm-profdata`) to the end of your PATH to\n   avoid overriding Apple's Clang compiler. Ensure that the LLVM version matches\n   the default Apple Clang version to avoid compatibility issues:\n\n   ```zsh\n   clang --version\n   brew install llvm@15\n   echo 'export PATH=\"$PATH:/opt/homebrew/opt/llvm@15/bin\"' \u003e\u003e ~/.zshrc\n   ```\n\n   **Option 2: Use LLVM entirely**  \n   If you'd prefer to use the latest LLVM as your default compiler, you can\n   install it and add it to the front of your PATH:\n\n   ```zsh\n   brew install llvm\n   echo 'export PATH=\"/opt/homebrew/opt/llvm/bin:$PATH\"' \u003e\u003e ~/.zshrc\n   ```\n\nMake sure you restart the terminal for the changes in the PATH to take effect.\n\n## Final Step\n\nUse the following commands to see the available presets and build with the one\nthat matches your setup:\n\n```bash\ncmake --workflow --list-presets\ncmake --workflow --preset linux-default-release\n```\n\n## First Step\n\nOne man's final step is another man's first step. After developing your\nlibrary using this template, your users will need to add it as an external\ndependency. One easy way to do this is by using CMake's `FetchContent`. This\ntemplate has already set things up, so your users can add your library like\nthis:\n\n```cmake\n# CMakeLists.txt\ncmake_minimum_required(VERSION 3.30.0)\nproject(Extension VERSION 0.0.0 LANGUAGES CXX)\n\ninclude(FetchContent)\nFetchContent_Declare(Libsee\n    GIT_TAG main\n    GIT_REPOSITORY https://github.com/MhmRhm/SeeMake.git\n)\nFetchContent_MakeAvailable(Libsee)\n\n# or after installation:\n# find_package(libsee)\n\nadd_executable(extension main.cpp)\ntarget_link_libraries(extension PRIVATE see::libsee_shared see::precompiled)\n```\n\nIn their `main.cpp`, they might write:\n\n```cpp\n// main.cpp\n\n#include \u003ciostream\u003e\n#include \u003cformat\u003e\n#include \"libsee/see_model.h\"\n\nint main() {\n  std::cout \u003c\u003c getVersion() \u003c\u003c std::endl;\n}\n```\n\nFinally, they can compile the project easily using the `CMakePresets.json` file\nor setup their own presets:\n\n```bash\ncmake --workflow --preset linux-default-release\n```\n\nThis template works well with the recommended extensions for C++ development in\nVSCode, so be sure to check them out.\n\nThis template is tested on both Linux and Windows. I hope you find this useful.\nPlease feel free to reach out if you have any improvements or suggestions.\n","funding_links":[],"categories":["Recently Updated","Examples / Templates"],"sub_categories":["[Aug 31, 2024](/content/2024/08/31/README.md)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMhmRhm%2FSeeMake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMhmRhm%2FSeeMake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMhmRhm%2FSeeMake/lists"}