[Development] Build system for Qt 6
Matthew Woehlke
mwoehlke.floss at gmail.com
Tue Oct 30 18:18:29 CET 2018
On 30/10/2018 04.21, resurrection at centrum.cz wrote:
> Christian Gagneraud wrote:
>> On Tue, 30 Oct 2018 at 18:29, <resurrection at centrum.cz> wrote:
>>> set(var1 "Hello")
>>> set(var2 "Hello")
>>>
>>> if(var1 EQUAL var2)
>>> message("They are equal")
>>> endif()
>>>
>>> Guess what, it prints NOTHING despite docs explicitly saying this
>>> should work. Nothig will help, STREQUAL, MATCHES, dereferencing
>>> the arguments, whatever.>>
>> You want
>> if (var1 STREQUAL var2) and this works as expected (and documented).
>
> No it does not. Have you tried it?
$ cat test.cmake
set(var1 "Hello")
set(var2 "Hello")
if(var1 STREQUAL var2)
message("They are equal")
endif()
$ cmake -P test.cmake
They are equal
> As I mentioned it does not work. And even if you somehow managed to
> make it work it would break the moment someone would define the
> variable "Hello" elsewhere in the script.
$ cat test2.cmake
set(Hello good bye)
set(var1 "Hello")
set(var2 "Hello")
if(var1 STREQUAL var2)
message("They are equal")
endif()
$ cmake -P test2.cmake
They are equal
As written, the variables will only be expanded once. But, even if you
wrote:
if(${var1} STREQUAL ${var2})
...which will expand to:
if("good;bye" STREQUAL "good;bye")
...they will still be equal. (And I don't see your point, because if you
wrote it like that, you *wanted* it to be able to expand the way it did.)
> The fact we are discussing the very fundamental programming feature -
> control flow - that just does not work as expected (or documented) is
> the main problem with CMake.
That's a strong claim that lacks substantiation.
p.s. Please use '>' to quote like the rest of the world.
--
Matthew
(This should always go without saying when I'm using this e-mail
address, but opinions expressed herein do not necessarily reflect those
of my employer.)
More information about the Development
mailing list