Skip to content

Commit 8cfca70

Browse files
committed
Fix formatting of CMake files
2 spaces seems to be the more common indentation level so that's what I unified around.
1 parent 6aac11e commit 8cfca70

16 files changed

+684
-787
lines changed

CMake/Catch2Config.cmake.in

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
@PACKAGE_INIT@
22

3-
43
# Avoid repeatedly including the targets
54
if(NOT TARGET Catch2::Catch2)
6-
# Provide path for scripts
7-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
5+
# Provide path for scripts
6+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
87

9-
include(${CMAKE_CURRENT_LIST_DIR}/Catch2Targets.cmake)
8+
include(${CMAKE_CURRENT_LIST_DIR}/Catch2Targets.cmake)
109
endif()

CMake/CatchConfigOptions.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#
1515
# For detailed docs look into docs/configuration.md
1616

17-
1817
macro(AddOverridableConfigOption OptionBaseName)
1918
option(CATCH_CONFIG_${OptionBaseName} "Read docs/configuration.md for details" OFF)
2019
option(CATCH_CONFIG_NO_${OptionBaseName} "Read docs/configuration.md for details" OFF)
@@ -74,9 +73,9 @@ foreach(OptionName ${_OtherConfigOptions})
7473
AddConfigOption(${OptionName})
7574
endforeach()
7675
if(DEFINED BUILD_SHARED_LIBS)
77-
set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
76+
set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
7877
else()
79-
set(CATCH_CONFIG_SHARED_LIBRARY "")
78+
set(CATCH_CONFIG_SHARED_LIBRARY "")
8079
endif()
8180

8281
set(CATCH_CONFIG_DEFAULT_REPORTER "console" CACHE STRING "Read docs/configuration.md for details. The name of the reporter should be without quotes.")

CMake/CatchMiscFunctions.cmake

Lines changed: 90 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -8,108 +8,107 @@
88

99
include(CheckCXXCompilerFlag)
1010
function(add_cxx_flag_if_supported_to_targets flagname targets)
11-
string(MAKE_C_IDENTIFIER ${flagname} flag_identifier )
12-
check_cxx_compiler_flag("${flagname}" HAVE_FLAG_${flag_identifier})
11+
string(MAKE_C_IDENTIFIER ${flagname} flag_identifier)
12+
check_cxx_compiler_flag("${flagname}" HAVE_FLAG_${flag_identifier})
1313

14-
if (HAVE_FLAG_${flag_identifier})
15-
foreach(target ${targets})
16-
target_compile_options(${target} PRIVATE ${flagname})
17-
endforeach()
18-
endif()
14+
if(HAVE_FLAG_${flag_identifier})
15+
foreach(target ${targets})
16+
target_compile_options(${target} PRIVATE ${flagname})
17+
endforeach()
18+
endif()
1919
endfunction()
2020

2121
# Assumes that it is only called for development builds, where warnings
2222
# and Werror is desired, so it also enables Werror.
2323
function(add_warnings_to_targets targets)
24-
LIST(LENGTH targets TARGETS_LEN)
25-
# For now we just assume 2 possibilities: msvc and msvc-like compilers,
26-
# and other.
27-
if (MSVC)
28-
foreach(target ${targets})
29-
# Force MSVC to consider everything as encoded in utf-8
30-
target_compile_options( ${target} PRIVATE /utf-8 )
31-
# Enable Werror equivalent
32-
if (CATCH_ENABLE_WERROR)
33-
target_compile_options( ${target} PRIVATE /WX )
34-
endif()
35-
36-
# MSVC is currently handled specially
37-
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
38-
STRING(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # override default warning level
39-
target_compile_options( ${target} PRIVATE /w44265 /w44061 /w44062 /w45038 )
40-
endif()
41-
endforeach()
24+
LIST(LENGTH targets TARGETS_LEN)
25+
# For now we just assume 2 possibilities: msvc and msvc-like compilers,
26+
# and other.
27+
if(MSVC)
28+
foreach(target ${targets})
29+
# Force MSVC to consider everything as encoded in utf-8
30+
target_compile_options(${target} PRIVATE /utf-8)
31+
# Enable Werror equivalent
32+
if(CATCH_ENABLE_WERROR)
33+
target_compile_options(${target} PRIVATE /WX)
34+
endif()
4235

43-
endif()
36+
# MSVC is currently handled specially
37+
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
38+
STRING(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # override default warning level
39+
target_compile_options(${target} PRIVATE /w44265 /w44061 /w44062 /w45038)
40+
endif()
41+
endforeach()
42+
endif()
4443

45-
if (NOT MSVC)
46-
set(CHECKED_WARNING_FLAGS
47-
"-Wabsolute-value"
48-
"-Wall"
49-
"-Wcall-to-pure-virtual-from-ctor-dtor"
50-
"-Wcast-align"
51-
"-Wcatch-value"
52-
"-Wdangling"
53-
"-Wdeprecated"
54-
"-Wdeprecated-register"
55-
"-Wexceptions"
56-
"-Wexit-time-destructors"
57-
"-Wextra"
58-
"-Wextra-semi"
59-
"-Wfloat-equal"
60-
"-Wglobal-constructors"
61-
"-Winit-self"
62-
"-Wmisleading-indentation"
63-
"-Wmismatched-new-delete"
64-
"-Wmismatched-return-types"
65-
"-Wmismatched-tags"
66-
"-Wmissing-braces"
67-
"-Wmissing-declarations"
68-
"-Wmissing-noreturn"
69-
"-Wmissing-prototypes"
70-
"-Wmissing-variable-declarations"
71-
"-Wnon-virtual-dtor"
72-
"-Wnull-dereference"
73-
"-Wold-style-cast"
74-
"-Woverloaded-virtual"
75-
"-Wparentheses"
76-
"-Wpedantic"
77-
"-Wredundant-decls"
78-
"-Wreorder"
79-
"-Wreturn-std-move"
80-
"-Wshadow"
81-
"-Wstrict-aliasing"
82-
"-Wsubobject-linkage"
83-
"-Wsuggest-destructor-override"
84-
"-Wsuggest-override"
85-
"-Wundef"
86-
"-Wuninitialized"
87-
"-Wunneeded-internal-declaration"
88-
"-Wunreachable-code-aggressive"
89-
"-Wunused"
90-
"-Wunused-function"
91-
"-Wunused-parameter"
92-
"-Wvla"
93-
"-Wweak-vtables"
44+
if(NOT MSVC)
45+
set(CHECKED_WARNING_FLAGS
46+
"-Wabsolute-value"
47+
"-Wall"
48+
"-Wcall-to-pure-virtual-from-ctor-dtor"
49+
"-Wcast-align"
50+
"-Wcatch-value"
51+
"-Wdangling"
52+
"-Wdeprecated"
53+
"-Wdeprecated-register"
54+
"-Wexceptions"
55+
"-Wexit-time-destructors"
56+
"-Wextra"
57+
"-Wextra-semi"
58+
"-Wfloat-equal"
59+
"-Wglobal-constructors"
60+
"-Winit-self"
61+
"-Wmisleading-indentation"
62+
"-Wmismatched-new-delete"
63+
"-Wmismatched-return-types"
64+
"-Wmismatched-tags"
65+
"-Wmissing-braces"
66+
"-Wmissing-declarations"
67+
"-Wmissing-noreturn"
68+
"-Wmissing-prototypes"
69+
"-Wmissing-variable-declarations"
70+
"-Wnon-virtual-dtor"
71+
"-Wnull-dereference"
72+
"-Wold-style-cast"
73+
"-Woverloaded-virtual"
74+
"-Wparentheses"
75+
"-Wpedantic"
76+
"-Wredundant-decls"
77+
"-Wreorder"
78+
"-Wreturn-std-move"
79+
"-Wshadow"
80+
"-Wstrict-aliasing"
81+
"-Wsubobject-linkage"
82+
"-Wsuggest-destructor-override"
83+
"-Wsuggest-override"
84+
"-Wundef"
85+
"-Wuninitialized"
86+
"-Wunneeded-internal-declaration"
87+
"-Wunreachable-code-aggressive"
88+
"-Wunused"
89+
"-Wunused-function"
90+
"-Wunused-parameter"
91+
"-Wvla"
92+
"-Wweak-vtables"
9493

95-
# This is a useful warning, but our tests sometimes rely on
96-
# functions being present, but not picked (e.g. various checks
97-
# for stringification implementation ordering).
98-
# Ergo, we should use it every now and then, but we cannot
99-
# enable it by default.
100-
# "-Wunused-member-function"
101-
)
102-
foreach(warning ${CHECKED_WARNING_FLAGS})
103-
add_cxx_flag_if_supported_to_targets(${warning} "${targets}")
104-
endforeach()
94+
# This is a useful warning, but our tests sometimes rely on
95+
# functions being present, but not picked (e.g. various checks
96+
# for stringification implementation ordering).
97+
# Ergo, we should use it every now and then, but we cannot
98+
# enable it by default.
99+
# "-Wunused-member-function"
100+
)
101+
foreach(warning ${CHECKED_WARNING_FLAGS})
102+
add_cxx_flag_if_supported_to_targets(${warning} "${targets}")
103+
endforeach()
105104

106-
if (CATCH_ENABLE_WERROR)
107-
foreach(target ${targets})
108-
# Enable Werror equivalent
109-
target_compile_options( ${target} PRIVATE -Werror )
110-
endforeach()
111-
endif()
105+
if(CATCH_ENABLE_WERROR)
106+
foreach(target ${targets})
107+
# Enable Werror equivalent
108+
target_compile_options(${target} PRIVATE -Werror)
109+
endforeach()
112110
endif()
111+
endif()
113112
endfunction()
114113

115114
# Adds flags required for reproducible build to the target

0 commit comments

Comments
 (0)