summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalUnixMakefileGenerator3.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-01-07 21:12:37 (GMT)
committerBrad King <brad.king@kitware.com>2008-01-07 21:12:37 (GMT)
commit52eb0ccac76b0f4066af11d9ed4537204633548a (patch)
tree78505b8e32417eaf945c8a2ca929a11f8c1644cc /Source/cmLocalUnixMakefileGenerator3.cxx
parent9f2790d3e7e5a1e8e564d7f670fe2ff8b28cf6e6 (diff)
downloadCMake-52eb0ccac76b0f4066af11d9ed4537204633548a.zip
CMake-52eb0ccac76b0f4066af11d9ed4537204633548a.tar.gz
CMake-52eb0ccac76b0f4066af11d9ed4537204633548a.tar.bz2
BUG: Restore old interface of "make foo.o" and "make foo.i" even though object file names now include source extensions. For Java we also need to always remove the source extension (.java -> .class). This fixes the re-opening of bug #6169.
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator3.cxx')
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx70
1 files changed, 63 insertions, 7 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 44307c7..0976e17 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -38,6 +38,25 @@
#include <queue>
//----------------------------------------------------------------------------
+// Helper function used below.
+static std::string cmSplitExtension(std::string const& in, std::string& base)
+{
+ std::string ext;
+ std::string::size_type dot_pos = in.rfind(".");
+ if(dot_pos != std::string::npos)
+ {
+ // Remove the extension first in case &base == &in.
+ ext = in.substr(dot_pos, std::string::npos);
+ base = in.substr(0, dot_pos);
+ }
+ else
+ {
+ base = in;
+ }
+ return ext;
+}
+
+//----------------------------------------------------------------------------
cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3()
{
this->SilentNoColon = false;
@@ -298,12 +317,45 @@ void
cmLocalUnixMakefileGenerator3
::WriteObjectConvenienceRule(std::ostream& ruleFileStream,
const char* comment, const char* output,
- LocalObjectInfo const& targets)
+ LocalObjectInfo const& info)
{
+ // If the rule includes the source file extension then create a
+ // version that has the extension removed. The help should include
+ // only the version without source extension.
+ bool inHelp = true;
+ if(info.HasSourceExtension)
+ {
+ // Remove the last extension. This should be kept.
+ std::string outBase1 = output;
+ std::string outExt1 = cmSplitExtension(outBase1, outBase1);
+
+ // Now remove the source extension and put back the last
+ // extension.
+ std::string outNoExt;
+ cmSplitExtension(outBase1, outNoExt);
+ outNoExt += outExt1;
+
+ // Add a rule to drive the rule below.
+ std::vector<std::string> depends;
+ depends.push_back(output);
+ std::vector<std::string> commands;
+ cmGlobalUnixMakefileGenerator3* gg =
+ static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
+ std::string emptyCommand = gg->GetEmptyRuleHackCommand();
+ if(!emptyCommand.empty())
+ {
+ commands.push_back(emptyCommand);
+ }
+
+ this->WriteMakeRule(ruleFileStream, 0,
+ outNoExt.c_str(), depends, commands, true, true);
+ inHelp = false;
+ }
+
// Recursively make the rule for each target using the object file.
std::vector<std::string> commands;
- for(std::vector<LocalObjectEntry>::const_iterator t = targets.begin();
- t != targets.end(); ++t)
+ for(std::vector<LocalObjectEntry>::const_iterator t = info.begin();
+ t != info.end(); ++t)
{
std::string tgtMakefileName =
this->GetRelativeTargetDirectory(*(t->Target));
@@ -322,7 +374,7 @@ cmLocalUnixMakefileGenerator3
// Write the rule to the makefile.
std::vector<std::string> no_depends;
this->WriteMakeRule(ruleFileStream, comment,
- output, no_depends, commands, true, true);
+ output, no_depends, commands, true, inHelp);
}
//----------------------------------------------------------------------------
@@ -1800,13 +1852,16 @@ std::string
cmLocalUnixMakefileGenerator3
::GetObjectFileName(cmTarget& target,
const cmSourceFile& source,
- std::string* nameWithoutTargetDir)
+ std::string* nameWithoutTargetDir,
+ bool* hasSourceExtension)
{
if(const char* fileTargetDirectory =
source.GetProperty("MACOSX_PACKAGE_LOCATION"))
{
// Special handling for OSX package files.
- std::string objectName = this->GetObjectFileNameWithoutTarget(source, 0);
+ std::string objectName =
+ this->GetObjectFileNameWithoutTarget(source, 0,
+ hasSourceExtension);
if(nameWithoutTargetDir)
{
*nameWithoutTargetDir = objectName;
@@ -1857,7 +1912,8 @@ cmLocalUnixMakefileGenerator3
dir_len += 1;
dir_len += obj.size();
std::string objectName =
- this->GetObjectFileNameWithoutTarget(source, dir_len);
+ this->GetObjectFileNameWithoutTarget(source, dir_len,
+ hasSourceExtension);
if(nameWithoutTargetDir)
{
*nameWithoutTargetDir = objectName;