[CMake] Reverse logic

Jean-Christophe Fillion-Robin jchris.fillionr at kitware.com
Wed Jan 29 19:23:40 EST 2014


Hi Rob,

What about:

if( NOT USE_SYSTEM_FOO)
    # Build my own FOO
endif()

Hth
Jc


On Wed, Jan 29, 2014 at 7:09 PM, Rob McDonald <rob.a.mcdonald at gmail.com>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()
>
> What is the CMake idiomatic way to do this?
>
> BTW, I'm going to do a bunch of these, and I'd like to surround them with
> a global USE_SYSTEM_LIBRARIES, so solutions that don't get exponentially
> uglier with linear increases in complexity are desired.
>
> Rob
>
> --
>
> 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
>



-- 
+1 919 869 8849
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140129/aae79bfd/attachment-0001.html>


More information about the CMake mailing list