[Cmake] strange behavior

Stefan Schmidt Stefan.Schmidt at sophia.inria.fr
Fri May 2 11:45:19 EDT 2003


Hello,
I have a strange problem with cmake (1.6.5) that I don't fully understand:

I've some CMake code like this (simplified here), that sets some cache entries 
in a loop:
---
SET (ALLPACKAGES
AuxPkgs/TestData
StdPkgs/ImagePkg
AuxPkgs/Package3
)

FOREACH(PKG ${ALLPACKAGES})
   STRING(REGEX REPLACE "/" "_" PKGNAME ${PKG})
     SET ("${PKGNAME}_DIR" ${CMAKE_BINARY_DIR}/${PKG} CACHE PATH "Location of 
package ${PKG}" FORCE)
ENDFOREACH(PKG)

SUBDIRS(TestSubDir)
---

Additionally to the intended AuxPkgs_TestData_DIR entries, a _DIR entry is 
created with the same value as the last correct one.

This isn't the case when there are no SUBDIRS! Appearently, it has something 
to do with the way CMake processes the subdirectories and rereads (?) the 
parent's CMakeList.
I get around this if I use a (obviously superfluous) IF(PKGNAME)...ENDIF 
around the cache setting.

I think this might either be a bug or the underlying mechanism how CMake 
traverses the SUBDIRs has to be better documented. 


Kind regards,
Stefan



More information about the CMake mailing list