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.
This commit is contained in:
Oliver Stöneberg 2022-07-11 10:46:18 +02:00 committed by GitHub
parent 0ae9877766
commit e8b0f12367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 22 additions and 22 deletions

View File

@ -1,4 +1,4 @@
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
message(ERROR "GCC >= 4.8 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported")
endif ()

View File

@ -1,6 +1,6 @@
if (MSVC)
# Visual Studio only sets _DEBUG
if (CMAKE_BUILD_TYPE MATCHES "Debug")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDEBUG)
endif()
@ -15,7 +15,7 @@ endif()
# TODO: this should probably apply to the compiler and not the platform
if (CPPCHK_GLIBCXX_DEBUG AND UNIX)
# TODO: check if this can be enabled again for Clang - also done in Makefile
if (CMAKE_BUILD_TYPE MATCHES "Debug" AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_definitions(-D_GLIBCXX_DEBUG)
endif()
endif()

View File

@ -20,8 +20,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Weverything)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_BUILD_TYPE MATCHES "Release")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
# "Release" uses -O3 by default
add_compile_options(-O2)
endif()
@ -45,14 +45,14 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
add_compile_options(-Wno-multichar)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Woverloaded-virtual) # when a function declaration hides virtual functions from a base class
add_compile_options(-Wno-maybe-uninitialized) # there are some false positives
add_compile_options(-Wsuggest-attribute=noreturn)
add_compile_options(-Wno-shadow) # whenever a local variable or type declaration shadows another one
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 14)
if (CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
# work around performance regression - see https://github.com/llvm/llvm-project/issues/53555
add_compile_options(-mllvm -inline-deferral)
endif()
@ -124,7 +124,7 @@ if (MSVC)
# No Whole Program Optimization
# C/C++ - Optimization
if(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_compile_options(/O2) # Optimization - Maximum Optimization (Favor Speed)
add_compile_options(/Ob2) # Inline Function Expansion - Any Suitable
add_compile_options(/Oi) # Enable Intrinsic Functions
@ -135,7 +135,7 @@ if (MSVC)
endif()
# C/C++ - Code Generation
if(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_compile_options(/GF) # Enable String Pooling
add_compile_options(/MD) # Runtime Library - Multi-threaded DLL
add_compile_options(/GS-) # Disable Security Check
@ -172,7 +172,7 @@ if (MSVC)
add_compile_options(/Zc:throwingNew /Zc:__cplusplus) # Additional Options
# Linker - General
if(CMAKE_BUILD_TYPE MATCHES "Debug")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_link_options(/INCREMENTAL) # Enable Incremental Linking - Yes
endif()
add_link_options(/NOLOGO) # SUppress Startup Banner - Yes
@ -191,13 +191,13 @@ if (MSVC)
add_link_options(/OPT:ICF) # Enable COMDAT Folding - Yes
# Linker - Advanced
if(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_link_options(/RELEASE) # Set Checksum - Yes
endif()
endif()
# TODO: check if this can be enabled again - also done in Makefile
if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-U_GLIBCXX_DEBUG)

View File

@ -1,6 +1,6 @@
macro(use_cxx11)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

View File

@ -21,8 +21,8 @@ option(WARNINGS_ARE_ERRORS "Treat warnings as errors"
set(USE_MATCHCOMPILER "Auto" CACHE STRING "Usage of match compiler")
set_property(CACHE USE_MATCHCOMPILER PROPERTY STRINGS Auto Off On Verify)
if (USE_MATCHCOMPILER MATCHES "Auto")
if (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
if (USE_MATCHCOMPILER STREQUAL "Auto")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(USE_MATCHCOMPILER_OPT "On")
else()
set(USE_MATCHCOMPILER_OPT "Off")

View File

@ -53,7 +53,7 @@ endif()
message( STATUS )
message( STATUS "USE_THREADS = ${USE_THREADS}" )
message( STATUS "CMAKE_THREAD_LIBS_INIT = ${CMAKE_THREAD_LIBS_INIT}" )
if (NOT USE_MATCHCOMPILER_OPT MATCHES "Off")
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
message( STATUS )
message( STATUS "PYTHON_VERSION_STRING = ${PYTHON_VERSION_STRING}" )
message( STATUS "PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}" )

View File

@ -4,7 +4,7 @@ file(GLOB srcs "*.cpp")
add_library(tinyxml2_objs OBJECT ${srcs} ${hdrs})
# TODO: needs to be fixed upstream
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(tinyxml2_objs PRIVATE -Wno-suggest-attribute=format)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")

View File

@ -1,6 +1,6 @@
if (BUILD_GUI)
if (CMAKE_BUILD_TYPE MATCHES "Release")
if (CMAKE_BUILD_TYPE STREQUAL "Release")
add_definitions(-DQT_NO_DEBUG)
add_definitions(-DQT_NO_DEBUG_OUTPUT)
add_definitions(-DQT_NO_WARNING_OUTPUT)

View File

@ -5,7 +5,7 @@ function(build_src output filename)
get_filename_component(file ${filename} NAME)
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/build/mc_${file})
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
if (USE_MATCHCOMPILER MATCHES "Verify")
if (USE_MATCHCOMPILER STREQUAL "Verify")
set(verify_option "--verify")
endif()
add_custom_command(
@ -26,7 +26,7 @@ foreach(file ${srcs})
build_src(srcs_build ${file})
endforeach()
if (NOT USE_MATCHCOMPILER_OPT MATCHES "Off")
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
set(srcs_lib ${srcs_build})
else()
set(srcs_lib ${srcs})

View File

@ -1,6 +1,6 @@
set(srcs_lib pathmatch.cpp path.cpp)
foreach(file ${srcs_lib})
if (NOT USE_MATCHCOMPILER_OPT MATCHES "Off")
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
set(src "${CMAKE_BINARY_DIR}/lib/build/mc_${file}")
set_source_files_properties(${src} PROPERTIES GENERATED TRUE)
else()

View File

@ -1,5 +1,5 @@
if (BUILD_GUI AND BUILD_TESTS)
if (CMAKE_BUILD_TYPE MATCHES "Release")
if (CMAKE_BUILD_TYPE STREQUAL "Release")
add_definitions(-DQT_NO_DEBUG)
add_definitions(-DQT_NO_DEBUG_OUTPUT)
add_definitions(-DQT_NO_WARNING_OUTPUT)