[Cmake] Retrieving values from dynamic variables

Brad King brad . king at kitware . com
Wed, 27 Aug 2003 16:58:21 -0400 (EDT)


>             IF("${DEPENDENCY}_VERSION" MATCHES "v0.0.0")
>                   MESSAGE(SEND_ERROR "Version other than v0.0.0 required")
>             ELSE("${DEPENDENCY}_VERSION" MATCHES "v0.0.0")
>                   SET(VERSION ${"${DEPENDENCY}_VERSION"})
>             ENDIF("${DEPENDENCY}_VERSION" MATCHES "v0.0.0")
[snip]
> The OPTION and IF commands work easily but I cannot SET a new variable (see
> line 11) to the value of the variable  whose name is "${DEPENDENCY}
> _VERSION".

This should work:

SET(VERSION "${${DEPENDENCY}_VERSION}")

but only because DEPENDENCY is the loop variable of the FOREACH.
Normally cmake only has one level of ${...} replacement, but the FOREACH
substitutes for ${DEPENDENCY} before evaluating the commands and their
arguments.

-Brad