diff options
author | Ken Martin <ken.martin@kitware.com> | 2005-05-06 18:49:38 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2005-05-06 18:49:38 (GMT) |
commit | 0cb20474d81c1193e0e00ed04b83e5980f9d8dc5 (patch) | |
tree | 9d71ccaf93c06fc4f931576672d34b4da3f28db9 /Source/cmLocalUnixMakefileGenerator3.cxx | |
parent | dc75c22645f16f3781513e51ae6488df058d69e4 (diff) | |
download | CMake-0cb20474d81c1193e0e00ed04b83e5980f9d8dc5.zip CMake-0cb20474d81c1193e0e00ed04b83e5980f9d8dc5.tar.gz CMake-0cb20474d81c1193e0e00ed04b83e5980f9d8dc5.tar.bz2 |
ENH: updates
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator3.cxx')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 718 |
1 files changed, 276 insertions, 442 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 88bcb10..43dd5c1 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -34,9 +34,6 @@ #include <memory> // auto_ptr #include <queue> -// TODO: Convert makefile name to a runtime switch. -#define CMLUMG_MAKEFILE_NAME "Makefile" - // TODO: Add "help" target. // TODO: Identify remaining relative path violations. // TODO: Need test for separate executable/library output path. @@ -58,16 +55,6 @@ cmLocalUnixMakefileGenerator3::~cmLocalUnixMakefileGenerator3() } //---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::SetEmptyCommand(const char* cmd) -{ - m_EmptyCommands.clear(); - if(cmd) - { - m_EmptyCommands.push_back(cmd); - } -} - -//---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::Generate() { // Setup our configuration variables for this directory. @@ -82,20 +69,69 @@ void cmLocalUnixMakefileGenerator3::Generate() (t->second.GetType() == cmTarget::SHARED_LIBRARY) || (t->second.GetType() == cmTarget::MODULE_LIBRARY)) { - this->GenerateTargetRuleFile(t->second); + this->WriteTargetRuleFiles(t->second); } else if(t->second.GetType() == cmTarget::UTILITY) { - this->GenerateUtilityRuleFile(t->second); + this->WriteUtilityRuleFiles(t->second); } } this->WriteCustomCommands(); - // Generate the cmake file with information for this directory. - this->GenerateDirectoryInformationFile(); + // Write the cmake file with information for this directory. + this->WriteDirectoryInformationFile(); +} + + +//---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3::ConfigureOutputPaths() +{ + // Format the library and executable output paths. + if(const char* libOut = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) + { + m_LibraryOutputPath = libOut; + this->FormatOutputPath(m_LibraryOutputPath, "LIBRARY"); + } + if(const char* exeOut = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) + { + m_ExecutableOutputPath = exeOut; + this->FormatOutputPath(m_ExecutableOutputPath, "EXECUTABLE"); + } +} + +//---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3::FormatOutputPath(std::string& path, + const char* name) +{ + if(!path.empty()) + { + // Convert the output path to a full path in case it is + // specified as a relative path. Treat a relative path as + // relative to the current output directory for this makefile. + path = + cmSystemTools::CollapseFullPath(path.c_str(), + m_Makefile->GetStartOutputDirectory()); + + // Add a trailing slash for easy appending later. + if(path.empty() || path[path.size()-1] != '/') + { + path += "/"; + } + + // Make sure the output path exists on disk. + if(!cmSystemTools::MakeDirectory(path.c_str())) + { + cmSystemTools::Error("Error failed to create ", + name, "_OUTPUT_PATH directory:", path.c_str()); + } + + // Add this as a link directory automatically. + m_Makefile->AddLinkDirectory(path.c_str()); + } } + void cmLocalUnixMakefileGenerator3::WriteCustomCommands() { // Generate the rule files for each custom command. @@ -135,7 +171,6 @@ void cmLocalUnixMakefileGenerator3::WriteCustomCommands() << this->ConvertToOutputForExisting(objTarget.c_str()).c_str() << "\n"; } - // now do the clean ruleFileName = "CMakeCustomRules.dir/clean.make"; @@ -182,7 +217,7 @@ void cmLocalUnixMakefileGenerator3::WriteCustomCommands() } //---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::GenerateDirectoryInformationFile() +void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() { std::string infoFileName = m_Makefile->GetStartOutputDirectory(); infoFileName += "/CMakeDirectoryInformation.cmake"; @@ -246,6 +281,29 @@ void cmLocalUnixMakefileGenerator3::GenerateDirectoryInformationFile() << "SET(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})\n"; } +//---------------------------------------------------------------------------- +std::string +cmLocalUnixMakefileGenerator3 +::ConvertToFullPath(const std::string& localPath) +{ + std::string dir = m_Makefile->GetStartOutputDirectory(); + dir += "/"; + dir += localPath; + return dir; +} + + +//---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os) +{ + os + << "# CMAKE generated file: DO NOT EDIT!\n" + << "# Generated by \"" << m_GlobalGenerator->GetName() << "\"" + << " Generator, CMake Version " + << cmMakefile::GetMajorVersion() << "." + << cmMakefile::GetMinorVersion() << "\n\n"; +} + std::string cmLocalUnixMakefileGenerator3::GetHomeRelativeOutputPath() { // Include the rule file for each object. @@ -262,7 +320,7 @@ std::string cmLocalUnixMakefileGenerator3::GetHomeRelativeOutputPath() //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 -::GenerateTargetRuleFile(const cmTarget& target) +::WriteTargetRuleFiles(const cmTarget& target) { // Create a directory for this target. std::string dir = this->GetTargetDirectory(target); @@ -283,8 +341,7 @@ cmLocalUnixMakefileGenerator3 if(!m_GlobalGenerator->IgnoreFile((*source)->GetSourceExtension().c_str())) { // Generate this object file's rule file. - this->GenerateObjectRuleFile(target, *(*source), objects, - provides_requires); + this->WriteObjectRuleFiles(target, *(*source), objects,provides_requires); } else if((*source)->GetPropertyAsBool("EXTERNAL_OBJECT")) { @@ -303,9 +360,6 @@ cmLocalUnixMakefileGenerator3 std::string ruleFileName = dir; ruleFileName += "/build.make"; - // The rule file must be included by the makefile. - m_IncludeRuleFiles.push_back(ruleFileName); - // Open the rule file. This should be copy-if-different because the // rules may depend on this file itself. std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); @@ -370,13 +424,22 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 -::GenerateObjectDependFile(const std::string& obj, const cmSourceFile& source, - std::vector<std::string>& objects, - std::vector<std::string>& provides_requires, - const std::string& depMarkFile, - std::vector<std::string>& depends) +::WriteObjectDependFile(std::string &obj, + const char * lang, + const cmSourceFile& source, + std::vector<std::string>& depends, + std::string& depMakeFile) { - const char* lang = this->GetSourceFileLanguage(source); + // TODO: what the heck is this? + // Generate the build-time dependencies file for this object file. + std::string depMarkFile; + if(!this->GenerateDependsMakeFile(lang, obj.c_str(), + depMakeFile, depMarkFile)) + { + cmSystemTools::Error("No dependency checker available for language \"", + lang, "\"."); + return; + } // Open the rule file for writing. This should be copy-if-different // because the rules may depend on this file itself. @@ -441,68 +504,14 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 -::GenerateObjectRuleFile(const cmTarget& target, const cmSourceFile& source, - std::vector<std::string>& objects, - std::vector<std::string>& provides_requires) +::WriteObjectBuildFile(std::string &obj, + const char *lang, + const cmTarget& target, + const cmSourceFile& source, + std::vector<std::string>& depends, + std::string &depMakeFile, + std::vector<std::string>& provides_requires) { - // Identify the language of the source file. - const char* lang = this->GetSourceFileLanguage(source); - if(!lang) - { - // If language is not known, this is an error. - cmSystemTools::Error("Source file \"", source.GetFullPath().c_str(), - "\" has unknown type."); - return; - } - - // Get the full path name of the object file. - std::string obj = this->GetObjectFileName(target, source); - - // Avoid generating duplicate rules. - if(m_ObjectFiles.find(obj) == m_ObjectFiles.end()) - { - m_ObjectFiles.insert(obj); - } - else - { - cmOStringStream err; - err << "Warning: Source file \"" - << source.GetSourceName().c_str() << "." - << source.GetSourceExtension().c_str() - << "\" is listed multiple times for target \"" << target.GetName() - << "\"."; - cmSystemTools::Message(err.str().c_str(), "Warning"); - return; - } - - // Create the directory containing the object file. This may be a - // subdirectory under the target's directory. - std::string dir = cmSystemTools::GetFilenamePath(obj.c_str()); - cmSystemTools::MakeDirectory(this->ConvertToFullPath(dir).c_str()); - - // Generate the build-time dependencies file for this object file. - std::string depMakeFile; - std::string depMarkFile; - if(!this->GenerateDependsMakeFile(lang, obj.c_str(), - depMakeFile, depMarkFile)) - { - cmSystemTools::Error("No dependency checker available for language \"", - lang, "\"."); - return; - } - - // Save this in the target's list of object files. - objects.push_back(obj); - std::string relativeObj = this->GetHomeRelativeOutputPath(); - relativeObj += obj; - - // The object file should be checked for dependency integrity. - m_CheckDependFiles[lang].insert(obj); - - // write the .depends.make file - std::vector<std::string> depends; - this->GenerateObjectDependFile(obj,source,objects,provides_requires,depMarkFile,depends); - // Open the rule file for writing. This should be copy-if-different // because the rules may depend on this file itself. std::string ruleFileName = obj; @@ -570,6 +579,8 @@ cmLocalUnixMakefileGenerator3 this->ConvertToRelativeOutputPath(obj.c_str()); // Construct the build message. + std::string relativeObj = this->GetHomeRelativeOutputPath(); + relativeObj += obj; std::vector<std::string> commands; std::string buildEcho = "Building "; buildEcho += lang; @@ -629,6 +640,91 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 +::WriteObjectRuleFiles(const cmTarget& target, const cmSourceFile& source, + std::vector<std::string>& objects, + std::vector<std::string>& provides_requires) +{ + // Identify the language of the source file. + const char* lang = this->GetSourceFileLanguage(source); + if(!lang) + { + // If language is not known, this is an error. + cmSystemTools::Error("Source file \"", source.GetFullPath().c_str(), + "\" has unknown type."); + return; + } + + // Get the full path name of the object file. + std::string obj = this->GetObjectFileName(target, source); + + // Avoid generating duplicate rules. + if(m_ObjectFiles.find(obj) == m_ObjectFiles.end()) + { + m_ObjectFiles.insert(obj); + } + else + { + cmOStringStream err; + err << "Warning: Source file \"" + << source.GetSourceName().c_str() << "." + << source.GetSourceExtension().c_str() + << "\" is listed multiple times for target \"" << target.GetName() + << "\"."; + cmSystemTools::Message(err.str().c_str(), "Warning"); + return; + } + + // Create the directory containing the object file. This may be a + // subdirectory under the target's directory. + std::string dir = cmSystemTools::GetFilenamePath(obj.c_str()); + cmSystemTools::MakeDirectory(this->ConvertToFullPath(dir).c_str()); + + // Save this in the target's list of object files. + objects.push_back(obj); + std::string relativeObj = this->GetHomeRelativeOutputPath(); + relativeObj += obj; + + // we compute some depends when writing the depend.make that we will also + // use in the build.make, same with depMakeFile + std::vector<std::string> depends; + std::string depMakeFile; + + // generate the depends rule file + this->WriteObjectDependFile(obj, lang, source, depends, depMakeFile); + + // generate the build rule file + this->WriteObjectBuildFile(obj, lang, target, source, depends, depMakeFile, + provides_requires); + + // The object file should be checked for dependency integrity. + m_CheckDependFiles[lang].insert(relativeObj); + + // If the language needs provides-requires mode, create the + // corresponding targets. +/* + if(strcmp(lang, "Fortran") == 0) + { + std::string objectRequires = obj; + std::string objectProvides = obj; + objectRequires += ".requires"; + objectProvides += ".provides"; + + // Add the provides target to build the object file. + std::vector<std::string> no_commands; + std::vector<std::string> p_depends; + p_depends.push_back(obj); + this->WriteMakeRule(ruleFileStream, 0, + objectProvides.c_str(), p_depends, no_commands); + + // Add this to the set of provides-requires objects on the target. + provides_requires.push_back(objectRequires); + } +*/ +} + +//---------------------------------------------------------------------------- +void +cmLocalUnixMakefileGenerator3 ::GenerateCustomRuleFile(const cmCustomCommand& cc) { // Create a directory for custom rule files. @@ -659,9 +755,6 @@ cmLocalUnixMakefileGenerator3 } m_CustomRuleFiles.insert(ruleFileName); - // This rule should be included by the makefile. - m_IncludeRuleFiles.push_back(ruleFileName); - // what is the relative path to the rule file std::string relRuleFile = this->GetHomeRelativeOutputPath(); relRuleFile += ruleFileName; @@ -707,7 +800,7 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 -::GenerateUtilityRuleFile(const cmTarget& target) +::WriteUtilityRuleFiles(const cmTarget& target) { // Create a directory for this target. std::string dir = this->GetTargetDirectory(target); @@ -717,9 +810,6 @@ cmLocalUnixMakefileGenerator3 std::string ruleFileName = dir; ruleFileName += "/build.make"; - // This rule should be included by the makefile. - m_IncludeRuleFiles.push_back(ruleFileName); - // Open the rule file. This should be copy-if-different because the // rules may depend on this file itself. std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); @@ -785,9 +875,11 @@ cmLocalUnixMakefileGenerator3 depMakeFile = checker->GetMakeFileName(); depMarkFile = checker->GetMarkFileName(); + + // Todo is this required??? // Check the dependencies. checker->Check(); - + return true; } return false; @@ -867,6 +959,88 @@ cmLocalUnixMakefileGenerator3 os << "\n"; } +//---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3::WriteDivider(std::ostream& os) +{ + os + << "#======================================" + << "=======================================\n"; +} + +//---------------------------------------------------------------------------- +void +cmLocalUnixMakefileGenerator3 +::WriteMakeVariables(std::ostream& makefileStream) +{ + this->WriteDivider(makefileStream); + makefileStream + << "# Set environment variables for the build.\n" + << "\n"; + if(m_WindowsShell) + { + makefileStream + << "!IF \"$(OS)\" == \"Windows_NT\"\n" + << "NULL=\n" + << "!ELSE\n" + << "NULL=nul\n" + << "!ENDIF\n"; + } + else + { + makefileStream + << "# The shell in which to execute make rules.\n" + << "SHELL = /bin/sh\n" + << "\n"; + } + + if(m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) + { + makefileStream + << "# Produce verbose output by default.\n" + << "VERBOSE = 1\n" + << "\n"; + } + + std::string cmakecommand = + this->ConvertToOutputForExisting( + m_Makefile->GetRequiredDefinition("CMAKE_COMMAND")); + makefileStream + << "# The CMake executable.\n" + << "CMAKE_COMMAND = " + << m_GlobalGenerator->ConvertToHomeRelativeOutputPath + (cmakecommand.c_str()).c_str() << "\n" + << "\n"; + makefileStream + << "# The command to remove a file.\n" + << "RM = " + << this->ConvertToRelativeOutputPath(cmakecommand.c_str()).c_str() + << " -E remove -f\n" + << "\n"; + + if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) + { + makefileStream + << "# The program to use to edit the cache.\n" + << "CMAKE_EDIT_COMMAND = " + << (this->ConvertToOutputForExisting( + m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))) << "\n" + << "\n"; + } + + makefileStream + << "# The top-level source directory on which CMake was run.\n" + << "CMAKE_SOURCE_DIR = " + << this->ConvertToRelativeOutputPath(m_Makefile->GetHomeDirectory()) + << "\n" + << "\n"; + makefileStream + << "# The top-level build directory on which CMake was run.\n" + << "CMAKE_BINARY_DIR = " + << this->ConvertToRelativeOutputPath(m_Makefile->GetHomeOutputDirectory()) + << "\n" + << "\n"; +} + void cmLocalUnixMakefileGenerator3::WriteTargetIncludes(std::ostream& makefileStream, const char *file, const char *rule) @@ -973,98 +1147,6 @@ cmLocalUnixMakefileGenerator3 } } -//---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::WriteDivider(std::ostream& os) -{ - os - << "#======================================" - << "=======================================\n"; -} - -//---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os) -{ - os - << "# CMAKE generated file: DO NOT EDIT!\n" - << "# Generated by \"" << m_GlobalGenerator->GetName() << "\"" - << " Generator, CMake Version " - << cmMakefile::GetMajorVersion() << "." - << cmMakefile::GetMinorVersion() << "\n\n"; -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteMakeVariables(std::ostream& makefileStream) -{ - this->WriteDivider(makefileStream); - makefileStream - << "# Set environment variables for the build.\n" - << "\n"; - if(m_WindowsShell) - { - makefileStream - << "!IF \"$(OS)\" == \"Windows_NT\"\n" - << "NULL=\n" - << "!ELSE\n" - << "NULL=nul\n" - << "!ENDIF\n"; - } - else - { - makefileStream - << "# The shell in which to execute make rules.\n" - << "SHELL = /bin/sh\n" - << "\n"; - } - - if(m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) - { - makefileStream - << "# Produce verbose output by default.\n" - << "VERBOSE = 1\n" - << "\n"; - } - - std::string cmakecommand = - this->ConvertToOutputForExisting( - m_Makefile->GetRequiredDefinition("CMAKE_COMMAND")); - makefileStream - << "# The CMake executable.\n" - << "CMAKE_COMMAND = " - << m_GlobalGenerator->ConvertToHomeRelativeOutputPath - (cmakecommand.c_str()).c_str() << "\n" - << "\n"; - makefileStream - << "# The command to remove a file.\n" - << "RM = " - << this->ConvertToRelativeOutputPath(cmakecommand.c_str()).c_str() - << " -E remove -f\n" - << "\n"; - - if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) - { - makefileStream - << "# The program to use to edit the cache.\n" - << "CMAKE_EDIT_COMMAND = " - << (this->ConvertToOutputForExisting( - m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))) << "\n" - << "\n"; - } - - makefileStream - << "# The top-level source directory on which CMake was run.\n" - << "CMAKE_SOURCE_DIR = " - << this->ConvertToRelativeOutputPath(m_Makefile->GetHomeDirectory()) - << "\n" - << "\n"; - makefileStream - << "# The top-level build directory on which CMake was run.\n" - << "CMAKE_BINARY_DIR = " - << this->ConvertToRelativeOutputPath(m_Makefile->GetHomeOutputDirectory()) - << "\n" - << "\n"; -} //---------------------------------------------------------------------------- void @@ -1219,7 +1301,7 @@ cmLocalUnixMakefileGenerator3 { // Build command to run CMake to check if anything needs regenerating. std::string cmakefileName = m_Makefile->GetStartOutputDirectory(); - cmakefileName += "/" CMLUMG_MAKEFILE_NAME ".cmake"; + cmakefileName += "/Makefile.cmake"; std::string runRule = "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; runRule += " --check-build-system "; @@ -1267,86 +1349,7 @@ cmLocalUnixMakefileGenerator3 ".SUFFIXES", depends, no_commands); } -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteAllRules(std::ostream& makefileStream) -{ - // Write section header. - this->WriteDivider(makefileStream); - makefileStream - << "# Rules to build dependencies and targets.\n" - << "\n"; - - std::vector<std::string> depends; - std::vector<std::string> commands; - - // Check the build system in this directory. - depends.push_back("cmake_check_build_system"); - - commands.push_back(this->GetRecursiveMakeCall("depend.make",0)); - commands.push_back(this->GetRecursiveMakeCall("build.make",0)); - - // Write the rule. - this->WriteMakeRule(makefileStream, "The main all target", "all", depends, commands); - - // write the clean - commands.clear(); - commands.push_back(this->GetRecursiveMakeCall("clean.make",0)); - this->WriteMakeRule(makefileStream, "default clean target", "clean", depends, commands); -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteConvenienceRules(std::ostream& ruleFileStream) -{ - std::vector<std::string> depends; - std::vector<std::string> tgt_depends; - std::vector<std::string> commands; - - depends.push_back("cmake_check_build_system"); - - // for each target - // Generate the rule files for each target. - const cmTargets& targets = m_Makefile->GetTargets(); - std::string localName; - std::string makeTargetName; - for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) - { - if((t->second.GetType() == cmTarget::EXECUTABLE) || - (t->second.GetType() == cmTarget::STATIC_LIBRARY) || - (t->second.GetType() == cmTarget::SHARED_LIBRARY) || - (t->second.GetType() == cmTarget::MODULE_LIBRARY)) - { - // Add a rule to build the target by name. - localName = this->GetRelativeTargetDirectory(t->second); - - commands.clear(); - makeTargetName = localName; - makeTargetName += "/depend"; - commands.push_back(this->GetRecursiveMakeCall("depend.make",makeTargetName.c_str())); - makeTargetName = localName; - makeTargetName += "/build"; - commands.push_back(this->GetRecursiveMakeCall("build.make",makeTargetName.c_str())); - - // Write the rule. - this->WriteMakeRule(ruleFileStream, "Convenience name for target.", - localName.c_str(), depends, commands); - - // Add a target with the canonical name (no prefix, suffix or path). - if(localName != t->second.GetName()) - { - commands.clear(); - tgt_depends.clear(); - tgt_depends.push_back(localName); - this->WriteMakeRule(ruleFileStream, "Convenience name for target.", - t->second.GetName(), tgt_depends, commands); - } - } - } -} //---------------------------------------------------------------------------- void @@ -1374,35 +1377,6 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 -::WriteRuleFileIncludes(std::ostream& makefileStream) -{ - // Make sure we have some rules to include. - if(m_IncludeRuleFiles.empty()) - { - return; - } - - // Write section header. - this->WriteDivider(makefileStream); - makefileStream - << "# Include rule files for this directory.\n" - << "\n"; - - // Write the include rules. - for(std::vector<std::string>::const_iterator i = m_IncludeRuleFiles.begin(); - i != m_IncludeRuleFiles.end(); ++i) - { - makefileStream - << m_IncludeDirective << " " - << this->ConvertToOutputForExisting(i->c_str()).c_str() - << "\n"; - } - makefileStream << "\n"; -} - -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 ::WriteExecutableRule(std::ostream& ruleFileStream, const char* ruleFileName, const cmTarget& target, @@ -2061,52 +2035,6 @@ cmLocalUnixMakefileGenerator3 cleanTarget.c_str(), no_depends, commands); } -//---------------------------------------------------------------------------- -void -cmLocalUnixMakefileGenerator3 -::WriteTargetRequiresRule(std::ostream& ruleFileStream, const cmTarget& target, - const std::vector<std::string>& provides_requires) -{ - // Create the driving make target. - std::string targetRequires = target.GetName(); - targetRequires += ".requires"; - std::string comment = "Directory-level driver rulue for this target."; - if(provides_requires.empty()) - { - // No provides-requires mode objects in this target. Anything - // that requires the target can build it directly. - std::vector<std::string> no_commands; - std::vector<std::string> depends; - depends.push_back(target.GetName()); - this->WriteMakeRule(ruleFileStream, comment.c_str(), - targetRequires.c_str(), depends, no_commands); - } - else - { - // There are provides-requires mode objects in this target. Use - // provides-requires mode to build the target itself. - std::string targetProvides = target.GetName(); - targetProvides += ".provides"; - { - std::vector<std::string> no_commands; - std::vector<std::string> depends; - depends.push_back(target.GetName()); - this->WriteMakeRule(ruleFileStream, 0, - targetProvides.c_str(), depends, no_commands); - } - { - // Build list of require-level dependencies. - std::vector<std::string> depends; - for(std::vector<std::string>::const_iterator - pr = provides_requires.begin(); - pr != provides_requires.end(); ++pr) - { - depends.push_back(*pr); - } - - } - } -} //---------------------------------------------------------------------------- void @@ -2241,17 +2169,6 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- std::string -cmLocalUnixMakefileGenerator3 -::ConvertToFullPath(const std::string& localPath) -{ - std::string dir = m_Makefile->GetStartOutputDirectory(); - dir += "/"; - dir += localPath; - return dir; -} - -//---------------------------------------------------------------------------- -std::string cmLocalUnixMakefileGenerator3::ConvertToRelativeOutputPath(const char* p) { // Convert the path to a relative path. @@ -2320,53 +2237,6 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p) } //---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::ConfigureOutputPaths() -{ - // Format the library and executable output paths. - if(const char* libOut = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) - { - m_LibraryOutputPath = libOut; - this->FormatOutputPath(m_LibraryOutputPath, "LIBRARY"); - } - if(const char* exeOut = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) - { - m_ExecutableOutputPath = exeOut; - this->FormatOutputPath(m_ExecutableOutputPath, "EXECUTABLE"); - } -} - -//---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::FormatOutputPath(std::string& path, - const char* name) -{ - if(!path.empty()) - { - // Convert the output path to a full path in case it is - // specified as a relative path. Treat a relative path as - // relative to the current output directory for this makefile. - path = - cmSystemTools::CollapseFullPath(path.c_str(), - m_Makefile->GetStartOutputDirectory()); - - // Add a trailing slash for easy appending later. - if(path.empty() || path[path.size()-1] != '/') - { - path += "/"; - } - - // Make sure the output path exists on disk. - if(!cmSystemTools::MakeDirectory(path.c_str())) - { - cmSystemTools::Error("Error failed to create ", - name, "_OUTPUT_PATH directory:", path.c_str()); - } - - // Add this as a link directory automatically. - m_Makefile->AddLinkDirectory(path.c_str()); - } -} - -//---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 ::AppendTargetDepends(std::vector<std::string>& depends, @@ -2840,43 +2710,6 @@ cmLocalUnixMakefileGenerator3 //============================================================================ //---------------------------------------------------------------------------- -std::string -cmLocalUnixMakefileGenerator3 -::GetRecursiveMakeCall(const char *Makefile, const char* tgt) -{ - // Call make on the given file. - std::string cmd; - cmd += "$(MAKE) -f "; - cmd += Makefile; - cmd += " "; - - // Pass down verbosity level. - if(m_MakeSilentFlag.size()) - { - cmd += m_MakeSilentFlag; - cmd += " "; - } - - // Most unix makes will pass the command line flags to make down to - // sub-invoked makes via an environment variable. However, some - // makes do not support that, so you have to pass the flags - // explicitly. - if(m_PassMakeflags) - { - cmd += "-$(MAKEFLAGS) "; - } - - // Add the target. - if (tgt && tgt[0] != '\0') - { - std::string tgt2 = this->ConvertToRelativeOutputPath(tgt); - tgt2 = this->ConvertToMakeTarget(tgt2.c_str()); - cmd += tgt2; - } - return cmd; -} - -//---------------------------------------------------------------------------- cmDepends* cmLocalUnixMakefileGenerator3::GetDependsChecker(const std::string& lang, const char* dir, @@ -3039,3 +2872,4 @@ void cmLocalUnixMakefileGenerator3::CheckDependencies(cmMakefile* mf) } } } + |