bootstrap/specs/clang/template
Joshua Potter ad6e70f999 Use CMake Doxygen module. (#1)
Use CMake's Doxygen support instead of invoking Doxygen directly. This makes it much clearer what configuration flags are specified that differ from the defaults.

Reviewed-on: #1
Co-authored-by: Joshua Potter <jrpotter2112@gmail.com>
Co-committed-by: Joshua Potter <jrpotter2112@gmail.com>
2024-01-06 18:12:44 +00:00
..
.githooks clang: Migrate to `CMake`, dropping `bear`. 2023-12-19 15:36:21 -07:00
docs Use CMake Doxygen module. (#1) 2024-01-06 18:12:44 +00:00
include Migrate clang project to fuller CMake configuration. 2023-12-21 18:08:21 -05:00
src Migrate clang project to fuller CMake configuration. 2023-12-21 18:08:21 -05:00
test Migrate clang project to fuller CMake configuration. 2023-12-21 18:08:21 -05:00
.clang-format Add clang spec. 2023-11-26 14:51:41 -07:00
.envrc Add clang spec. 2023-11-26 14:51:41 -07:00
.gitignore Use CMake Doxygen module. (#1) 2024-01-06 18:12:44 +00:00
CMakeLists.txt Use CMake Doxygen module. (#1) 2024-01-06 18:12:44 +00:00
README.md Use CMake Doxygen module. (#1) 2024-01-06 18:12:44 +00:00
compile_commands.json Migrate clang project to fuller CMake configuration. 2023-12-21 18:08:21 -05:00
default.nix Add clang spec. 2023-11-26 14:51:41 -07:00
flake.lock Add clang spec. 2023-11-26 14:51:41 -07:00
flake.nix Use CMake Doxygen module. (#1) 2024-01-06 18:12:44 +00:00
main.c Migrate clang project to fuller CMake configuration. 2023-12-21 18:08:21 -05:00

README.md

Clang Flake Template

This is a template for constructing a working environment for C/C++ development with the clang (version 16.0.6) toolchain. direnv can be used to launch a dev shell upon entering this directory (refer to .envrc). Otherwise run via:

$ nix develop

Building

We use CMake (version 3.27.7) to build the project. When first starting the project, we recommend running the following commands:

$ mkdir -p build/{Debug,Release}
$ (cd build/Debug && cmake -DCMAKE_BUILD_TYPE=Debug ../..)
$ (cd build/Release && cmake -DCMAKE_BUILD_TYPE=Release ../..)

This will create a CMake cache file in each subdirectory with the build types set. Now you can build a Debug or Release variant by navigating to the corresponding subdirectory and running:

$ cmake --build .

Language Server

The clangd LSP (version 14.0.6) is included in this flake. The codelldb VSCode plugin is also included to interface with the LSP. Note this plugin, despite its name, is compatible with other editors (e.g. neovim). To configure, refer to your editor's documentation.

To use the LSP across files, a compilation database must be generated. The CMakeLists.txt file already enables this in the Debug configuration type. A top-level compile_commands.json symbolic link already exists and points to this generated database.

Documentation

Documentation is generated using Doxygen (version 1.9.7) through CMake. (Re)generate documentation by navigating to the desired build configuration directory and running:

$ cmake --build .
$ make docs

Testing

We use CTest (version 3.27.7) for unit testing. To run the tests, navigate to build/Debug and type the following:

$ cmake --build .
$ make test

Formatting

Formatting depends on the clang-format (version 14.0.6) tool. Refer to .clang-format for default formatting options. A pre-commit hook is included in .githooks that can be used to format all *.c(pp)? and *.h(pp)? files prior to commit. Install via:

$ git config --local core.hooksPath .githooks/

If running direnv, this hook is installed automatically when entering the directory.