haru

CMake Project Generator for C/C++

🥡 張る Haru

🥡 CMake project generator for C and C++

haru can be used to initialise a barebones CMake project.
This initialisation process can be customised by responding to prompts during project initialisation.
These options are further detailed below.
Alternatively leave everything to the default values, which strive to provide a sensible basic project setup.


📌 Features

  • Generate ready-to-go CMakelists.txt
  • Support both C and C++ (or combined) projects
  • Define standard library version for each language
  • Include default formatting and git configuration if desired
  • Include default dependencies if desired
  • Add dependencies at project creation time
  • Add dependencies at project creation time
  • Initialise git repository after project creation
  • Initialise CMake after project creation

💻 Usage

Main two commands to get a new project started are: | Command | Description | |---------- | --------------------------------------------------- | | create | Create a new directory with the name of the project | | init | Initialise a project in the current directory |

Both commands allow using all default values by issuing the flag -d or --use-defaults.
This will skip the configuration section, aside from having to enter the project name when using create.

For create, if a directory already exists with the project name, the project creation will abort by default.
This behaviour can however be overridden with the -f or --force flag to allow overwriting the directory when found.

After this haru will ask you for input about project settings:

OptionDescription
NameName for the project. If run with init will default to PWD
CMake versionMinimum CMake version. Defaults to 3.28
VersionProject version string. Defaults to 0.1.0
LanguagesLanguages to use for project. Allows C, C++ or both. Defaults to C++
StandardStandard library editions. Defaults to C++23 and C17
EntrypointEntrypoint for the project. Defaults to src/main.{c\|cpp}
Default filesDefault files to include, .clang-format etc. Defaults to all
Default dependenciesWhether to add default dependencies. Defaults to yes
DependenciesAdd arbitary dependencies if desired.

📋 Requirements

💻 Using

For general usage, haru is completely self contained in a single binary.
However, a few external tools are used, when present, to make the generated output better.

  • gersemi
    • Runs when .gersemirc is included in project initialisation.
    • Formats all generated CMake files during project setup.
  • clang-format
    • Runs when .clang-format is included in project initialisation.
    • Formats generated entry point source file.
  • git
    • Optionally initialise a git repository after generation
  • cmake
    • Optionally initialise the CMake project after generation

🛠 Building

For building requirements are:

  • C++23 compatible compiler. clang >= 17.0 recommended.
  • cmake >= 3.27
  • xxd is needed to generate .cpp files from the templates in assets/.
Go back