[CMake] Using a variable as a method name

Eric Noulard eric.noulard at gmail.com
Sat Jun 2 03:14:11 EDT 2012


2012/6/1 LaViolette, Alan <ALAVIOLETTE at overwatch.textron.com>:
> Hello
>
> I would like to call a method based on a variable name such as
>
> set( FOO “123”)
> BAR_${FOO}(arg1 arg2)
>
> would do the same as
>
> BAR_123(arg1 arg2)
>
> Does any way exist to do this in CMake, such as a call() or eval() command?

No there is no such thing, however you can create a cmake script file
and then use something like
"cmake -DFOO=123 -P yourscript.cmake"
 to launch a "second" CMake interpreter that will do this evaluation.

This is kind of heavy weight but should work.

You may use
execute_process to launch it at CMake-time
add_custom_command to launch it at Build time.


> "WARNING: Documents that can be viewed, printed or retrieved from this
> E-Mail may contain technical data whose export is restricted by the Arms
> Export Control Act (Title 22, U.S.C., Sec 2751, et seq,) or the Export
> Administration Act of 1979, as amended, Title 50, U.S.C., App. 2401 et seq.
> and which may not be exported, released or disclosed to non-U.S. persons
> (i.e. persons who are not U.S. citizens or lawful permanent residents
> [“green card” holders]) inside or outside the United States, without first
> obtaining an export license.  Violations of these export laws are subject to
> severe civil, criminal and administrative penalties."

I'm not sure such footer is appropriate on a pubic, archived and
international mailing list...



-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list