[CMake] Infinite checks for CMakeCache.txt

Brad King brad.king at kitware.com
Tue Dec 21 09:03:49 EST 2004


Nils H.Busch wrote:
>  billlist at nycap.rr.com wrote:
> 
>>Most of the time this is caused by CMake writing one of its input files
> 
> and not using a copy on different.  If you look in the Makefiles you will
> see a CMAKE_MAKEFILE_SOURCES, check to see if your CMakeLists files are
> writing any of those input files.
> 
> Thanks. That is indeed the case.
> 
> In my top-level CMakeLists.txt, I run a FIND_PACKAGE(xxx) for my
> third-party package, which in turn parses the respective third-party
> config	 file and transforms the variable value pairs into CMake variables
> and values and writes them into a file.
> 
> The question is now, how can  I write this file from CMakeLists without
> causing this error. I tried moving accessing the written variables into
> sub directory CMakeLists.txt, copying the written file to another one via
> CONFIGURE_FILE and using that file, but the error remains.
> 
> Maybe, there is an altogether different approach to extracting variables
> and their values from other projects' makefiles, more CMake compliant.
> I guess to solve my specific problem, it would need to do some pattern
> matching and replacing to adjust the way variables are set and accessed.
> Right now, I use a little perl script that does the pattern matching run
> from the above Findxxx.cmake and write the found variable,value pairs in
> CMake notation to file there.

You can use the FILE(READ ...) and STRING(REGEX ...) to parse the file. 
  It isn't as powerful as perl but it can probably get the job done.  It 
will also remove the dependence on having perl installed.

If you really need to use the perl script then you can have it write to 
a file as it does now and then implement copy-if-different in the perl 
script itself.  This could be done either directly in perl or by invoking

   cmake -E copy_if_different src dest

-Brad


More information about the CMake mailing list