[Cmake] cmMakefile::ExpandVariablesInString (ex: DART_ROOT)

Sebastien BARRE sebastien at barre.nom.fr
Fri Aug 17 09:41:27 EDT 2001


Hi

Here is a simple example: the FindDart.cmake module searches for Dart in 
order to set DART_ROOT :

FIND_PATH(DART_ROOT README.INSTALL
     ${PROJECT_SOURCE_DIR}/Dart
      /usr/share/Dart
     "C:/Program Files/Dart"
     ${PROJECT_SOURCE_DIR}/../Dart
     [HKEY_LOCAL_MACHINE\\SOFTWARE\\Dart\\InstallPath]
     )

It tries hard, but it looks weird to me that at this moment it just can not 
handle a very simple (and usual) solution : the user could just have set 
the DART_ROOT environment var (just as CMAKE_ROOT is set for some us, for 
example) and expected Cmake to use it.

I thought env vars were handled by CMake, but indeed they are not, is this 
a design choice ?

This would require a very small change in cmMakefile::ExpandVariablesInString()

Then, we could just modify FindDart.cmake like this :

FIND_PATH(DART_ROOT README.INSTALL
     ${DART_ROOT}
   [...]
     )

and of course this applies to some other modules (and indeed to most 
FOO_ROOT vars).

To avoid potentially dangerous solution were an env var would "override" a 
Cmake var, we could also use a slightly different syntax to require an 
explicit reference to an env var : $ENV{DART_ROOT}

What do you think ?





More information about the CMake mailing list