[CMake] Working directory issue with CMake 2.8.0
Brad King
brad.king at kitware.com
Wed Nov 18 10:44:07 EST 2009
Yannick Mortier wrote:
> Hello!
>
> We just tried out CMake 2.8.0 today and we found that our old CMake
> build scripts don't work anymore.
>
> One particular error was related to the handling of the current working
> directory of the function
> get_filename_component(FULLPATH ${SUBDIRECTORY} REALPATH)
>
> I used this function in a small macro to get the full path of a
> subdirectory in a certain CMakeLists.txt.
>
> The behaviour of CMake 2.6.4 was to use the path of the CMakeLists.txt
> as the working dir.
> So for example calling this function on ../subdir in
> c:\foo\bar\projectpart\CMakeLists.txt would have returned C:/foo/bar/subdir
> Now the result of this function seems to depent from the working dir
> from which cmake was called.
> So if I have opened up my console window in c:\my\build\tree the same
> call of this function returns c:/my/build/subdir
>
> After calling this function I add the subdirectory using
> add_subdirectory(${SUBDIRECTORY} PROJECTNAME) which works in both cases
> regardless of what the working directory of the console window was.
>
> I just checked the list of changes and I didn't find this listed there
> officially. Was this an intentional change or is it a bug?
It's a bug, and it will be fixed in 2.8.1.
You can avoid this problem completely by using
get_filename_component(FULLPATH
${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY} ABSOLUTE)
which should work for both 2.6 and 2.8.0.
-Brad
More information about the CMake
mailing list