Skip to content

Project provides a set of tools that will ease the development process for code written in CMake.

License

Notifications You must be signed in to change notification settings

MaciejPatro/cmake-tidy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmake-tidy

1. Introduction

The goal of project is to provide a set of tools that will ease the development process for build systems code written in CMake. Main ideas of the tool are but not limited to:

  • CMake code formatting - based on language syntax analysis

  • modern CMake static analysis - basic code analysis with possible auto-fixing.

  • large flexibility of configuration - as coding styles differ quite a lot.

  • easy to use - mimic usage and parameters with other state-of-the-art tools to reduce learning curve for users.

2. Application usage

cmake-tidy is a command-line application written in python3.

Available subcommands:

usage: cmake-tidy [-h] {format} ...

optional arguments:
  -h, --help  show this help message and exit

sub-commands:
  {format}    see "cmake-tidy <command> --help" to read more about a specific
              sub-command.
    format    format file to align it to standard

2.1. format subcommand

2.1.1. Usage

usage: cmake-tidy format [-h] [--dump-config] [-i] [--diff] [--verbose]
                         [input [input ...]]

positional arguments:
  input          CMake file to be formatted

optional arguments:
  -h, --help     show this help message and exit
  --dump-config  Dump to stdout current settings. Script tries to read
                 settings from `.cmake-tidy.json` or provides default
                 settings. Precedence of searching `.cmake-tidy.json` is
                 described on github
  -i, --inplace  Inplace edit specified <input_data> file
  --diff         Print to stdout unified diff between original file and
                 formatted version.
  --verbose      Print to stdout information about formatted file

User can provide alternative settings to an application by providing custom .cmake-tidy.json file. For more information about available parameters and values visit here.

2.2. analyze subcommand

Introduction is ongoing.

3. Known limitations/bugs

  • Application can format only valid cmake files (Syntax errors cause application to exit without modifying content of formatted file).

  • Support for deprecated keywords/properties for older version of cmake than specified in --version command might be limited. If you need to support them please provide pull request or specify them as custom keywords in .cmake-tidy.json config file.

  • Line continuation \ handling is not implemented.

4. Other information

4.1. Installation

The tool is available throught python package index using command:

python3 -m pip install cmake-tidy

To confirm installation was successful you can run:

cmake-tidy -v

4.2. CI status

Automated testing is done with workflows:

  • ubuntu-lastest, python-3.8 Status

  • windows-lastest, python-3.8 Status