Skip to content

zemasoft/clangformat-cmake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

language.badge license.badge

ClangFormat.cmake module

ClangFormat.cmake is a simple CMake module for clang-format support.

Requirements

The module requires CMake 3.0 or higher and some version of clang-format installed.

Integration

  1. Obtain the module and add it into your project's CMake modules path:

    • Copy approach:

      $ wget https://raw.githubusercontent.com/zemasoft/clangformat-cmake/master/cmake/ClangFormat.cmake -P cmake
      # CMakeLists.txt
      
      list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
    • Submodule approach:

      $ git submodule add https://github.com/zemasoft/clangformat-cmake
      # CMakeLists.txt
      
      list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/clangformat-cmake/cmake)
  2. Include the module:

    # CMakeLists.txt
    
    include(ClangFormat)
  3. Setup the module:

    # CMakeLists.txt
    
    clangformat_setup(
      src/hello.hpp
      src/hello.cpp
    )

    or:

    # CMakeLists.txt
    
    target_clangformat_setup(sometarget)

Usage

  1. Generate the build system:

    $ cmake -S . -Bbuild
  2. Format sources anytime using clangformat target:

    $ cmake --build build --target clangformat

    or:

    $ cd build
    $ make clangformat

Example

See an example here.

About

A simple CMake module for clang-format support

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages