Unlike "CMAKE_HOST_SYSTEM_NAME", "CMAKE_SYSTEM_NAME" not defined by default in scripts executed with -P
(cmake 3.9, locally built from source with all defaults on Linux (CentOS 6.5) x86_64)
Iterating variables from a script executed via -P (cmake -P somescriptfile) does not encounter a variable named CMAKE_SYSTEM_NAME.
That same code executed from a CMakeLists.txt file encounters a variable named CMAKE_SYSTEM_NAME.
The documentation (3.4, 3.9 - https://cmake.org/cmake/help/v3.9/variable/CMAKE_SYSTEM_NAME.html#) does not mention in the entry for CMAKE_SYSTEM_NAME, that it may not be available, but states that it will default to CMAKE_HOST_SYSTEM_NAME (which is defined in both execution environments).
Example script code (obtained from https://stackoverflow.com/questions/9298278/cmake-print-out-all-accessible-variables-in-a-script):
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
Alternate code at (https://blog.kitware.com/cmake-variable-values/) behaves similarly.