[Cmake] Retrieving values from dynamic variables

hvanderpool@xn-tech.com hvanderpool at xn-tech . com
Wed, 27 Aug 2003 13:23:01 -0700


I am able to create variables dynamically and use them in a number of the
CMake expressions.  However, I am unable to come up with an expression that
can retrieve the value of the dynamic variable.  See the CMakeLists.txt
example:

#INCLUDE(${CMAKE_ROOT}/Modules/VSSGetClean.cmake)

PROJECT(ThisProject)
SET(PROJECT_DEPENDENCIES Depend1 Depend2 Depend3)
FOREACH(DEPENDENCY ${PROJECT_DEPENDENCIES})
      OPTION("${DEPENDENCY}_FORMAL" "Build the dependent project
${DEPENDENCY} from scratch" OFF)
      SET("${DEPENDENCY}_VERSION" "v0.0.0" CACHE STRING "Version of the
dependent project ${DEPENDENCY}")
      IF("${DEPENDENCY}_FORMAL")
            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"})
                  #VSS_GET_CLEAN("$/XNet/${DEPENDENCY}" ${VERSION}
${ThisProject_SOURCE_DIR})
                  #SUBDIRS(${DEPENDENCY})
            ENDIF("${DEPENDENCY}_VERSION" MATCHES "v0.0.0")
      ENDIF("${DEPENDENCY}_FORMAL")

ENDFOREACH(DEPENDENCY ${PROJECT_DEPENDENCIES})

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 evaluation also fails as a parameter in the macro call
VSS_GET_CLEAN.  (Note:  I have commented out the include, macro, and
subdirs calls so it will run on your machine(s) but left them in place so
you can see the intention.)

Can this, or something similar, be accomplished in the current CMake?

Of course, I could hard code this for every project, but it would be
simpler to have a single chunk of re-usable code.  My goal is to enable a
build for ThisProject from dependent libraries that are either generated
from repository source or using ones that already exist, depending on the
devlopers needs.  Even better would be to be able to use SUBDIRS to point
to a complete other CMAKE project (not necessarily in a sub-folder) that
would be incorporated into the build chain complete with additions to
CMakeSetup ui and cache.  But I haven't made any progress in that pipe
dream at all.

Thanks for keeping the mailing list so active.