MCPcopy Index your code
hub / github.com/TheLartians/Format.cmake

github.com/TheLartians/Format.cmake @v1.8.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.8.3 ↗ · + Follow
26 symbols 74 edges 2 files 17 documented · 65% updated 18mo agov1.8.3 · 2024-12-29★ 1808 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Actions Status Actions Status

Format.cmake

clang-format and cmake-format for CMake

About

Format.cmake adds three additional targets to your CMake project.

  • format Shows which files are affected by clang-format
  • check-format Errors if files are affected by clang-format (for CI integration)
  • fix-format Applies clang-format to all affected files

To run the targets, invoke CMake with cmake --build <build directory> --target <target name>.

To disable using cmake_format to format CMake files, set the cmake option FORMAT_SKIP_CMAKE to a truthy value, e.g. by invoking CMake with -DFORMAT_SKIP_CMAKE=YES, or enabling the option when adding the dependency (recommended).

To disable using clang_format to format clang-supported files, set the cmake option FORMAT_SKIP_CLANG to a truthy value, e.g. by invoking CMake with -DFORMAT_SKIP_CLANG=YES, or enabling the option when adding the dependency (recommended).

To specify a extra arguments for cmake-format, use the cmake option CMAKE_FORMAT_EXTRA_ARGS, e.g. by invoking CMake with -DCMAKE_FORMAT_EXTRA_ARGS="-c /path/to/cmake-format-config.{yaml,json,py}", or by enabling the option when adding the dependency (recommended).

Demo

How to integrate

Using CPM.cmake (recommended)

Basic configuration

After adding CPM.cmake, add the following line to the project's CMakeLists.txt after calling project(...).

include(cmake/CPM.cmake)
CPMAddPackage("gh:TheLartians/Format.cmake@1.8.2")

Advanced configuration

This package supports optional parameters that you can specify in the CPM.cmake OPTIONS argument.

CPMAddPackage(
  NAME Format.cmake
  VERSION 1.8.2
  GITHUB_REPOSITORY TheLartians/Format.cmake
  OPTIONS
      # set to yes skip cmake formatting
      "FORMAT_SKIP_CMAKE NO"
      # set to yes skip clang formatting
      "FORMAT_SKIP_CLANG NO"
      # path to exclude (optional, supports regular expressions)
      "CMAKE_FORMAT_EXCLUDE cmake/CPM.cmake"
      # extra arguments for cmake_format (optional)
      "CMAKE_FORMAT_EXTRA_ARGS -c /path/to/cmake-format.{yaml,json,py}"
)

Using git submodules (not suited for libraries)

Run the following from the project's root directory.

git submodule add https://github.com/TheLartians/Format.cmake

In add the following lines to the project's CMakeLists.txt after calling project(...).

add_subdirectory(Format.cmake)

Dependencies

Format.cmake requires CMake, clang-format, python 2.7 or python 3, and cmake-format (optional).

Core symbols most depended-on inside this repo

run
called by 10
git-clang-format.py
die
called by 10
git-clang-format.py
convert_string
called by 5
git-clang-format.py
temporary_index_file
called by 3
git-clang-format.py
get_object_type
called by 2
git-clang-format.py
run_clang_format_and_save_to_tree
called by 2
git-clang-format.py
create_tree
called by 2
git-clang-format.py
main
called by 1
git-clang-format.py

Shape

Function 26

Languages

Python96%
C++4%

Modules by API surface

git-clang-format.py25 symbols
test/test.cpp1 symbols

For agents

$ claude mcp add Format.cmake \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact