Skip to content

DragonStorm97/cmake_cpp_project_generator

Repository files navigation

C++ Project Template

Basically just this: catch2-examples

To-Do

  • NB: we need to actually get tests to import the bloody app they're supposed to be testing!
  • Update setup.sh
    • Single vs multi-binary test output
    • Some menu for adding more project libraries?
    • Some menu for adding more dependencies?
    • Some way to set output directory
  • make fetchcontent-able
  • Refine cicd workflow preset
  • update cicd build-and-test workflow to use a matrix
  • Add Code Coverage to the GitHub workflow
  • CPack/Packaging workflow
  • Extra Libraries (toggled with flags, and using emscripten ports where possible)
  • Ability to add more libraries? (maybe one primary shared library, then multiple private, or remove public include and have each library be shared? BAD might accidentally make libraries depend on each other)
  • Actually enable the sanitizers/StaticAnalyzers in builds
    • clang-tidy?
    • cppcheck?
  • CMAKE_PROJECT_NAME(top level project name) vs PROJECT_NAME(name given with the project setting)!
  • PLATFORM (from raylib): enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi;DRM;SDL" "Platform to build for.")
  • copy resources to build directory (so that tests using resources will work too)

Features

  • Project, apps, and library names
  • specify cpp version
  • source as lib or app
    • have the templates in src/REPLACE_ME_LIB_NAME and src/REPLACE_ME_APP_NAME
    • include/ folder
  • GitHub Actions Workflow
  • compile_commands.json (make sure it's generated) OR clang options file
  • make app folder actually be apps folder, then build them each as independent executables!
  • Add emscripten as a dependency if PLATFORM==Web
  • Copies and packages files in a resource/ folder under each app, and the project root (with wasm support)

CMake vars

  • {{REPLACE_ME_PROJECT_NAME}}_ENABLE_RAYLIB
  • {{REPLACE_ME_PROJECT_NAME}}_ENABLE_GLOBS Set if we just want to use the default templated CMakeLists.txt to glob all source files under their directory.
  • {{REPLACE_ME_PROJECT_NAME}}_ENABLE_CATCH2_TESTS
  • {{REPLACE_ME_PROJECT_NAME}}_ENABLE_FLECS

Tests

Tests are run as one executable for app and another for library.

Source

Gitea/GitHub Actions (Workflow)

with CTest

Building and Compiling

  • ./setup.sh
  • cmake --preset=default -DCMAKE_BUILD_TYPE=Debug -DENABLE_CATCH2_TESTS=ON -DENABLE_GLOBS=ON add {{REPLACE_ME_PROJECT_NAME}}_ before the opts
  • cmake --build ./build/default
    • ninja -C build/default -j 24
  • cd build/default && ctest -C Debug --output-on-failure --verbose
  • or just: cmake --workflow --preset=default -DENABLE_CATCH2_TESTS=ON -DENABLE_GLOBS=ON

Project Structure

  • include/project_name The public include folder for the library
    • project_name
      • app The main executable for the project (Could just be a demo app for the library)
        • include private includes for the App.
        • src App source files.
        • tests Catch2 test sources for the App.
      • library The main library for the project.
        • include private includes for the Lib.
        • src Lib source files.
        • tests Catch2 test sources for the Lib.

About

Personal CMake project generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published