diff options
author | Brad King <brad.king@kitware.com> | 2006-06-05 18:38:16 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-06-05 18:38:16 (GMT) |
commit | df70e3de66eb6821570db89d9f631a25f353694e (patch) | |
tree | 03262ce163504ef11015cef970edbdf17a0fcf62 /Source/cmAddSubDirectoryCommand.cxx | |
parent | 7d5bc02c9d18278d47e81db766aa66c1797eafee (diff) | |
download | CMake-df70e3de66eb6821570db89d9f631a25f353694e.zip CMake-df70e3de66eb6821570db89d9f631a25f353694e.tar.gz CMake-df70e3de66eb6821570db89d9f631a25f353694e.tar.bz2 |
BUG: Always check whether a subdirectory is below the top of the source before computing the binary tree automatically. Even when the source is a relative path it may contain ../ which would allow it to be outside the source tree.
Diffstat (limited to 'Source/cmAddSubDirectoryCommand.cxx')
-rw-r--r-- | Source/cmAddSubDirectoryCommand.cxx | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 5e13150..8f28499 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -74,6 +74,7 @@ bool cmAddSubDirectoryCommand::InitialPass // at this point srcPath has the full path to the source directory // now we need to compute the binPath if it was not provided + srcPath = cmSystemTools::CollapseFullPath(srcPath.c_str()); // if the argument was provided then use it if (binArg.size()) @@ -87,34 +88,25 @@ bool cmAddSubDirectoryCommand::InitialPass // otherwise compute the binPath from the srcPath else { - // if the srcArg was relative then we just do the same for the binPath - if (relativeSource) - { - binPath = std::string(this->Makefile->GetCurrentOutputDirectory()) + - "/" + srcArg; - } - // otherwise we try to remove the CurrentDirectory from the srcPath and + // we try to remove the CurrentDirectory from the srcPath and // replace it with the CurrentOutputDirectory. This may not really work // because the source dir they provided may not be "in" the source // tree. This is an error if this happens. - else + // try replacing the home dir with the home output dir + binPath = srcPath; + if(!cmSystemTools::FindLastString(binPath.c_str(), + this->Makefile->GetHomeDirectory())) { - // try replacing the home dir with the home output dir - binPath = srcPath; - if (!cmSystemTools::FindLastString(binPath.c_str(), - this->Makefile->GetHomeDirectory())) - { - this->SetError("A full source directory was specified that is not " - "in the source tree but no binary directory was " - "specified. If you specify an out of tree source " - "directory then you must provide the binary " - "directory as well."); - return false; - } - cmSystemTools::ReplaceString(binPath, - this->Makefile->GetHomeDirectory(), - this->Makefile->GetHomeOutputDirectory()); + this->SetError("A full source directory was specified that is not " + "in the source tree but no binary directory was " + "specified. If you specify an out of tree source " + "directory then you must provide the binary " + "directory as well."); + return false; } + cmSystemTools::ReplaceString(binPath, + this->Makefile->GetHomeDirectory(), + this->Makefile->GetHomeOutputDirectory()); } // now we have all the arguments |