[CMake] intercepting CMakeLists.txt read

Jack Andrews effbiae at gmail.com
Thu Nov 13 08:20:02 EST 2008


hi guys,

i want to generate the CMakeLists.txt just-in-time before cmake reads
it (in each descending directory).  where would be a good place to put
in a callback?

or maybe cmake can read an environment variable (say, CMAKERUN) and if
set, call $CMAKERUN with the path to the current directory

eg.

$ export CMAKERUN=cat %s/mylists

then in source:

descend(char*dir)
{
  char* cmr=getenv("CMAKERUN")
  FILE*fp=0
  if(cmr)
  {
    sprintf(cmr,dir);
    fp=popen(cmr);
  }
  else
    fp=open("CMakeLists.txt");
  char*source=freadall(fp);
  parse_process_etc(source);
  foreach (lowerdir in subdirs(dir))
    descend(lowerdir);
}

i've had a quick look at the source, but i can't find the descending
part of cmake.
also, do the terms of the cmake licence permit modification and
release of modified source?

ta, jack.


More information about the CMake mailing list