Bug in evaluating of `if` statement
For the following snippet
if((NOT (ARGC GREATER 1)) AND (ARGC EQUAL 2))
_message(FATAL_ERROR "We don't know arithmetic: ARGC=${ARGC}")
endif()
I don't expect to see "We don't know arithmetic" ever printed, and yet it happens:
CMake Error at C:/Users/AGrinshpun/gitlab/integration/cc/build/map.cmake:168 (_message):
We don't know arithmetic: ARGC=2
CMake version - 3.13.0
OS - Windows-7
Full function body
function(map_getl mapKey) #resVar
_parse_key(${mapKey} map key)
if((NOT map) OR (NOT key))
message(FATAL_ERROR "illegal mapkey=${mapKey}")
return()
endif()
if((NOT (ARGC GREATER 1)) AND (ARGC EQUAL 2))
_message(FATAL_ERROR "We don't know arithmetic: ARGC=${ARGC}")
endif()
if(ARGC EQUAL 2)
set(resVar ${ARGV1})
else()
list(GET key -1 resVar)
endif()
_map_getl_aux(${map} "${key}" tmp ${ARGN})
set(${resVar} "${tmp}" PARENT_SCOPE)
endfunction()
Before failure, this function run successfully with exactly the same arguments quite a few times.