How to specify the variable which must be set and exist in cmake
<p>I have a need to have some variable to be specified and exist in the environment.
In case it does not exist need to stop building.</p>

<p>example </p>

<pre><code>if ( "${VARMUSTEXIST}" STREQUAL "ON" )
   message(STATUS is ON)
elif ("${VARMUSTEXIST}" STREQUAL "OFF")
   message(STATUS is OFF)
endif()
</code></pre>

<p>I don't want to put an <code>if (defined VARMUSTEXIST)</code> everywhere in the script.
In bash there is an option for that "set -u".</p>