Variable evaluation in command parameters

Hello,

I am trying to understand why a target in some CMakeLists.txt is built with VS 2022, whereas it is supposed to be build with the VS 2017 generator.

I didn’t code this CMakeLists, but somethings seems strange to me.

There is a call to ExternalProject_Add(), and the generator parameter is given with a variable, whose value is returned by a function.

set(generator_var "CMAKE_GENERATOR;Visual Studio 2017") # Is actually retrieved from a function

ExternalProject_Add(MyProj
    ...
    ${generator_var} # Expected to be evaluated, I guess, as CMAKE_GENERATOR "Visual Studio 2017"
    LOG_CONFIGURE ON
    ...
)

Actually, I found that at work, I am at home now, and I am not sure if there are, in the list, quotes around Visual Studio 2017 (sorry, I’m in Europe, and I didn’t want the american guys escaped me !).

But my question is : is the list splitted so that I am supposed to get the expected result ??
I tried to add LOG_CONFIGURE, but I didn’t find where was put the log…

Personnally, I would have put in the variable only “Visual Studio 2017”, and coded :

set(generator_var "Visual Studio 2017") # Is actually retrieved from a function

ExternalProject_Add(MyProj
    ...
    CMAKE_GENERATOR  ${generator_var}
    LOG_CONFIGURE ON
    ...
)

I finally found the answer to my question in an interesting post of @craig.scott :

I had read (again) in his book the chapter about lists (§6.7), but not the one about functions arguments (§9.2). I’ll see that this evening…