1#!/bin/sh 2# 3# Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 4# 5# SPDX-License-Identifier: BSD-2-Clause 6# 7# 8 9# Style an input list of files as cmake files. 10 11PROGNAME=${0##*/} 12 13# Pass the cmake format as args such that cmake-format.py can be used 14# to provide definitions for custom function formatting. 15CMAKE_FMT="--line-width 100 \ 16 --tab-size 4 \ 17 --max-subargs-per-line 3 \ 18 --separate-ctrl-name-with-space False \ 19 --separate-fn-name-with-space False \ 20 --dangle-parens True \ 21 --command-case unchanged \ 22 --keyword-case unchanged \ 23 --enable-markup False" 24 25# cmake-format sends its version info to standard error. :-/ 26CF_VERSION=$(cmake-format --version 2>&1) 27DESIRED_VERSION=0.4.5 28 29case "$CF_VERSION" in 30 ("") 31 echo "$PROGNAME: fatal error: no output from \"cmake-format --version\"" 32 exit 2 33 ;; 34 ($DESIRED_VERSION) 35 # Good version; proceed. 36 ;; 37 (*) 38 echo "$PROGNAME: fatal error: need version $DESIRED_VERSION of" \ 39 "cmake-format; $CF_VERSION is installed" 40 exit 2 41 ;; 42esac 43 44cmake-format -i $CMAKE_FMT "$@" 45