summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-02-24 17:19:20 (GMT)
committerBrad King <brad.king@kitware.com>2005-02-24 17:19:20 (GMT)
commitb40745c925eb931d4044596018cd5079b8456ab7 (patch)
tree9a8b55787994c979cec301f688c3989ccfd26190 /Source
parenta21c0449aba62319e84c5d48d21638bc1f5d9d65 (diff)
downloadCMake-b40745c925eb931d4044596018cd5079b8456ab7.zip
CMake-b40745c925eb931d4044596018cd5079b8456ab7.tar.gz
CMake-b40745c925eb931d4044596018cd5079b8456ab7.tar.bz2
BUG: Using a better technique to produce the rule file name for a custom command when the output is not in the current directory or lower.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalUnixMakefileGenerator2.cxx43
-rw-r--r--Source/cmLocalUnixMakefileGenerator2.h1
2 files changed, 12 insertions, 32 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx
index a8023e5..5eec9f7 100644
--- a/Source/cmLocalUnixMakefileGenerator2.cxx
+++ b/Source/cmLocalUnixMakefileGenerator2.cxx
@@ -659,8 +659,15 @@ cmLocalUnixMakefileGenerator2
std::string dir = "CMakeCustomRules.dir";
cmSystemTools::MakeDirectory(this->ConvertToFullPath(dir).c_str());
- // Construct the name of the rule file.
- std::string customName = this->GetCustomBaseName(cc);
+ // Convert the output name to a relative path if possible.
+ std::string output = this->ConvertToRelativePath(cc.GetOutput());
+
+ // Construct the name of the rule file by transforming the output
+ // name to a valid file name. Since the output is already a file
+ // everything but the path characters is valid.
+ std::string customName = output;
+ cmSystemTools::ReplaceString(customName, "../", "___");
+ cmSystemTools::ReplaceString(customName, "/", "_");
std::string ruleFileName = dir;
ruleFileName += "/";
ruleFileName += customName;
@@ -689,7 +696,7 @@ cmLocalUnixMakefileGenerator2
}
this->WriteDisclaimer(ruleFileStream);
ruleFileStream
- << "# Custom command rule file for " << customName.c_str() << ".\n\n";
+ << "# Custom command rule file for " << output.c_str() << ".\n\n";
// Collect the commands.
std::vector<std::string> commands;
@@ -709,13 +716,13 @@ cmLocalUnixMakefileGenerator2
comment = cc.GetComment();
}
std::string preEcho = "Generating ";
- preEcho += customName;
+ preEcho += output;
preEcho += "...";
this->WriteMakeRule(ruleFileStream, comment, preEcho.c_str(),
cc.GetOutput(), depends, commands);
// Write the clean rule for this custom command.
- std::string cleanTarget = customName;
+ std::string cleanTarget = output;
cleanTarget += ".clean";
commands.clear();
depends.clear();
@@ -2281,32 +2288,6 @@ cmLocalUnixMakefileGenerator2
}
//----------------------------------------------------------------------------
-std::string
-cmLocalUnixMakefileGenerator2
-::GetCustomBaseName(const cmCustomCommand& cc)
-{
- // If the full path to the output file includes this build
- // directory, we want to use the relative path for the filename of
- // the custom file. Otherwise, we will use just the filename
- // portion.
- std::string customName;
- if(cmSystemTools::FileIsFullPath(cc.GetOutput()) &&
- (std::string(cc.GetOutput()).find(m_Makefile->GetStartOutputDirectory()) == 0))
- {
- // Use the relative path but convert it to a valid file name.
- customName =
- cmSystemTools::RelativePath(m_Makefile->GetStartOutputDirectory(),
- cc.GetOutput());
- cmSystemTools::ReplaceString(customName, "/", "_");
- }
- else
- {
- customName = cmSystemTools::GetFilenameName(cc.GetOutput());
- }
- return customName;
-}
-
-//----------------------------------------------------------------------------
const char*
cmLocalUnixMakefileGenerator2
::GetSourceFileLanguage(const cmSourceFile& source)
diff --git a/Source/cmLocalUnixMakefileGenerator2.h b/Source/cmLocalUnixMakefileGenerator2.h
index ed83081..efa03cd 100644
--- a/Source/cmLocalUnixMakefileGenerator2.h
+++ b/Source/cmLocalUnixMakefileGenerator2.h
@@ -196,7 +196,6 @@ protected:
std::string GetSubdirTargetName(const char* pass, const char* subdir);
std::string GetObjectFileName(const cmTarget& target,
const cmSourceFile& source);
- std::string GetCustomBaseName(const cmCustomCommand& cc);
const char* GetSourceFileLanguage(const cmSourceFile& source);
std::string ConvertToFullPath(const std::string& localPath);
std::string ConvertToRelativePath(const char* p);