Skip to content

Commit

Permalink
fix: use quotation marks in if(STREQUAL) (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
threeal authored Jul 5, 2024
1 parent 05cad86 commit 415ac6f
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions cmake/Assertion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,40 +116,40 @@ function(assert)
# Assertion failed, determine the fatal error message based on the given
# condition.
if(ARGC EQUAL 2)
if(NOT ARGV0 STREQUAL NOT)
if(ARGV0 STREQUAL DEFINED)
if(NOT ARGV0 STREQUAL "NOT")
if(ARGV0 STREQUAL "DEFINED")
fail("expected variable" ARGV1 "to be defined")
return()
elseif(ARGV0 STREQUAL EXISTS)
elseif(ARGV0 STREQUAL "EXISTS")
fail("expected path" ARGV1 "to exist")
return()
elseif(ARGV0 STREQUAL IS_DIRECTORY)
elseif(ARGV0 STREQUAL "IS_DIRECTORY")
fail("expected path" ARGV1 "to be a directory")
return()
endif()
endif()
elseif(ARGC EQUAL 3)
if(ARGV0 STREQUAL NOT)
if(ARGV1 STREQUAL DEFINED)
if(ARGV0 STREQUAL "NOT")
if(ARGV1 STREQUAL "DEFINED")
fail("expected variable" ARGV2 "not to be defined")
return()
elseif(ARGV1 STREQUAL EXISTS)
elseif(ARGV1 STREQUAL "EXISTS")
fail("expected path" ARGV2 "not to exist")
return()
elseif(ARGV1 STREQUAL IS_DIRECTORY)
elseif(ARGV1 STREQUAL "IS_DIRECTORY")
fail("expected path" ARGV2 "not to be a directory")
return()
endif()
else()
if(ARGV1 STREQUAL MATCHES)
if(ARGV1 STREQUAL "MATCHES")
if(DEFINED "${ARGV0}")
fail("expected string" "${ARGV0}" "of variable" ARGV0
"to match" ARGV2)
else()
fail("expected string" ARGV0 "to match" ARGV2)
endif()
return()
elseif(ARGV1 STREQUAL STREQUAL)
elseif(ARGV1 STREQUAL "STREQUAL")
if(DEFINED "${ARGV0}")
if(DEFINED "${ARGV2}")
fail("expected string" "${ARGV0}" "of variable" ARGV0
Expand All @@ -170,16 +170,16 @@ function(assert)
endif()
endif()
elseif(ARGC EQUAL 4)
if(ARGV0 STREQUAL NOT)
if(ARGV2 STREQUAL MATCHES)
if(ARGV0 STREQUAL "NOT")
if(ARGV2 STREQUAL "MATCHES")
if(DEFINED "${ARGV1}")
fail("expected string" "${ARGV1}" "of variable" ARGV1
"not to match" ARGV3)
else()
fail("expected string" ARGV1 "not to match" ARGV3)
endif()
return()
elseif(ARGV2 STREQUAL STREQUAL)
elseif(ARGV2 STREQUAL "STREQUAL")
if(DEFINED "${ARGV1}")
if(DEFINED "${ARGV3}")
fail("expected string" "${ARGV1}" "of variable" ARGV1
Expand Down Expand Up @@ -232,7 +232,7 @@ function(assert_fatal_error)
# The fatal error message will only be captured if the capture level is
# one or above.
get_property(CAPTURE_LEVEL GLOBAL PROPERTY fatal_error_capture_level)
if(CAPTURE_LEVEL GREATER_EQUAL 1 AND MODE STREQUAL FATAL_ERROR)
if(CAPTURE_LEVEL GREATER_EQUAL 1 AND MODE STREQUAL "FATAL_ERROR")
string(JOIN "" MESSAGE ${ARG_UNPARSED_ARGUMENTS})
set_property(GLOBAL PROPERTY captured_fatal_error "${MESSAGE}")

Expand Down Expand Up @@ -388,7 +388,7 @@ if(DEFINED CMAKE_SCRIPT_MODE_FILE AND
CMAKE_SCRIPT_MODE_FILE STREQUAL CMAKE_CURRENT_LIST_FILE)
math(EXPR END "${CMAKE_ARGC} - 1")
foreach(I RANGE 0 "${END}")
if("${CMAKE_ARGV${I}}" STREQUAL --)
if(CMAKE_ARGV${I} STREQUAL "--")
math(EXPR I "${I} + 1")
foreach(I RANGE "${I}" "${END}")
include("${CMAKE_ARGV${I}}")
Expand Down

0 comments on commit 415ac6f

Please sign in to comment.