[Cmake] FW: contruction of variable names

Brad King brad.king at kitware.com
Thu Aug 19 13:58:02 EDT 2004


Dekeyser, Kris wrote:
> # project's name
> SET(ThisProject "LMSCft")
> 
> #--- exported header files
> INCLUDE_DIRECTORIES(${${ThisProject}_SOURCE_DIR}/export/include)

You can use ${PROJECT_SOURCE_DIR} and ${PROJECT_BINARY_DIR} to refer to 
the directories independently of the name of the project.  They refer to 
the directories corresponding to the most recent CMakeLists.txt file to 
invoke the PROJECT command.

> But the include directory is "_SOURCE_DIR}/export/include" in the MSDev
> project file. 
> I expected to have "<Source dir of the LMSCft project>/export/include". It
> seems as if
> the first ${ gets "eaten" by the rest. What did I do wrong?

Nothing.  CMake does not support nested variable name evaluation.

> BTW, in the CMake book (version 1.8) on page 33, the example says:
> IF( ${${tfile}}_TEST_RESULT} MATCHES FAILED)

This is not really a nested evaluation.  That is inside a FOREACH 
command.  The text "${tfile}" is replaced by FOREACH with the current 
iteration's argument before the command is evaluated.

> Notice the unbalanced } due to the double } after tfile. Is that a typo? 

Yes, that is a typo.

-Brad



More information about the Cmake mailing list