On 2014-01-29 19:09, Rob McDonald wrote:
I feel like this is a really dumb question, but I've got myself wrapped
around the axel....
I'd like to use a negative conditional on a variable that may or may not be
defined... say USE_SYSTEM_FOO
So, I'd like to do something like this...
IF( NOT ${USE_SYSTEM_FOO} )
# Build my own FOO
ENDIF()
However, this does not work as desired. On the other hand, the following
version does have the desired behavior (shouldn't these be the same?).
IF( ${USE_SYSTEM_FOO} )
ELSE()
# Build my own FOO
ENDIF()
I tried a couple of combinations with DEFINED thrown in. They didn't work
as desired either. I didn't chase after a compound conditional like the
following simply due to ugliness....
IF( NOT DEFINED ${USE_SYSTEM_FOO} OR NOT ${USE_SYSTEM_FOO} )
# Build my own FOO
ENDIF()
Expanding somewhat on JC's reply... do you realize you wrote e.g.
'if(NOT DEFINED ON)' here? "${NAME}" means "before evaluating anything
else, replace '${NAME}' with the value of the variable 'NAME' (or
nothing, if 'NAME' is unset)".
Dereferencing is automatic in this context (especially 'DEFINED', which
operates on a variable name). So as JC wrote, you will probably have
better success omitting the dereference.
--
Matthew
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake