[CMake] Re: Out of source build and KDevelop

William A. Hoffman billlist at nycap.rr.com
Wed Oct 13 11:36:30 EDT 2004


At 02:16 AM 10/13/2004, Alexander Neundorf wrote:

>I also didn't understand how RelativePath() works. 
>If I had e.g. /usr/src/test/blah/foo.cpp and as directory /usr/src/, it
>returned 
>../test/blah/foo.cpp. This is not what I expected ( test/blah/foo.cpp). 
> 


It didn't!

I have just checked in a fix for RelativePath,
and added better comments.

  /** compute the relative path from local to remote.  local must 
      be a directory.  remote can be a file or a directory.  
      Both remote and local must be full paths.  Basically, if
      you are in directory local and you want to access the file in remote
      what is the relative path to do that.  For example:
      /a/b/c/d to /a/b/c1/d1 -> ../../c1/d1
      from /usr/src to /usr/src/test/blah/foo.cpp -> test/blah/foo.cpp
  */
  static std::string RelativePath(const char* local, const char* remote);

Some other examples:

from /a/b/c/d to /a/b/c1/d1 -> ../../c1/d1
from /usr/src/test/blah to /usr/src -> ../../
from /usr/src to /usr/src/test/blah/foo.cpp -> test/blah/foo.cpp
from a:/usr/src to a:/usr/src/test/blah/foo.cpp -> test/blah/foo.cpp
from a:/usr/SRC to a:/usr/src/test/blah/foo.cpp -> test/blah/foo.cpp
from b:/usr/src to c:/usr/src/test/blah/foo.cpp -> c:/usr/src/test/blah/foo.cpp

-Bill 



More information about the CMake mailing list