Skip to content

Commit e8b0f12

Browse files
authored
replaced if(MATCHES) with if(STREQUAL) (#4263)
`MATCHES` does regular expression matching which is not the intended behavior here. `Clang` still requires it since it also needs to match `AppleClang.
1 parent 0ae9877 commit e8b0f12

11 files changed

Lines changed: 22 additions & 22 deletions

File tree

cmake/compilerCheck.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
1+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
22
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
33
message(ERROR "GCC >= 4.8 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported")
44
endif ()

cmake/compilerDefinitions.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
if (MSVC)
22
# Visual Studio only sets _DEBUG
3-
if (CMAKE_BUILD_TYPE MATCHES "Debug")
3+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
44
add_definitions(-DDEBUG)
55
endif()
66

@@ -15,7 +15,7 @@ endif()
1515
# TODO: this should probably apply to the compiler and not the platform
1616
if (CPPCHK_GLIBCXX_DEBUG AND UNIX)
1717
# TODO: check if this can be enabled again for Clang - also done in Makefile
18-
if (CMAKE_BUILD_TYPE MATCHES "Debug" AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
18+
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
1919
add_definitions(-D_GLIBCXX_DEBUG)
2020
endif()
2121
endif()

cmake/compileroptions.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
2020
add_compile_options(-Weverything)
2121
endif()
2222

23-
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
24-
if(CMAKE_BUILD_TYPE MATCHES "Release")
23+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
24+
if(CMAKE_BUILD_TYPE STREQUAL "Release")
2525
# "Release" uses -O3 by default
2626
add_compile_options(-O2)
2727
endif()
@@ -45,14 +45,14 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
4545
add_compile_options(-Wno-multichar)
4646
endif()
4747

48-
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
48+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
4949
add_compile_options(-Woverloaded-virtual) # when a function declaration hides virtual functions from a base class
5050
add_compile_options(-Wno-maybe-uninitialized) # there are some false positives
5151
add_compile_options(-Wsuggest-attribute=noreturn)
5252
add_compile_options(-Wno-shadow) # whenever a local variable or type declaration shadows another one
5353
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5454
if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 14)
55-
if (CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
55+
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
5656
# work around performance regression - see https://github.com/llvm/llvm-project/issues/53555
5757
add_compile_options(-mllvm -inline-deferral)
5858
endif()
@@ -124,7 +124,7 @@ if (MSVC)
124124
# No Whole Program Optimization
125125

126126
# C/C++ - Optimization
127-
if(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
127+
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
128128
add_compile_options(/O2) # Optimization - Maximum Optimization (Favor Speed)
129129
add_compile_options(/Ob2) # Inline Function Expansion - Any Suitable
130130
add_compile_options(/Oi) # Enable Intrinsic Functions
@@ -135,7 +135,7 @@ if (MSVC)
135135
endif()
136136

137137
# C/C++ - Code Generation
138-
if(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
138+
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
139139
add_compile_options(/GF) # Enable String Pooling
140140
add_compile_options(/MD) # Runtime Library - Multi-threaded DLL
141141
add_compile_options(/GS-) # Disable Security Check
@@ -172,7 +172,7 @@ if (MSVC)
172172
add_compile_options(/Zc:throwingNew /Zc:__cplusplus) # Additional Options
173173

174174
# Linker - General
175-
if(CMAKE_BUILD_TYPE MATCHES "Debug")
175+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
176176
add_link_options(/INCREMENTAL) # Enable Incremental Linking - Yes
177177
endif()
178178
add_link_options(/NOLOGO) # SUppress Startup Banner - Yes
@@ -191,13 +191,13 @@ if (MSVC)
191191
add_link_options(/OPT:ICF) # Enable COMDAT Folding - Yes
192192

193193
# Linker - Advanced
194-
if(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
194+
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
195195
add_link_options(/RELEASE) # Set Checksum - Yes
196196
endif()
197197
endif()
198198

199199
# TODO: check if this can be enabled again - also done in Makefile
200-
if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND
200+
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
201201
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
202202

203203
add_compile_options(-U_GLIBCXX_DEBUG)

cmake/cxx11.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
macro(use_cxx11)
22
if (CMAKE_VERSION VERSION_LESS "3.1")
3-
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
3+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
44
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
55
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
66
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

cmake/options.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ option(WARNINGS_ARE_ERRORS "Treat warnings as errors"
2121

2222
set(USE_MATCHCOMPILER "Auto" CACHE STRING "Usage of match compiler")
2323
set_property(CACHE USE_MATCHCOMPILER PROPERTY STRINGS Auto Off On Verify)
24-
if (USE_MATCHCOMPILER MATCHES "Auto")
25-
if (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
24+
if (USE_MATCHCOMPILER STREQUAL "Auto")
25+
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
2626
set(USE_MATCHCOMPILER_OPT "On")
2727
else()
2828
set(USE_MATCHCOMPILER_OPT "Off")

cmake/printInfo.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ endif()
5353
message( STATUS )
5454
message( STATUS "USE_THREADS = ${USE_THREADS}" )
5555
message( STATUS "CMAKE_THREAD_LIBS_INIT = ${CMAKE_THREAD_LIBS_INIT}" )
56-
if (NOT USE_MATCHCOMPILER_OPT MATCHES "Off")
56+
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
5757
message( STATUS )
5858
message( STATUS "PYTHON_VERSION_STRING = ${PYTHON_VERSION_STRING}" )
5959
message( STATUS "PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}" )

externals/tinyxml2/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ file(GLOB srcs "*.cpp")
44
add_library(tinyxml2_objs OBJECT ${srcs} ${hdrs})
55

66
# TODO: needs to be fixed upstream
7-
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
7+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
88
target_compile_options(tinyxml2_objs PRIVATE -Wno-suggest-attribute=format)
99
endif()
1010
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")

gui/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
if (BUILD_GUI)
22

3-
if (CMAKE_BUILD_TYPE MATCHES "Release")
3+
if (CMAKE_BUILD_TYPE STREQUAL "Release")
44
add_definitions(-DQT_NO_DEBUG)
55
add_definitions(-DQT_NO_DEBUG_OUTPUT)
66
add_definitions(-DQT_NO_WARNING_OUTPUT)

lib/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function(build_src output filename)
55
get_filename_component(file ${filename} NAME)
66
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/build/mc_${file})
77
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
8-
if (USE_MATCHCOMPILER MATCHES "Verify")
8+
if (USE_MATCHCOMPILER STREQUAL "Verify")
99
set(verify_option "--verify")
1010
endif()
1111
add_custom_command(
@@ -26,7 +26,7 @@ foreach(file ${srcs})
2626
build_src(srcs_build ${file})
2727
endforeach()
2828

29-
if (NOT USE_MATCHCOMPILER_OPT MATCHES "Off")
29+
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
3030
set(srcs_lib ${srcs_build})
3131
else()
3232
set(srcs_lib ${srcs})

tools/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set(srcs_lib pathmatch.cpp path.cpp)
22
foreach(file ${srcs_lib})
3-
if (NOT USE_MATCHCOMPILER_OPT MATCHES "Off")
3+
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
44
set(src "${CMAKE_BINARY_DIR}/lib/build/mc_${file}")
55
set_source_files_properties(${src} PROPERTIES GENERATED TRUE)
66
else()

0 commit comments

Comments
 (0)