FILE(REMOVE) and FILE(APPEND) don't resolve relative filenames the same way
Brad King
brad.king at kitware.com
Fri Mar 6 15:06:25 CET 2009
David Faure wrote:
> Testcase:
>
> macro(mymacro)
> FILE(REMOVE out)
> FILE(APPEND out "hello\n")
> endmacro(mymacro)
> add_subdirectory(subdir)
>
> and in subdir/CMakeLists.txt:
> mymacro()
> mymacro()
>
> Expected result: only one line "hello" in the file "subdir/out".
> Actual result: two lines "hello" in the file "subdir/out".
>
> It looks like FILE(REMOVE out) uses the "current dir of the macro" (i.e. the toplevel)
> while FILE(APPEND out) uses the real "current dir" (subdir/).
>
> Is this a bug, or is it expected behavior? I'll play with the commands to get
> absolute paths in order to fix this for now...
At one time we just required people to always use full paths, but around 2.4 we
established the convention that relative paths are interpreted with respect to
the location of the CMakeLists.txt file. It looks like file(REMOVE) was never
taught this convention. However, don't you want this file to be manipulated
in the *build* tree? That will require full paths anyway.
-Brad
More information about the Kde-buildsystem
mailing list