[CMake] override variable in macro

Juan Sanchez Juan.Sanchez at amd.com
Fri Sep 21 09:30:40 EDT 2007


> 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).
>

I can deal with the restriction as long as its documented.
Unfortunately, I didn't catch the reference semantics.  BTW, C++
references are by default mutable, unless they are qualified with const.

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