[CMake] override variable in macro
Juan Sanchez
Juan.Sanchez at amd.com
Fri Sep 21 11:44:23 EDT 2007
What I was trying to do was to avoid having to create a local variable.
The macro parameter is the default, which can be overridden if necessary.
Now I immediately have to set a new variable with the value of the
parameter. So I now have to account for another variable being created
which may then escape the macro's namespace.
Can we have the SET command fail on trying to set a macro parameter?
Juan
Dizzy wrote:
> On Thursday 20 September 2007 20:38:38 Juan Sanchez wrote:
>> It appears that the set command cannot override a variable specified as
>> a MACRO argument.
>>
>> For example:
>> MACRO (ADD_GADB RCMD)
>>
>> does not accept changes to RCMD within the macro using the set command.
>> Is there a way to override this?
>
> As I understand it (from reading various cmake macros) is that
> MACRO "parameters" are not variables. They are "names of variables", they
> are "aliases" to variables if you wish. So when you call a macro with the
> parameter "someVAR" that in the macro is made to be received as "VARIABLE"
> then "VARIABLE" acts like a variable holding the NAME of the argument given
> variable (ie holding "someVAR") so then if you need to write/read someVAR you
> need to "dereference" VARIABLE (ie SET(${VARIABLE} "value") and not
> SET(VARIABLE "value")).
>
> I haven't tried but the macro parameters might be immutable themselves (like
> C++ references :) ) so SET(VARIABLE something) might not be supported (but
> then again why would you ever need such a thing).
>
--
Juan Sanchez
Juan.Sanchez at amd.com
800-538-8450 Ext. 54395
512-602-4395
More information about the CMake
mailing list