From e4ec89d0360408cc4ad2bb6428be06749d8b11ba Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 2 Oct 2006 10:20:53 -0400 Subject: ENH: Added SYMBOLIC source file property to mark custom command outputs that are never actually created on disk. This is used by the Watcom WMake generator to generate the .SYMBOLIC mark on the files in the make system. --- Source/cmAddCustomCommandCommand.h | 5 ++++- Source/cmGlobalGenerator.cxx | 3 +++ Source/cmGlobalGenerator.h | 5 +++++ Source/cmGlobalWatcomWMakeGenerator.cxx | 1 + Source/cmMakefile.cxx | 11 +++++++++++ Source/cmMakefileTargetGenerator.cxx | 25 +++++++++++++++++++++++-- Source/cmSetSourceFilesPropertiesCommand.h | 5 ++++- 7 files changed, 51 insertions(+), 4 deletions(-) diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index 73bd881..fdea26a 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -112,7 +112,10 @@ public: "Use of VERBATIM is recommended as it enables correct behavior. " "When VERBATIM is not given the behavior is platform specific. " "In the future VERBATIM may be enabled by default. The only reason " - "it is an option is to preserve compatibility with older CMake code."; + "it is an option is to preserve compatibility with older CMake code.\n" + "If the output of the custom command is not actually " + "created as a file on disk it should be marked as SYMBOLIC with " + "SET_SOURCE_FILES_PROPERTIES."; } cmTypeMacro(cmAddCustomCommandCommand, cmCommand); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4b895e2..8c81f08 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -31,6 +31,9 @@ int cmGlobalGenerator::s_TryCompileTimeout = 0; cmGlobalGenerator::cmGlobalGenerator() { + // By default the .SYMBOLIC dependency is not needed on symbolic rules. + this->NeedSymbolicMark = false; + // by default use the native paths this->ForceUnixPaths = false; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 7c6caf0..d95a555 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -156,6 +156,10 @@ public: /** Get whether the generator should use a script for link commands. */ bool GetUseLinkScript() { return this->UseLinkScript; } + /** Get whether the generator should produce special marks on rules + producing symbolic (non-file) outputs. */ + bool GetNeedSymbolicMark() { return this->NeedSymbolicMark; } + /* * Determine what program to use for building the project. */ @@ -210,6 +214,7 @@ protected: const cmCustomCommandLines* commandLines, std::vector depends, bool depends_on_all = false); + bool NeedSymbolicMark; bool UseLinkScript; bool ForceUnixPaths; bool ToolSupportsColor; diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 8fd4b30..6f6c8cf 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -23,6 +23,7 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator() this->FindMakeProgramFile = "CMakeFindWMake.cmake"; this->ForceUnixPaths = false; this->ToolSupportsColor = true; + this->NeedSymbolicMark = true; this->EmptyCommandsHack = "@cd ."; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8ad4139..8799e52 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -846,6 +846,17 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, bool all, escapeOldStyle); target.GetSourceLists().push_back(force); + // The output is not actually created so mark it symbolic. + if(cmSourceFile* sf = this->GetSource(force.c_str())) + { + sf->SetProperty("SYMBOLIC", "1"); + } + else + { + cmSystemTools::Error("Could not get source file entry for ", + force.c_str()); + } + // Add the target to the set of targets. cmTargets::iterator it = this->Targets.insert(cmTargets::value_type(utilityName,target)).first; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index cc16069..449d37a 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -862,12 +862,25 @@ void cmMakefileTargetGenerator std::vector depends; this->LocalGenerator->AppendCustomDepend(depends, cc); + // Check whether we need to bother checking for a symbolic output. + bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark(); + // Write the rule. const std::vector& outputs = cc.GetOutputs(); std::vector::const_iterator o = outputs.begin(); + { + bool symbolic = false; + if(need_symbolic) + { + if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str())) + { + symbolic = sf->GetPropertyAsBool("SYMBOLIC"); + } + } this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, o->c_str(), depends, commands, - false); + symbolic); + } // If the rule has multiple outputs, add a rule for the extra // outputs to just depend on the first output with no command. Also @@ -887,9 +900,17 @@ void cmMakefileTargetGenerator } for(++o; o != outputs.end(); ++o) { + bool symbolic = false; + if(need_symbolic) + { + if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str())) + { + symbolic = sf->GetPropertyAsBool("SYMBOLIC"); + } + } this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, o->c_str(), depends, commands, - false); + symbolic); gg->AddMultipleOutputPair(o->c_str(), depends[0].c_str()); } } diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h index c1501f9..63d3f73 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.h +++ b/Source/cmSetSourceFilesPropertiesCommand.h @@ -74,7 +74,10 @@ public: "only used by Makefiles). " "OBJECT_DEPENDS (string) adds dependencies to the object file. " "COMPILE_FLAGS (string) is passed to the compiler as additional " - "command line arguments when the source file is compiled. "; + "command line arguments when the source file is compiled. " + "If SYMBOLIC (boolean) is set to true the build system will be " + "informed that the source file is not actually created on disk but " + "instead used as a symbolic name for a build rule."; } -- cgit v0.12