[CMake] CONFIGURE FILE() always expects absolute path

Ken Martin ken.martin at kitware.com
Thu Jul 7 16:03:21 EDT 2005


> current cmake UnixMakefileGenerator3 only works with absolute paths for
> the input file given to CONFIGURE_FILE(). If the filename is given
> without the complete path in a subdir, it searches for the input file in
> CMAKE_SOURCE_DIR instead of CMAKE_CURRENT_SOURCE_DIR.
> Attached is a testcase which failes. It succeeds if the config.h.in is
> put directly in cmake-configure-file/.
> 
> Maybe this is related to the problem with DEPENDS in ADD_CUSTOM_COMMAND
> where the files are also searched relative to CMAKE_SOURCE_DIR instead of
> CMAKE_CURRENT_SOURCE_DIR ?

This has nothing to do with the UnixMakefileGenerator3. In fact the example
doesn't work with 2.0.6 either. It turns out that the command currently
looks in cwd as well (which happens to be CMAKE_SOURCE_DIR) but that is a
coincidence and side effect of the cmSystemTools::FileExists function used
by CONFIGURE_FILE.  Since this seems like a reasonable idea I have modified
the command such that if a full path isn't specified it will prepend the
current source dir. As long as nothing breaks (i.e. no one is relying on the
cwd behavior where cwd is different from current source dir) I'll leave it
that way.

Thanks
Ken




More information about the CMake mailing list