summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-03-13 17:34:02 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-03-13 17:34:02 (GMT)
commit0707e0d422d2333c7907071774336481947d4354 (patch)
tree89478eac0e660f50b9d5307485fb0fc9b0fccd2f
parent26436346fba7bf535a1cb2d99a9d0647ffde5b0d (diff)
parent1df49282a5649c9ad9f8769cb552423ad74adbfb (diff)
downloadCMake-0707e0d422d2333c7907071774336481947d4354.zip
CMake-0707e0d422d2333c7907071774336481947d4354.tar.gz
CMake-0707e0d422d2333c7907071774336481947d4354.tar.bz2
Merge topic 'add_subdirectory-trailing-slashes'
1df4928 add_subdirectory: Compute output dir with consistent slashes (#10072)
-rw-r--r--Source/cmAddSubDirectoryCommand.cxx15
1 files changed, 10 insertions, 5 deletions
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index 9efeda4..5b1c9c6 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -78,7 +78,7 @@ bool cmAddSubDirectoryCommand::InitialPass
// No binary directory was specified. If the source directory is
// not a subdirectory of the current directory then it is an
// error.
- if(!cmSystemTools::FindLastString(srcPath.c_str(),
+ if(!cmSystemTools::IsSubDirectory(srcPath.c_str(),
this->Makefile->GetCurrentDirectory()))
{
cmOStringStream e;
@@ -93,10 +93,15 @@ bool cmAddSubDirectoryCommand::InitialPass
// Remove the CurrentDirectory from the srcPath and replace it
// with the CurrentOutputDirectory.
- binPath = srcPath;
- cmSystemTools::ReplaceString(binPath,
- this->Makefile->GetCurrentDirectory(),
- this->Makefile->GetCurrentOutputDirectory());
+ const char* src = this->Makefile->GetCurrentDirectory();
+ const char* bin = this->Makefile->GetCurrentOutputDirectory();
+ size_t srcLen = strlen(src);
+ size_t binLen = strlen(bin);
+ if(srcLen > 0 && src[srcLen-1] == '/')
+ { --srcLen; }
+ if(binLen > 0 && bin[binLen-1] == '/')
+ { --binLen; }
+ binPath = std::string(bin, binLen) + srcPath.substr(srcLen);
}
else
{