Skip to content

Latest commit

 

History

History
226 lines (191 loc) · 4.48 KB

config.adoc

File metadata and controls

226 lines (191 loc) · 4.48 KB

format subcommand configuration

1. Usage

There is a number of configurable settings possible to provide in .cmake-tidy.json configuration file. The file is searched in following locations and order of precedence

  • location of input_file to be formatted

  • parent locations of input_file

  • current working directory of the tool (cwd)

2. Settings and default values

Table 1. Settings
Name Type Default Value Detailed description

succeeding_newlines

integer

2

Describes the maximum number of succeeding newlines that can appear in formatted file.

tabs_as_spaces

boolean

False

Dictates whether code indentation should be done using spaces (True) or tabs (False).

tab_size

integer

4

When tabs_as_spaces is True this option defines the amount of spaces used for a single TAB.

force_command_lowercase

boolean

True

Convert all command invocations to lowercase (including keywords) eg. SOME_FUNC() to some_func() and IF(…​) to if(…​).

space_between_command_and_begin_parentheses

boolean

False

Insert space between command name and begin parentheses eg. if() to \"if ()` or set() to set ().

line_length

integer

100

Maximum line length that will not cause command invocation splitting.

wrap_short_invocations_to_single_line

boolean

True

Wrap command invocations into single line when they fit in line_length. from:

target_sources(${PROJECT_NAME}
    PRIVATE
        file1.cpp
)

to:

target_sources(${PROJECT_NAME} PRIVATE file1.cpp)

closing_parentheses_in_newline_when_split

boolean

True

Force closing parentheses to new line when command invocation splitting is needed. from:

target_sources(${PROJECT_NAME}
    PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/Source/file1.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/Source/file2.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/Source/file3.cpp)

to:

target_sources(${PROJECT_NAME}
    PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/Source/file1.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/Source/file2.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/Source/file3.cpp
)

unquoted_uppercase_as_keyword

boolean

False

Consider all unquoted uppercase arguments as keywords. eg. keywords:

SOME
TEXT_IS_KEYWORD

treated as normal arguments:

_SOME
TEXT__IS_KEYWORD
NOT_
a_ARGUMENT
SOMeARG

space_after_loop_condition

boolean

False

Introduces spaces after all conditional invocations only eg.

if (Linux STREQUAL ${CMAKE_SYSTEM_NAME})
	target_sources(${PROJECT_NAME} PRIVATE file.cpp)
elseif (Windows STREQUAL ${CMAKE_SYSTEM_NAME})
	target_sources(${PROJECT_NAME} PRIVATE different.cpp)
endif()

keep_property_and_value_in_one_line

boolean

True

Forces no splitting between property and value even if the line is too long. eg.

set_property(
	SOURCE
		${CMAKE_CURRENT_SOURCE_DIR}/Source/File.cpp
	PROPERTY
		COMPILE_FLAGS $<$<CXX_COMPILER_ID:MSVC>:/Y-> # ignore precompiled headers
)

keep_command_in_single_line

boolean

True

Keeps COMMAND within single line. Enabled:

add_custom_target(${target}-resources
        ALL
        COMMAND
                ${CMAKE_COMMAND} -E echo "Copy resource files for ${target}"

Disabled:

add_custom_target(${target}-resources
        ALL
        COMMAND
                ${CMAKE_COMMAND}
                -E
                echo
                "Copy resource files for ${target}"

keyword_and_single_value_in_one_line

boolean

True

Enforces keyword and its value to be in single line. Disabled:

install(
	FILES
		file.cpp
		file.hpp
	DESTINATION
		"include/folder"
)

Enabled:

install(
	FILES
		file.cpp
		file.hpp
	DESTINATION "include/folder"
)

condition_splitting_move_and_or_to_newline

boolean

True

When splitting conditional invocation when enabled splits invocation before AND/OR operators:

if(CMAKE_GENERATOR STREQUAL "Visual Studio 15 2017"
        OR CMAKE_GENERATOR STREQUAL "Visual Studio 16 2019")

Disabled:

if(CMAKE_GENERATOR STREQUAL "Visual Studio 15 2017" OR
        CMAKE_GENERATOR STREQUAL "Visual Studio 16 2019")

keywords

array

[]

Consider list of provided arguments as keywords when formatting.