[CMake] if(MATCHES) broken??
Matthew Woehlke
mw_triad at users.sourceforge.net
Thu Nov 20 14:56:39 EST 2008
Bill Hoffman wrote:
> The only work around that I can think of is to change the macro to a
> function and unset the variable before the test.
>
> function(foo bar)
> set(${bar} ) # unset the variable named "${bar}"
> if("${bar}" MATCHES "CFLAGS")
> message(STATUS "CFLAGS matched")
> elseif("${bar}" STREQUAL "CFLAGS")
> message(STATUS "CFLAGS match broken!!!")
> endif()
> endfunction()
I should add: this doesn't work (at least, not nicely and without
fiddling with PARENT_SCOPE), since I need to change another
(function-local) variable based on the value of ${bar}.
After thinking about it a bit more, this bit of autotools-inspired
hackery seems to suffice: 'if("!${bar}" MATCHES "!CFLAGS")'. Except I
think I found another bug (stay tuned) :-).
--
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
--
C++ is for people who want to be able to not just shoot themselves in
the foot, but do it with a rocket launcher. -- Igor Peshansky
More information about the CMake
mailing list