diff options
Diffstat (limited to 'Source')
65 files changed, 1015 insertions, 479 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 17fb52d..3c944fb 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -517,6 +517,7 @@ if(WIN32) CPack/WiX/cmCPackWIXGenerator.cxx CPack/WiX/cmWIXSourceWriter.cxx CPack/WiX/cmWIXRichTextFormatWriter.cxx + CPack/WiX/cmWIXPatchParser.cxx ) endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a2c6fcc..5cb27c8 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 12) -set(CMake_VERSION_TWEAK 20131218) +set(CMake_VERSION_TWEAK 20140102) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 1b9b20a..c1749ac 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -85,8 +85,8 @@ bool cmCPackWIXGenerator::RunCandleCommand( command << " -arch " << GetArchitecture(); command << " -out " << QuotePath(objectFile); - for(extension_set_t::const_iterator i = candleExtensions.begin(); - i != candleExtensions.end(); ++i) + for(extension_set_t::const_iterator i = CandleExtensions.begin(); + i != CandleExtensions.end(); ++i) { command << " -ext " << QuotePath(*i); } @@ -111,8 +111,8 @@ bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles) command << " -nologo"; command << " -out " << QuotePath(packageFileNames.at(0)); - for(extension_set_t::const_iterator i = lightExtensions.begin(); - i != lightExtensions.end(); ++i) + for(extension_set_t::const_iterator i = LightExtensions.begin(); + i != LightExtensions.end(); ++i) { command << " -ext " << QuotePath(*i); } @@ -211,12 +211,18 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() SetOption("CPACK_WIX_UI_REF", defaultRef.c_str()); } - CollectExtensions("CPACK_WIX_EXTENSIONS", candleExtensions); - CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", candleExtensions); + CollectExtensions("CPACK_WIX_EXTENSIONS", CandleExtensions); + CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", CandleExtensions); - lightExtensions.insert("WixUIExtension"); - CollectExtensions("CPACK_WIX_EXTENSIONS", lightExtensions); - CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", lightExtensions); + LightExtensions.insert("WixUIExtension"); + CollectExtensions("CPACK_WIX_EXTENSIONS", LightExtensions); + CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", LightExtensions); + + const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE"); + if(patchFilePath) + { + LoadPatchFragments(patchFilePath); + } return true; } @@ -241,9 +247,9 @@ bool cmCPackWIXGenerator::PackageFilesImpl() AppendUserSuppliedExtraSources(); std::stringstream objectFiles; - for(size_t i = 0; i < wixSources.size(); ++i) + for(size_t i = 0; i < WixSources.size(); ++i) { - const std::string& sourceFilename = wixSources[i]; + const std::string& sourceFilename = WixSources[i]; std::string objectFilename = cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj"; @@ -266,7 +272,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources() const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES"); if(!cpackWixExtraSources) return; - cmSystemTools::ExpandListArgument(cpackWixExtraSources, wixSources); + cmSystemTools::ExpandListArgument(cpackWixExtraSources, WixSources); } void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream) @@ -345,7 +351,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() std::string directoryDefinitionsFilename = cpackTopLevel + "/directories.wxs"; - wixSources.push_back(directoryDefinitionsFilename); + WixSources.push_back(directoryDefinitionsFilename); cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename); directoryDefinitions.BeginElement("Fragment"); @@ -400,7 +406,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() std::string fileDefinitionsFilename = cpackTopLevel + "/files.wxs"; - wixSources.push_back(fileDefinitionsFilename); + WixSources.push_back(fileDefinitionsFilename); cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename); fileDefinitions.BeginElement("Fragment"); @@ -408,7 +414,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() std::string featureDefinitionsFilename = cpackTopLevel +"/features.wxs"; - wixSources.push_back(featureDefinitionsFilename); + WixSources.push_back(featureDefinitionsFilename); cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename); featureDefinitions.BeginElement("Fragment"); @@ -527,7 +533,29 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() return false; } - wixSources.push_back(mainSourceFilePath); + WixSources.push_back(mainSourceFilePath); + + std::string fragmentList; + for(cmWIXPatchParser::fragment_map_t::const_iterator + i = Fragments.begin(); i != Fragments.end(); ++i) + { + if(!fragmentList.empty()) + { + fragmentList += ", "; + } + + fragmentList += "'"; + fragmentList += i->first; + fragmentList += "'"; + } + + if(fragmentList.size()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Some XML patch fragments did not have matching IDs: " << + fragmentList << std::endl); + return false; + } return true; } @@ -737,7 +765,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( fileDefinitions.EndElement("RemoveFolder"); std::string registryKey = - std::string("Software/") + cpackVendor + "/" + cpackPackageName; + std::string("Software\\") + cpackVendor + "\\" + cpackPackageName; fileDefinitions.BeginElement("RegistryValue"); fileDefinitions.AddAttribute("Root", "HKCU"); @@ -872,6 +900,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( packageExecutables, shortcutMap); + ApplyPatchFragment(subDirectoryId, directoryDefinitions); directoryDefinitions.EndElement("Directory"); } else @@ -891,7 +920,10 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( fileDefinitions.AddAttribute("Source", fullPath); fileDefinitions.AddAttribute("KeyPath", "yes"); + ApplyPatchFragment(fileId, fileDefinitions); fileDefinitions.EndElement("File"); + + ApplyPatchFragment(componentId, fileDefinitions); fileDefinitions.EndElement("Component"); fileDefinitions.EndElement("DirectoryRef"); @@ -986,8 +1018,8 @@ std::string cmCPackWIXGenerator::GetRightmostExtension( std::string cmCPackWIXGenerator::PathToId(const std::string& path) { - id_map_t::const_iterator i = pathToIdMap.find(path); - if(i != pathToIdMap.end()) return i->second; + id_map_t::const_iterator i = PathToIdMap.find(path); + if(i != PathToIdMap.end()) return i->second; std::string id = CreateNewIdForPath(path); return id; @@ -1024,7 +1056,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path) std::stringstream result; result << idPrefix << "_" << identifier; - size_t ambiguityCount = ++idAmbiguityCounter[identifier]; + size_t ambiguityCount = ++IdAmbiguityCounter[identifier]; if(ambiguityCount > 999) { @@ -1041,7 +1073,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path) std::string resultString = result.str(); - pathToIdMap[path] = resultString; + PathToIdMap[path] = resultString; return resultString; } @@ -1146,3 +1178,45 @@ void cmCPackWIXGenerator::CreateStartMenuFolder( directoryDefinitions.EndElement("Directory"); } + +void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath) +{ + cmWIXPatchParser parser(Fragments, Logger); + parser.ParseFile(patchFilePath.c_str()); +} + +void cmCPackWIXGenerator::ApplyPatchFragment( + const std::string& id, cmWIXSourceWriter& writer) +{ + cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id); + if(i == Fragments.end()) return; + + const cmWIXPatchElement& fragment = i->second; + for(cmWIXPatchElement::child_list_t::const_iterator + j = fragment.children.begin(); j != fragment.children.end(); ++j) + { + ApplyPatchElement(**j, writer); + } + + Fragments.erase(i); +} + +void cmCPackWIXGenerator::ApplyPatchElement( + const cmWIXPatchElement& element, cmWIXSourceWriter& writer) +{ + writer.BeginElement(element.name); + + for(cmWIXPatchElement::attributes_t::const_iterator + i = element.attributes.begin(); i != element.attributes.end(); ++i) + { + writer.AddAttribute(i->first, i->second); + } + + for(cmWIXPatchElement::child_list_t::const_iterator + i = element.children.begin(); i != element.children.end(); ++i) + { + ApplyPatchElement(**i, writer); + } + + writer.EndElement(element.name); +} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index 84f68b6..0a85ae2 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -13,6 +13,8 @@ #ifndef cmCPackWIXGenerator_h #define cmCPackWIXGenerator_h +#include "cmWIXPatchParser.h" + #include <CPack/cmCPackGenerator.h> #include <string> @@ -160,12 +162,21 @@ private: void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions); - std::vector<std::string> wixSources; - id_map_t pathToIdMap; - ambiguity_map_t idAmbiguityCounter; + void LoadPatchFragments(const std::string& patchFilePath); + + void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer); + + void ApplyPatchElement(const cmWIXPatchElement& element, + cmWIXSourceWriter& writer); + + std::vector<std::string> WixSources; + id_map_t PathToIdMap; + ambiguity_map_t IdAmbiguityCounter; + + extension_set_t CandleExtensions; + extension_set_t LightExtensions; - extension_set_t candleExtensions; - extension_set_t lightExtensions; + cmWIXPatchParser::fragment_map_t Fragments; }; #endif diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx new file mode 100644 index 0000000..7ceaf1f --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -0,0 +1,145 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmWIXPatchParser.h" + +#include <CPack/cmCPackGenerator.h> + +#include <cm_expat.h> + +cmWIXPatchElement::~cmWIXPatchElement() +{ + for(child_list_t::iterator i = children.begin(); i != children.end(); ++i) + { + delete *i; + } +} + +cmWIXPatchParser::cmWIXPatchParser( + fragment_map_t& fragments, cmCPackLog* logger): + Logger(logger), + State(BEGIN_DOCUMENT), + Valid(true), + Fragments(fragments) +{ + +} + +void cmWIXPatchParser::StartElement(const char *name, const char **atts) +{ + std::string name_str = name; + if(State == BEGIN_DOCUMENT) + { + if(name_str == "CPackWiXPatch") + { + State = BEGIN_FRAGMENTS; + } + else + { + ReportValidationError("Expected root element 'CPackWiXPatch'"); + } + } + else if(State == BEGIN_FRAGMENTS) + { + if(name_str == "CPackWiXFragment") + { + State = INSIDE_FRAGMENT; + StartFragment(atts); + } + else + { + ReportValidationError("Expected 'CPackWixFragment' element"); + } + } + else if(State == INSIDE_FRAGMENT) + { + cmWIXPatchElement &parent = *ElementStack.back(); + + parent.children.resize(parent.children.size() + 1); + cmWIXPatchElement*& currentElement = parent.children.back(); + currentElement = new cmWIXPatchElement; + currentElement->name = name; + + for(size_t i = 0; atts[i]; i += 2) + { + std::string key = atts[i]; + std::string value = atts[i+1]; + + currentElement->attributes[key] = value; + } + + ElementStack.push_back(currentElement); + } +} + +void cmWIXPatchParser::StartFragment(const char **attributes) +{ + for(size_t i = 0; attributes[i]; i += 2) + { + std::string key = attributes[i]; + std::string value = attributes[i+1]; + + if(key == "Id") + { + if(Fragments.find(value) != Fragments.end()) + { + std::stringstream tmp; + tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value; + ReportValidationError(tmp.str()); + } + + ElementStack.push_back(&Fragments[value]); + } + else + { + ReportValidationError( + "The only allowed 'CPackWixFragment' attribute is 'Id'"); + } + } +} + +void cmWIXPatchParser::EndElement(const char *name) +{ + std::string name_str = name; + if(State == INSIDE_FRAGMENT) + { + if(name_str == "CPackWiXFragment") + { + State = BEGIN_FRAGMENTS; + ElementStack.clear(); + } + else + { + ElementStack.pop_back(); + } + } +} + +void cmWIXPatchParser::ReportError(int line, int column, const char* msg) +{ + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while processing XML patch file at " << line << ":" << column << + ": "<< msg << std::endl); + Valid = false; +} + +void cmWIXPatchParser::ReportValidationError(const std::string& message) +{ + ReportError(XML_GetCurrentLineNumber(Parser), + XML_GetCurrentColumnNumber(Parser), + message.c_str()); +} + +bool cmWIXPatchParser::IsValid() const +{ + return Valid; +} diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h new file mode 100644 index 0000000..91b3b66 --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -0,0 +1,75 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmCPackWIXPatchParser_h +#define cmCPackWIXPatchParser_h + +#include <cmXMLParser.h> + +#include <CPack/cmCPackLog.h> + +#include <map> +#include <list> + +struct cmWIXPatchElement +{ + ~cmWIXPatchElement(); + + typedef std::list<cmWIXPatchElement*> child_list_t; + typedef std::map<std::string, std::string> attributes_t; + + std::string name; + child_list_t children; + attributes_t attributes; +}; + +/** \class cmWIXPatchParser + * \brief Helper class that parses XML patch files (CPACK_WIX_PATCH_FILE) + */ +class cmWIXPatchParser : public cmXMLParser +{ +public: + typedef std::map<std::string, cmWIXPatchElement> fragment_map_t; + + cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger); + +private: + virtual void StartElement(const char *name, const char **atts); + + void StartFragment(const char **attributes); + + virtual void EndElement(const char *name); + virtual void ReportError(int line, int column, const char* msg); + + void ReportValidationError(const std::string& message); + + bool IsValid() const; + + cmCPackLog* Logger; + + enum ParserState + { + BEGIN_DOCUMENT, + BEGIN_FRAGMENTS, + INSIDE_FRAGMENT + }; + + ParserState State; + + bool Valid; + + fragment_map_t& Fragments; + + std::list<cmWIXPatchElement*> ElementStack; +}; + +#endif diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx index 774c22c..886b534 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx @@ -16,7 +16,7 @@ cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter( const std::string& filename): - file(filename.c_str(), std::ios::binary) + File(filename.c_str(), std::ios::binary) { StartGroup(); WriteHeader(); @@ -29,8 +29,8 @@ cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter() /* I haven't seen this in the RTF spec but * wordpad terminates its RTF like this */ - file << "\r\n"; - file.put(0); + File << "\r\n"; + File.put(0); } void cmWIXRichTextFormatWriter::AddText(const std::string& text) @@ -44,16 +44,16 @@ void cmWIXRichTextFormatWriter::AddText(const std::string& text) switch(c) { case '\\': - file << "\\\\"; + File << "\\\\"; break; case '{': - file << "\\{"; + File << "\\{"; break; case '}': - file << "\\}"; + File << "\\}"; break; case '\n': - file << "\\par\r\n"; + File << "\\par\r\n"; break; case '\r': continue; @@ -61,11 +61,11 @@ void cmWIXRichTextFormatWriter::AddText(const std::string& text) { if(c <= 0x7F) { - file << c; + File << c; } else { - file << "[NON-ASCII-" << int(c) << "]"; + File << "[NON-ASCII-" << int(c) << "]"; } } break; @@ -103,7 +103,7 @@ void cmWIXRichTextFormatWriter::WriteGenerator() { StartGroup(); NewControlWord("generator"); - file << " CPack WiX Generator (" << cmVersion::GetCMakeVersion() << ");"; + File << " CPack WiX Generator (" << cmVersion::GetCMakeVersion() << ");"; EndGroup(); } @@ -118,20 +118,20 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix() void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword) { - file << "\\" << keyword; + File << "\\" << keyword; } void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword) { - file << "\\*\\" << keyword; + File << "\\*\\" << keyword; } void cmWIXRichTextFormatWriter::StartGroup() { - file.put('{'); + File.put('{'); } void cmWIXRichTextFormatWriter::EndGroup() { - file.put('}'); + File.put('}'); } diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h index 10b67c3..bb8580a 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h @@ -40,7 +40,7 @@ private: void StartGroup(); void EndGroup(); - std::ofstream file; + std::ofstream File; }; #endif diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index c8a3922..e83c226 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -20,9 +20,9 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, const std::string& filename, bool isIncludeFile): Logger(logger), - file(filename.c_str()), - state(DEFAULT), - sourceFilename(filename) + File(filename.c_str()), + State(DEFAULT), + SourceFilename(filename) { WriteXMLDeclaration(); @@ -40,79 +40,79 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, cmWIXSourceWriter::~cmWIXSourceWriter() { - if(elements.size() > 1) + if(Elements.size() > 1) { cmCPackLogger(cmCPackLog::LOG_ERROR, - elements.size() - 1 << " WiX elements were still open when closing '" << - sourceFilename << "'" << std::endl); + Elements.size() - 1 << " WiX elements were still open when closing '" << + SourceFilename << "'" << std::endl); return; } - EndElement(elements.back()); + EndElement(Elements.back()); } void cmWIXSourceWriter::BeginElement(const std::string& name) { - if(state == BEGIN) + if(State == BEGIN) { - file << ">"; + File << ">"; } - file << "\n"; - Indent(elements.size()); - file << "<" << name; + File << "\n"; + Indent(Elements.size()); + File << "<" << name; - elements.push_back(name); - state = BEGIN; + Elements.push_back(name); + State = BEGIN; } void cmWIXSourceWriter::EndElement(std::string const& name) { - if(elements.empty()) + if(Elements.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "can not end WiX element with no open elements in '" << - sourceFilename << "'" << std::endl); + SourceFilename << "'" << std::endl); return; } - if(elements.back() != name) + if(Elements.back() != name) { cmCPackLogger(cmCPackLog::LOG_ERROR, - "WiX element <" << elements.back() << + "WiX element <" << Elements.back() << "> can not be closed by </" << name << "> in '" << - sourceFilename << "'" << std::endl); + SourceFilename << "'" << std::endl); return; } - if(state == DEFAULT) + if(State == DEFAULT) { - file << "\n"; - Indent(elements.size()-1); - file << "</" << elements.back() << ">"; + File << "\n"; + Indent(Elements.size()-1); + File << "</" << Elements.back() << ">"; } else { - file << "/>"; + File << "/>"; } - elements.pop_back(); - state = DEFAULT; + Elements.pop_back(); + State = DEFAULT; } void cmWIXSourceWriter::AddProcessingInstruction( const std::string& target, const std::string& content) { - if(state == BEGIN) + if(State == BEGIN) { - file << ">"; + File << ">"; } - file << "\n"; - Indent(elements.size()); - file << "<?" << target << " " << content << "?>"; + File << "\n"; + Indent(Elements.size()); + File << "<?" << target << " " << content << "?>"; - state = DEFAULT; + State = DEFAULT; } void cmWIXSourceWriter::AddAttribute( @@ -120,7 +120,7 @@ void cmWIXSourceWriter::AddAttribute( { std::string utf8 = WindowsCodepageToUtf8(value); - file << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"'; + File << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"'; } void cmWIXSourceWriter::AddAttributeUnlessEmpty( @@ -172,14 +172,14 @@ std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value) void cmWIXSourceWriter::WriteXMLDeclaration() { - file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; + File << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; } void cmWIXSourceWriter::Indent(size_t count) { for(size_t i = 0; i < count; ++i) { - file << " "; + File << " "; } } diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index 670d4c0..f291d25 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -60,13 +60,13 @@ private: cmCPackLog* Logger; - std::ofstream file; + std::ofstream File; - State state; + State State; - std::vector<std::string> elements; + std::vector<std::string> Elements; - std::string sourceFilename; + std::string SourceFilename; }; #endif diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 31cc393..1be5980 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -619,19 +619,19 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, } //---------------------------------------------------------------------------- -cmTarget* cmComputeLinkDepends::FindTargetToLink(int depender_index, +cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const char* name) { // Look for a target in the scope of the depender. cmMakefile* mf = this->Makefile; if(depender_index >= 0) { - if(cmTarget* depender = this->EntryList[depender_index].Target) + if(cmTarget const* depender = this->EntryList[depender_index].Target) { mf = depender->GetMakefile(); } } - cmTarget* tgt = mf->FindTargetToUse(name); + cmTarget const* tgt = mf->FindTargetToUse(name); // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable @@ -950,7 +950,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) int count = 2; for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - if(cmTarget* target = this->EntryList[*ni].Target) + if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = target->GetLinkInterface(this->Config, this->HeadTarget)) @@ -997,7 +997,8 @@ void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index, // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - if(cmTarget* tgt = this->FindTargetToLink(depender_index, item.c_str())) + if(cmTarget const* tgt + = this->FindTargetToLink(depender_index, item.c_str())) { if(!tgt->IsImported()) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index b86c9b2..cf227fb 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -40,7 +40,7 @@ public: struct LinkEntry { std::string Item; - cmTarget* Target; + cmTarget const* Target; bool IsSharedDep; bool IsFlag; LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {} @@ -53,7 +53,7 @@ public: EntryVector const& Compute(); void SetOldLinkDirMode(bool b); - std::set<cmTarget*> const& GetOldWrongConfigItems() const + std::set<cmTarget const*> const& GetOldWrongConfigItems() const { return this->OldWrongConfigItems; } private: @@ -83,7 +83,7 @@ private: void AddDirectLinkEntries(); void AddLinkEntries(int depender_index, std::vector<std::string> const& libs); - cmTarget* FindTargetToLink(int depender_index, const char* name); + cmTarget const* FindTargetToLink(int depender_index, const char* name); // One entry for each unique item. std::vector<LinkEntry> EntryList; @@ -164,7 +164,7 @@ private: // Compatibility help. bool OldLinkDirMode; void CheckWrongConfigItem(int depender_index, std::string const& item); - std::set<cmTarget*> OldWrongConfigItems; + std::set<cmTarget const*> OldWrongConfigItems; }; #endif diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 1e21216..6986965 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -477,7 +477,7 @@ std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths() } //---------------------------------------------------------------------------- -std::set<cmTarget*> const& +std::set<cmTarget const*> const& cmComputeLinkInformation::GetSharedLibrariesLinked() { return this->SharedLibrariesLinked; @@ -542,11 +542,11 @@ bool cmComputeLinkInformation::Compute() // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - std::set<cmTarget*> const& wrongItems = cld.GetOldWrongConfigItems(); - for(std::set<cmTarget*>::const_iterator i = wrongItems.begin(); + std::set<cmTarget const*> const& wrongItems = cld.GetOldWrongConfigItems(); + for(std::set<cmTarget const*>::const_iterator i = wrongItems.begin(); i != wrongItems.end(); ++i) { - cmTarget* tgt = *i; + cmTarget const* tgt = *i; bool implib = (this->UseImportLibrary && (tgt->GetType() == cmTarget::SHARED_LIBRARY)); @@ -620,7 +620,8 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) } //---------------------------------------------------------------------------- -void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) +void cmComputeLinkInformation::AddItem(std::string const& item, + cmTarget const* tgt) { // Compute the proper name to use to link this library. const char* config = this->Config; @@ -700,7 +701,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, - cmTarget* tgt) + cmTarget const* tgt) { // If dropping shared library dependencies, ignore them. if(this->SharedDependencyMode == SharedDepModeNone) @@ -1062,7 +1063,7 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddTargetItem(std::string const& item, - cmTarget* target) + cmTarget const* target) { // This is called to handle a link item that is a full path to a target. // If the target is not a static library make sure the link type is @@ -1744,7 +1745,7 @@ cmComputeLinkInformation::GetRuntimeSearchPath() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, - cmTarget* target) + cmTarget const* target) { // Ignore targets on Apple where install_name is not @rpath. // The dependenty library can be found with other means such as diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 1da5495..356e6ed 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -39,11 +39,11 @@ public: Item(): Value(), IsPath(true), Target(0) {} Item(Item const& item): Value(item.Value), IsPath(item.IsPath), Target(item.Target) {} - Item(std::string const& v, bool p, cmTarget* target = 0): + Item(std::string const& v, bool p, cmTarget const* target = 0): Value(v), IsPath(p), Target(target) {} std::string Value; bool IsPath; - cmTarget* Target; + cmTarget const* Target; }; typedef std::vector<Item> ItemVector; ItemVector const& GetItems(); @@ -57,13 +57,13 @@ public: void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install); std::string GetRPathString(bool for_install); std::string GetChrpathString(); - std::set<cmTarget*> const& GetSharedLibrariesLinked(); + std::set<cmTarget const*> const& GetSharedLibrariesLinked(); std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; } std::string GetRPathLinkString(); private: - void AddItem(std::string const& item, cmTarget* tgt); - void AddSharedDepItem(std::string const& item, cmTarget* tgt); + void AddItem(std::string const& item, cmTarget const* tgt); + void AddSharedDepItem(std::string const& item, cmTarget const* tgt); // Output information. ItemVector Items; @@ -71,7 +71,7 @@ private: std::vector<std::string> Depends; std::vector<std::string> FrameworkPaths; std::vector<std::string> RuntimeSearchPath; - std::set<cmTarget*> SharedLibrariesLinked; + std::set<cmTarget const*> SharedLibrariesLinked; // Context information. cmTarget const* Target; @@ -139,7 +139,7 @@ private: std::string NoCaseExpression(const char* str); // Handling of link items. - void AddTargetItem(std::string const& item, cmTarget* target); + void AddTargetItem(std::string const& item, cmTarget const* target); void AddFullItem(std::string const& item); bool CheckImplicitDirItem(std::string const& item); void AddUserItem(std::string const& item, bool pathNotKnown); @@ -179,7 +179,8 @@ private: // Runtime path computation. cmOrderDirectories* OrderRuntimeSearchPath; - void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target); + void AddLibraryRuntimeInfo(std::string const& fullPath, + cmTarget const* target); void AddLibraryRuntimeInfo(std::string const& fullPath); // Dependent library path computation. diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index cb9e37e..73a8e27 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -143,12 +143,13 @@ bool cmComputeTargetDepends::Compute() //---------------------------------------------------------------------------- void -cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, +cmComputeTargetDepends::GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps) { // Lookup the index for this target. All targets should be known by // this point. - std::map<cmTarget*, int>::const_iterator tii = this->TargetIndex.find(t); + std::map<cmTarget const*, int>::const_iterator tii + = this->TargetIndex.find(t); assert(tii != this->TargetIndex.end()); int i = tii->second; @@ -156,7 +157,7 @@ cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, EdgeList const& nl = this->FinalGraph[i]; for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - cmTarget* dep = this->Targets[*ni]; + cmTarget const* dep = this->Targets[*ni]; cmTargetDependSet::iterator di = deps.insert(dep).first; di->SetType(ni->IsStrong()); } @@ -170,10 +171,11 @@ void cmComputeTargetDepends::CollectTargets() this->GlobalGenerator->GetLocalGenerators(); for(unsigned int i = 0; i < lgens.size(); ++i) { - cmTargets& targets = lgens[i]->GetMakefile()->GetTargets(); - for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) + const cmTargets& targets = lgens[i]->GetMakefile()->GetTargets(); + for(cmTargets::const_iterator ti = targets.begin(); + ti != targets.end(); ++ti) { - cmTarget* target = &ti->second; + cmTarget const* target = &ti->second; int index = static_cast<int>(this->Targets.size()); this->TargetIndex[target] = index; this->Targets.push_back(target); @@ -198,7 +200,11 @@ void cmComputeTargetDepends::CollectDepends() void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { // Get the depender. - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; + if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return; + } // Loop over all targets linked directly in all configs. // We need to make targets depend on the union of all config-specific @@ -208,15 +214,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) std::set<cmStdString> emitted; { std::vector<std::string> tlibs; - if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // For INTERFACE_LIBRARY depend on the interface instead. - depender->GetInterfaceLinkLibraries(0, tlibs, depender); - } - else - { - depender->GetDirectLinkLibraries(0, tlibs, depender); - } + depender->GetDirectLinkLibraries(0, tlibs, depender); // A target should not depend on itself. emitted.insert(depender->GetName()); for(std::vector<std::string>::const_iterator lib = tlibs.begin(); @@ -237,15 +235,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) it != configs.end(); ++it) { std::vector<std::string> tlibs; - if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // For INTERFACE_LIBRARY depend on the interface instead. - depender->GetInterfaceLinkLibraries(it->c_str(), tlibs, depender); - } - else - { - depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender); - } + depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender); + // A target should not depend on itself. emitted.insert(depender->GetName()); for(std::vector<std::string>::const_iterator lib = tlibs.begin(); @@ -282,11 +273,11 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, - cmTarget* dependee, + cmTarget const* dependee, const char *config, std::set<cmStdString> &emitted) { - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; if(cmTarget::LinkInterface const* iface = dependee->GetLinkInterface(config, depender)) { @@ -311,8 +302,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, bool linking, std::set<cmStdString> &emitted) { - cmTarget* depender = this->Targets[depender_index]; - cmTarget* dependee = + cmTarget const* depender = this->Targets[depender_index]; + cmTarget const* dependee = depender->GetMakefile()->FindTargetToUse(dependee_name); // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable @@ -346,10 +337,10 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, bool linking) { // Get the depender. - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; // Check the target's makefile first. - cmTarget* dependee = + cmTarget const* dependee = depender->GetMakefile()->FindTargetToUse(dependee_name); // Skip targets that will not really be linked. This is probably a @@ -370,7 +361,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddTargetDepend(int depender_index, - cmTarget* dependee, + cmTarget const* dependee, bool linking) { if(dependee->IsImported()) @@ -380,7 +371,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, for(std::set<cmStdString>::const_iterator i = utils.begin(); i != utils.end(); ++i) { - if(cmTarget* transitive_dependee = + if(cmTarget const* transitive_dependee = dependee->GetMakefile()->FindTargetToUse(i->c_str())) { this->AddTargetDepend(depender_index, transitive_dependee, false); @@ -391,7 +382,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, { // Lookup the index for this target. All targets should be known by // this point. - std::map<cmTarget*, int>::const_iterator tii = + std::map<cmTarget const*, int>::const_iterator tii = this->TargetIndex.find(dependee); assert(tii != this->TargetIndex.end()); int dependee_index = tii->second; @@ -411,13 +402,13 @@ cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name) for(int depender_index = 0; depender_index < n; ++depender_index) { EdgeList const& nl = graph[depender_index]; - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; fprintf(stderr, "target %d is [%s]\n", depender_index, depender->GetName()); for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { int dependee_index = *ni; - cmTarget* dependee = this->Targets[dependee_index]; + cmTarget const* dependee = this->Targets[dependee_index]; fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index, dependee->GetName(), ni->IsStrong()? "strong" : "weak"); } @@ -504,7 +495,7 @@ cmComputeTargetDepends { // Get the depender. int i = *ci; - cmTarget* depender = this->Targets[i]; + cmTarget const* depender = this->Targets[i]; // Describe the depender. e << " \"" << depender->GetName() << "\" of type " @@ -517,7 +508,7 @@ cmComputeTargetDepends int j = *ni; if(cmap[j] == c) { - cmTarget* dependee = this->Targets[j]; + cmTarget const* dependee = this->Targets[j]; e << " depends on \"" << dependee->GetName() << "\"" << " (" << (ni->IsStrong()? "strong" : "weak") << ")\n"; } diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index d6131cf..6cd6da0 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -38,19 +38,21 @@ public: bool Compute(); - std::vector<cmTarget*> const& GetTargets() const { return this->Targets; } - void GetTargetDirectDepends(cmTarget* t, cmTargetDependSet& deps); + std::vector<cmTarget const*> const& + GetTargets() const { return this->Targets; } + void GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps); private: void CollectTargets(); void CollectDepends(); void CollectTargetDepends(int depender_index); void AddTargetDepend(int depender_index, const char* dependee_name, bool linking); - void AddTargetDepend(int depender_index, cmTarget* dependee, bool linking); + void AddTargetDepend(int depender_index, cmTarget const* dependee, + bool linking); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); void AddInterfaceDepends(int depender_index, const char* dependee_name, bool linking, std::set<cmStdString> &emitted); - void AddInterfaceDepends(int depender_index, cmTarget* dependee, + void AddInterfaceDepends(int depender_index, cmTarget const* dependee, const char *config, std::set<cmStdString> &emitted); cmGlobalGenerator* GlobalGenerator; @@ -58,8 +60,8 @@ private: bool NoCycles; // Collect all targets. - std::vector<cmTarget*> Targets; - std::map<cmTarget*, int> TargetIndex; + std::vector<cmTarget const*> Targets; + std::map<cmTarget const*, int> TargetIndex; // Represent the target dependency graph. The entry at each // top-level index corresponds to a depender whose dependencies are diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 0d0d05b..c10f86f 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -229,10 +229,8 @@ cmExportBuildFileGenerator::HandleMissingTarget( // Append it with the export namespace. link_libs += this->Namespace; link_libs += dependee->GetExportName(); -// if generate time {} } - //---------------------------------------------------------------------------- std::vector<std::string> cmExportBuildFileGenerator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index f8b4e28..2a87e4f 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -402,7 +402,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, //---------------------------------------------------------------------------- -void getPropertyContents(cmTarget *tgt, const char *prop, +void getPropertyContents(cmTarget const* tgt, const char *prop, std::set<std::string> &ifaceProperties) { const char *p = tgt->GetProperty(prop); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 79e78df..1025dc0 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -297,16 +297,14 @@ cmExportInstallFileGenerator { // Collect import properties for this target. cmTargetExport const* te = *tei; - ImportPropertyMap properties; - std::set<std::string> importedLocations; - if (!properties.empty() - && te->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if (te->Target->GetType() == cmTarget::INTERFACE_LIBRARY) { - this->GenerateImportPropertyCode(os, config, te->Target, properties); - this->GenerateImportedFileChecksCode(os, te->Target, properties, - importedLocations); continue; } + + ImportPropertyMap properties; + std::set<std::string> importedLocations; + this->SetImportLocationProperty(config, suffix, te->ArchiveGenerator, properties, importedLocations); this->SetImportLocationProperty(config, suffix, te->LibraryGenerator, diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index f020ddb..177ef8d 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -52,6 +52,8 @@ void cmExtraKateGenerator::Generate() this->ProjectName = this->GenerateProjectName(mf->GetProjectName(), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), this->GetPathBasename(mf->GetHomeOutputDirectory())); + this->UseNinja = (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0); + this->CreateKateProjectFile(mf); this->CreateDummyKateProjectFile(mf); } @@ -95,11 +97,12 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); const std::string makeArgs = mf->GetSafeDefinition( "CMAKE_KATE_MAKE_ARGUMENTS"); + const char* homeOutputDir = mf->GetHomeOutputDirectory(); this->AppendTarget(fout, "all", make, makeArgs, - mf->GetHomeOutputDirectory()); + homeOutputDir, homeOutputDir); this->AppendTarget(fout, "clean", make, makeArgs, - mf->GetHomeOutputDirectory()); + homeOutputDir, homeOutputDir); // add all executable and library targets and some of the GLOBAL // and UTILITY targets @@ -143,7 +146,8 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, } if (insertTarget) { - this->AppendTarget(fout, ti->first, make, makeArgs, currentDir); + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); } } break; @@ -158,7 +162,8 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, break; } - this->AppendTarget(fout, ti->first, make, makeArgs, currentDir); + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); break; case cmTarget::EXECUTABLE: case cmTarget::STATIC_LIBRARY: @@ -166,10 +171,12 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, case cmTarget::MODULE_LIBRARY: case cmTarget::OBJECT_LIBRARY: { - this->AppendTarget(fout, ti->first, make, makeArgs, currentDir); + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); std::string fastTarget = ti->first; fastTarget += "/fast"; - this->AppendTarget(fout, fastTarget, make, makeArgs, currentDir); + this->AppendTarget(fout, fastTarget, make, makeArgs, + currentDir, homeOutputDir); } break; @@ -185,7 +192,7 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, fit != objectFileTargets.end(); ++fit) { - this->AppendTarget(fout, *fit, make, makeArgs, currentDir); + this->AppendTarget(fout, *fit, make, makeArgs, currentDir,homeOutputDir); } } @@ -199,14 +206,18 @@ cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout, const std::string& target, const std::string& make, const std::string& makeArgs, - const std::string& path) const + const std::string& path, + const char* homeOutputDir + ) const { static char JsonSep = ' '; fout << "\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", " - "\"build_cmd\":\"" << make << " -C " << path << " " << makeArgs << " " - << target << "\"}\n"; + "\"build_cmd\":\"" << make + << " -C " << (this->UseNinja ? homeOutputDir : path.c_str()) + << " " << makeArgs << " " + << target << "\"}\n"; JsonSep = ','; } @@ -326,47 +337,3 @@ std::string cmExtraKateGenerator::GetPathBasename(const std::string& path)const return outputBasename; } - - -// Create the command line for building the given target using the selected -// make -std::string cmExtraKateGenerator::BuildMakeCommand(const std::string& make, - const char* makefile, const char* target) const -{ - std::string command = make; - if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) - { - std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); - command += " /NOLOGO /f ""; - command += makefileName; - command += "" "; - command += " VERBOSE=1 "; - command += target; - } - else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0) - { - // no escaping of spaces in this case, see - // http://public.kitware.com/Bug/view.php?id=10014 - std::string makefileName = makefile; - command += " -f ""; - command += makefileName; - command += "" "; - command += " VERBOSE=1 "; - command += target; - } - else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0) - { - command += " -v "; - command += target; - } - else - { - std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); - command += " -f ""; - command += makefileName; - command += "" "; - command += " VERBOSE=1 "; - command += target; - } - return command; -} diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h index 4979eff..6ced5fe 100644 --- a/Source/cmExtraKateGenerator.h +++ b/Source/cmExtraKateGenerator.h @@ -46,17 +46,17 @@ private: const std::string& target, const std::string& make, const std::string& makeArgs, - const std::string& path) const; + const std::string& path, + const char* homeOutputDir) const; std::string GenerateFilesString(const cmMakefile* mf) const; std::string GetPathBasename(const std::string& path) const; std::string GenerateProjectName(const std::string& name, const std::string& type, const std::string& path) const; - std::string BuildMakeCommand(const std::string& make, - const char* makefile, const char* target) const; std::string ProjectName; + bool UseNinja; }; #endif diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 0f8c4e3..c8010d0 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -82,7 +82,6 @@ static const struct ZeroNode : public cmGeneratorExpressionNode const GeneratorExpressionContent *, cmGeneratorExpressionDAGChecker *) const { - // Unreachable return std::string(); } } zeroNode; @@ -94,13 +93,12 @@ static const struct OneNode : public cmGeneratorExpressionNode virtual bool AcceptsArbitraryContentParameter() const { return true; } - std::string Evaluate(const std::vector<std::string> &, + std::string Evaluate(const std::vector<std::string> ¶meters, cmGeneratorExpressionContext *, const GeneratorExpressionContent *, cmGeneratorExpressionDAGChecker *) const { - // Unreachable - return std::string(); + return parameters.front(); } } oneNode; @@ -203,6 +201,8 @@ static const struct LowerCaseNode : public cmGeneratorExpressionNode { LowerCaseNode() {} + bool AcceptsArbitraryContentParameter() const { return true; } + std::string Evaluate(const std::vector<std::string> ¶meters, cmGeneratorExpressionContext *, const GeneratorExpressionContent *, @@ -217,6 +217,8 @@ static const struct UpperCaseNode : public cmGeneratorExpressionNode { UpperCaseNode() {} + bool AcceptsArbitraryContentParameter() const { return true; } + std::string Evaluate(const std::vector<std::string> ¶meters, cmGeneratorExpressionContext *, const GeneratorExpressionContent *, @@ -231,6 +233,8 @@ static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode { MakeCIdentifierNode() {} + bool AcceptsArbitraryContentParameter() const { return true; } + std::string Evaluate(const std::vector<std::string> ¶meters, cmGeneratorExpressionContext *, const GeneratorExpressionContent *, @@ -350,6 +354,7 @@ static const struct CCompilerIdNode : public CompilerIdNode reportError(context, content->GetOriginalExpression(), "$<C_COMPILER_ID> may only be used with targets. It may not " "be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "C"); @@ -377,6 +382,7 @@ static const struct CXXCompilerIdNode : public CompilerIdNode reportError(context, content->GetOriginalExpression(), "$<CXX_COMPILER_ID> may only be used with targets. It may not " "be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "CXX"); @@ -444,6 +450,7 @@ static const struct CCompilerVersionNode : public CompilerVersionNode reportError(context, content->GetOriginalExpression(), "$<C_COMPILER_VERSION> may only be used with targets. It may not " "be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "C"); @@ -472,6 +479,7 @@ static const struct CxxCompilerVersionNode : public CompilerVersionNode reportError(context, content->GetOriginalExpression(), "$<CXX_COMPILER_VERSION> may only be used with targets. It may " "not be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "CXX"); @@ -504,7 +512,7 @@ struct PlatformIdNode : public cmGeneratorExpressionNode return parameters.front().empty() ? "1" : "0"; } - if (cmsysString_strcasecmp(parameters.begin()->c_str(), platformId) == 0) + if (strcmp(parameters.begin()->c_str(), platformId) == 0) { return "1"; } @@ -1634,14 +1642,6 @@ std::string GeneratorExpressionContent::Evaluate( return std::string(); } - if (node->NumExpectedParameters() == 1 - && node->AcceptsArbitraryContentParameter()) - { - return this->ProcessArbitraryContent(node, identifier, context, - dagChecker, - this->ParamChildren.begin()); - } - std::vector<std::string> parameters; this->EvaluateParameters(node, identifier, context, dagChecker, parameters); if (context->HadError) @@ -1669,33 +1669,35 @@ std::string GeneratorExpressionContent::EvaluateParameters( pend = this->ParamChildren.end(); const bool acceptsArbitraryContent = node->AcceptsArbitraryContentParameter(); - for ( ; pit != pend; ++pit) + int counter = 1; + for ( ; pit != pend; ++pit, ++counter) { - std::string parameter; - std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it = - pit->begin(); - const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end = - pit->end(); - for ( ; it != end; ++it) - { - parameter += (*it)->Evaluate(context, dagChecker); - if (context->HadError) - { - return std::string(); - } - } - parameters.push_back(parameter); - if (acceptsArbitraryContent - && parameters.size() == (unsigned int)numExpected - 1) + if (acceptsArbitraryContent && counter == numExpected) { - assert(pit != pend); std::string lastParam = this->ProcessArbitraryContent(node, identifier, context, dagChecker, - pit + 1); + pit); parameters.push_back(lastParam); return std::string(); } + else + { + std::string parameter; + std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it = + pit->begin(); + const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end = + pit->end(); + for ( ; it != end; ++it) + { + parameter += (*it)->Evaluate(context, dagChecker); + if (context->HadError) + { + return std::string(); + } + } + parameters.push_back(parameter); + } } } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6aff5f0..8b760f1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -104,7 +104,7 @@ struct cmStrictTargetComparison { bool operator()(cmTarget const* t1, cmTarget const* t2) const; }; -typedef std::map<cmTarget*, +typedef std::map<cmTarget const*, cmGeneratorTarget*, cmStrictTargetComparison> cmGeneratorTargetsType; diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index bd3db3e..70004ea 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -44,6 +44,8 @@ public: */ virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *, bool optional); + + virtual bool AllowNotParallel() const { return false; } }; #endif diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3ed612d..3b858af 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -950,7 +950,7 @@ void cmGlobalGenerator::ClearEnabledLanguages() } bool cmGlobalGenerator::IsDependedOn(const char* project, - cmTarget* targetIn) + cmTarget const* targetIn) { // Get all local gens for this project std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project]; @@ -1242,8 +1242,8 @@ bool cmGlobalGenerator::ComputeTargetDepends() { return false; } - std::vector<cmTarget*> const& targets = ctd.GetTargets(); - for(std::vector<cmTarget*>::const_iterator ti = targets.begin(); + std::vector<cmTarget const*> const& targets = ctd.GetTargets(); + for(std::vector<cmTarget const*>::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]); @@ -1306,7 +1306,7 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) cmQtAutoGenerators autogen; if(autogen.InitializeAutogenTarget(&target)) { - autogens.push_back(std::make_pair(autogen, &target)); + autogens.push_back(AutogensType::value_type(autogen, &target)); } } } @@ -1407,6 +1407,10 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects() for(cmGeneratorTargetsType::iterator ti = targets.begin(); ti != targets.end(); ++ti) { + if (ti->second->Target->IsImported()) + { + continue; + } cmGeneratorTarget* gt = ti->second; gt->ClassifySources(); gt->LookupObjectLibraries(); @@ -1460,7 +1464,8 @@ void cmGlobalGenerator::ClearGeneratorMembers() } //---------------------------------------------------------------------------- -cmGeneratorTarget* cmGlobalGenerator::GetGeneratorTarget(cmTarget* t) const +cmGeneratorTarget* +cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const { cmGeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t); if(ti == this->GeneratorTargets.end()) @@ -1982,7 +1987,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() clg = clg->GetParent()) { // This local generator includes the target. - std::set<cmTarget*>& targetSet = + std::set<cmTarget const*>& targetSet = this->LocalGeneratorToTargetMap[clg]; targetSet.insert(&target); @@ -1993,7 +1998,8 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() for(TargetDependSet::const_iterator ti = tgtdeps.begin(); ti != tgtdeps.end(); ++ti) { - targetSet.insert(*ti); + cmTarget const* ttt = *ti; + targetSet.insert(ttt); } } } @@ -2506,7 +2512,7 @@ void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*, //---------------------------------------------------------------------------- cmGlobalGenerator::TargetDependSet const& -cmGlobalGenerator::GetTargetDirectDepends(cmTarget & target) +cmGlobalGenerator::GetTargetDirectDepends(cmTarget const& target) { return this->TargetDependencies[&target]; } @@ -2628,7 +2634,7 @@ bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddTargetDepends(cmTarget* target, +void cmGlobalGenerator::AddTargetDepends(cmTarget const* target, TargetDependSet& projectTargets) { // add the target itself @@ -2639,7 +2645,7 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget* target, TargetDependSet const& ts = this->GetTargetDirectDepends(*target); for(TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i) { - cmTarget* dtarget = *i; + cmTarget const* dtarget = *i; this->AddTargetDepends(dtarget, projectTargets); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index b21bc8b..049b0e6 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -218,7 +218,7 @@ public: /** If check to see if the target is linked to by any other target in the project */ - bool IsDependedOn(const char* project, cmTarget* target); + bool IsDependedOn(const char* project, cmTarget const* target); ///! Find a local generator by its startdirectory cmLocalGenerator* FindLocalGenerator(const char* start_dir); @@ -266,10 +266,10 @@ public: // what targets does the specified target depend on directly // via a target_link_libraries or add_dependencies - TargetDependSet const& GetTargetDirectDepends(cmTarget & target); + TargetDependSet const& GetTargetDirectDepends(cmTarget const& target); /** Get per-target generator information. */ - cmGeneratorTarget* GetGeneratorTarget(cmTarget*) const; + cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const; const std::map<cmStdString, std::vector<cmLocalGenerator*> >& GetProjectMap() const {return this->ProjectMap;} @@ -325,7 +325,8 @@ protected: TargetDependSet& originalTargets, cmLocalGenerator* root, GeneratorVector const&); virtual bool IsRootOnlyTarget(cmTarget* target); - void AddTargetDepends(cmTarget* target, TargetDependSet& projectTargets); + void AddTargetDepends(cmTarget const* target, + TargetDependSet& projectTargets); void SetLanguageEnabledFlag(const char* l, cmMakefile* mf); void SetLanguageEnabledMaps(const char* l, cmMakefile* mf); void FillExtensionToLanguageMap(const char* l, cmMakefile* mf); @@ -335,7 +336,8 @@ protected: virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); bool CheckTargets(); - typedef std::vector<std::pair<cmQtAutoGenerators, cmTarget*> > AutogensType; + typedef std::vector<std::pair<cmQtAutoGenerators, + cmTarget const*> > AutogensType; void CreateQtAutoGeneratorsTargets(AutogensType& autogens); std::string SelectMakeProgram(const char* makeProgram, @@ -364,7 +366,8 @@ protected: cmLocalGenerator* CurrentLocalGenerator; // map from project name to vector of local generators in that project std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap; - std::map<cmLocalGenerator*, std::set<cmTarget *> > LocalGeneratorToTargetMap; + std::map<cmLocalGenerator*, std::set<cmTarget const*> > + LocalGeneratorToTargetMap; // Set of named installation components requested by the project. std::set<cmStdString> InstallComponents; @@ -422,7 +425,7 @@ private: std::vector<std::string> FilesReplacedDuringGenerate; // Store computed inter-target dependencies. - typedef std::map<cmTarget *, TargetDependSet> TargetDependMap; + typedef std::map<cmTarget const*, TargetDependSet> TargetDependMap; TargetDependMap TargetDependencies; // Per-target generator information. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 77571b2..4b92058 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -830,7 +830,7 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies() void cmGlobalNinjaGenerator -::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) +::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs) { const char* configName = target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE"); @@ -879,7 +879,7 @@ cmGlobalNinjaGenerator void cmGlobalNinjaGenerator -::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) +::AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs) { if (target->GetType() == cmTarget::GLOBAL_TARGET) { // Global targets only depend on other utilities, which may not appear in diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 4fd0d5c..de38923 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -283,8 +283,8 @@ public: ASD.insert(deps.begin(), deps.end()); } - void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); - void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); + void AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs); + void AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs); void AddDependencyToAll(cmTarget* target); void AddDependencyToAll(const std::string& input); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 6333873..622a7c5 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -480,7 +480,6 @@ cmGlobalUnixMakefileGenerator3 (l->second->GetType() == cmTarget::SHARED_LIBRARY) || (l->second->GetType() == cmTarget::MODULE_LIBRARY) || (l->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (l->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (l->second->GetType() == cmTarget::UTILITY)) { if(l->second->Target->IsImported()) @@ -658,7 +657,6 @@ cmGlobalUnixMakefileGenerator3 (t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (t->second->GetType() == cmTarget::UTILITY))) { // Add a rule to build the target by name. @@ -680,10 +678,6 @@ cmGlobalUnixMakefileGenerator3 t->second->GetName(), depends, commands, true); - if (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) - { - continue; - } // Add a fast rule to build the target std::string localName = lg->GetRelativeTargetDirectory(*t->second->Target); @@ -757,7 +751,6 @@ cmGlobalUnixMakefileGenerator3 || (t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) - || (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (t->second->GetType() == cmTarget::UTILITY))) { std::string makefileName; @@ -774,64 +767,53 @@ cmGlobalUnixMakefileGenerator3 << localName << "\n\n"; commands.clear(); + makeTargetName = localName; + makeTargetName += "/depend"; + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(),makeTargetName.c_str())); - if(t->second->GetType() != cmTarget::INTERFACE_LIBRARY) + // add requires if we need it for this generator + if (needRequiresStep) { makeTargetName = localName; - makeTargetName += "/depend"; + makeTargetName += "/requires"; commands.push_back(lg->GetRecursiveMakeCall (makefileName.c_str(),makeTargetName.c_str())); + } + makeTargetName = localName; + makeTargetName += "/build"; + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(),makeTargetName.c_str())); - // add requires if we need it for this generator - if (needRequiresStep) - { - makeTargetName = localName; - makeTargetName += "/requires"; - commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); - } - makeTargetName = localName; - makeTargetName += "/build"; - commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); - - // Write the rule. - localName += "/all"; - depends.clear(); + // Write the rule. + localName += "/all"; + depends.clear(); - std::string progressDir = - lg->GetMakefile()->GetHomeOutputDirectory(); - progressDir += cmake::GetCMakeFilesDirectory(); + std::string progressDir = + lg->GetMakefile()->GetHomeOutputDirectory(); + progressDir += cmake::GetCMakeFilesDirectory(); + { + cmOStringStream progCmd; + progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; + // all target counts + progCmd << lg->Convert(progressDir.c_str(), + cmLocalGenerator::FULL, + cmLocalGenerator::SHELL); + progCmd << " "; + std::vector<unsigned long>& progFiles = + this->ProgressMap[t->second->Target].Marks; + for (std::vector<unsigned long>::iterator i = progFiles.begin(); + i != progFiles.end(); ++i) { - cmOStringStream progCmd; - progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; - // all target counts - progCmd << lg->Convert(progressDir.c_str(), - cmLocalGenerator::FULL, - cmLocalGenerator::SHELL); - progCmd << " "; - std::vector<unsigned long>& progFiles = - this->ProgressMap[t->second->Target].Marks; - for (std::vector<unsigned long>::iterator i = progFiles.begin(); - i != progFiles.end(); ++i) - { - progCmd << " " << *i; - } - commands.push_back(progCmd.str()); + progCmd << " " << *i; } - progressDir = "Built target "; - progressDir += t->second->GetName(); - lg->AppendEcho(commands,progressDir.c_str()); - } - else - { - depends.clear(); + commands.push_back(progCmd.str()); } + progressDir = "Built target "; + progressDir += t->second->GetName(); + lg->AppendEcho(commands,progressDir.c_str()); + this->AppendGlobalTargetDepends(depends,*t->second->Target); - if(depends.empty() && this->EmptyRuleHackDepends != "") - { - depends.push_back(this->EmptyRuleHackDepends); - } lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", localName.c_str(), depends, commands, true); @@ -847,7 +829,7 @@ cmGlobalUnixMakefileGenerator3 // Write the rule. commands.clear(); - std::string progressDir = lg->GetMakefile()->GetHomeOutputDirectory(); + progressDir = lg->GetMakefile()->GetHomeOutputDirectory(); progressDir += cmake::GetCMakeFilesDirectory(); { @@ -859,7 +841,7 @@ cmGlobalUnixMakefileGenerator3 cmLocalGenerator::FULL, cmLocalGenerator::SHELL); // - std::set<cmTarget *> emitted; + std::set<cmTarget const*> emitted; progCmd << " " << this->CountProgressMarksInTarget(t->second->Target, emitted); commands.push_back(progCmd.str()); @@ -937,8 +919,8 @@ cmGlobalUnixMakefileGenerator3 //---------------------------------------------------------------------------- size_t cmGlobalUnixMakefileGenerator3 -::CountProgressMarksInTarget(cmTarget* target, - std::set<cmTarget*>& emitted) +::CountProgressMarksInTarget(cmTarget const* target, + std::set<cmTarget const*>& emitted) { size_t count = 0; if(emitted.insert(target).second) @@ -964,9 +946,10 @@ cmGlobalUnixMakefileGenerator3 ::CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg) { size_t count = 0; - std::set<cmTarget*> emitted; - std::set<cmTarget*> const& targets = this->LocalGeneratorToTargetMap[lg]; - for(std::set<cmTarget*>::const_iterator t = targets.begin(); + std::set<cmTarget const*> emitted; + std::set<cmTarget const*> const& targets + = this->LocalGeneratorToTargetMap[lg]; + for(std::set<cmTarget const*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { count += this->CountProgressMarksInTarget(*t, emitted); @@ -987,7 +970,7 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress( //---------------------------------------------------------------------------- bool cmGlobalUnixMakefileGenerator3::ProgressMapCompare -::operator()(cmTarget* l, cmTarget* r) const +::operator()(cmTarget const* l, cmTarget const* r) const { // Order by target name. if(int c = strcmp(l->GetName(), r->GetName())) diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 284f5d1..00a86eb 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -125,6 +125,9 @@ public: const std::string &workingDirectory, const std::string &compileCommand); + /** Does the make tool tolerate .NOTPARALLEL? */ + virtual bool AllowNotParallel() const { return true; } + protected: void WriteMainMakefile2(); void WriteMainCMakefile(); @@ -181,13 +184,14 @@ protected: std::vector<unsigned long> Marks; void WriteProgressVariables(unsigned long total, unsigned long& current); }; - struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*) const; }; - typedef std::map<cmTarget*, TargetProgress, + struct ProgressMapCompare { bool operator()(cmTarget const*, + cmTarget const*) const; }; + typedef std::map<cmTarget const*, TargetProgress, ProgressMapCompare> ProgressMapType; ProgressMapType ProgressMap; - size_t CountProgressMarksInTarget(cmTarget* target, - std::set<cmTarget*>& emitted); + size_t CountProgressMarksInTarget(cmTarget const* target, + std::set<cmTarget const*>& emitted); size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg); cmGeneratedFileStream *CommandDatabase; diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 614a79a..38c47ef 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -205,7 +205,7 @@ void cmGlobalVisualStudio6Generator tt = orderedProjectTargets.begin(); tt != orderedProjectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -271,7 +271,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile() void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, const char* dspname, const char* dir, - cmTarget& target) + cmTarget const& target) { fout << "#########################################################" "######################\n\n"; @@ -364,7 +364,7 @@ void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout) //---------------------------------------------------------------------------- std::string -cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget* target) +cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget const* target) { std::string pname = target->GetName(); pname += "_UTILITY"; diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index cb6cb8b..5521410 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -99,12 +99,12 @@ private: void WriteDSWFile(std::ostream& fout); void WriteDSWHeader(std::ostream& fout); void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, cmTarget const& t); void WriteExternalProject(std::ostream& fout, const char* name, const char* path, const std::set<cmStdString>& dependencies); void WriteDSWFooter(std::ostream& fout); - virtual std::string WriteUtilityDepend(cmTarget* target); + virtual std::string WriteUtilityDepend(cmTarget const* target); std::string MSDevCommand; bool MSDevCommandInitialized; std::string const& GetMSDevCommand(); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 61d3c4c..22e4f08 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -157,7 +157,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, const char* dspname, const char* dir, - cmTarget& t) + cmTarget const& t) { // check to see if this is a fortran build const char* ext = ".vcproj"; @@ -209,7 +209,7 @@ void cmGlobalVisualStudio71Generator ::WriteProjectDepends(std::ostream& fout, const char*, - const char*, cmTarget& target) + const char*, cmTarget const& target) { VSDependSet const& depends = this->VSTargetDepends[&target]; for(VSDependSet::const_iterator di = depends.begin(); @@ -240,7 +240,7 @@ void cmGlobalVisualStudio71Generator const std::set<cmStdString>& depends) { fout << "Project(\"{" - << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942") + << (typeGuid ? typeGuid : this->ExternalProjectType(location)) << "}\") = \"" << name << "\", \"" << this->ConvertToSolutionPath(location) << "\", \"{" diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index e136db7..04e3a55 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -59,9 +59,11 @@ protected: std::vector<cmLocalGenerator*>& generators); virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectConfigurations( std::ostream& fout, const char* name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index a217d8c..bb63289 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -146,6 +146,41 @@ std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand() } //---------------------------------------------------------------------------- +const char* cmGlobalVisualStudio7Generator::ExternalProjectType( + const char* location) +{ + std::string extension = cmSystemTools::GetFilenameLastExtension(location); + if (extension == ".vbproj") + { + return "F184B08F-C81C-45F6-A57F-5ABD9991F28F"; + } + else if (extension == ".csproj") + { + return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"; + } + else if (extension == ".fsproj") + { + return "F2A71F9B-5D33-465A-A702-920D77279786"; + } + else if (extension == ".vdproj") + { + return "54435603-DBB4-11D2-8724-00A0C9A8B90C"; + } + else if (extension == ".dbproj") + { + return "C8D11400-126E-41CD-887F-60BD40844F9E"; + } + else if (extension == ".wixproj") + { + return "930C7802-8A8C-48F9-8165-68863BCCD9DD"; + } + else if (extension == ".pyproj") + { + return "888888A0-9F3D-457C-B088-3A5042F75D52"; + } + return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942"; +} +//---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator::GenerateBuildCommand( std::vector<std::string>& makeCommand, const char* makeProgram, @@ -335,7 +370,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -376,7 +411,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -470,7 +505,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -619,7 +654,7 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path) // the libraries it uses are also done here void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, const char* dspname, - const char* dir, cmTarget& target) + const char* dir, cmTarget const& target) { // check to see if this is a fortran build const char* ext = ".vcproj"; @@ -659,7 +694,7 @@ void cmGlobalVisualStudio7Generator ::WriteProjectDepends(std::ostream& fout, const char* dspname, - const char*, cmTarget& target) + const char*, cmTarget const& target) { int depcount = 0; std::string dspguid = this->GetGUID(dspname); @@ -730,7 +765,7 @@ void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout, std::string d = cmSystemTools::ConvertToOutputPath(location); fout << "Project(" << "\"{" - << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942") + << (typeGuid ? typeGuid : this->ExternalProjectType(location)) << "}\") = \"" << name << "\", \"" << this->ConvertToSolutionPath(location) << "\", \"{" @@ -819,7 +854,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout) //---------------------------------------------------------------------------- std::string -cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget* target) +cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) { std::string pname = target->GetName(); pname += "_UTILITY"; @@ -940,7 +975,7 @@ cmGlobalVisualStudio7Generator std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, - cmTarget* target) + cmTarget const* target) { std::set<std::string> activeConfigs; // if it is a utilitiy target then only make it part of the diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 59e74ba..f69bd84 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -115,15 +115,19 @@ protected: std::string const& GetDevEnvCommand(); virtual std::string FindDevEnvCommand(); + static const char* ExternalProjectType(const char* location); + static cmIDEFlagTable const* GetExtraFlagTableVS7(); virtual void OutputSLNFile(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const&t); virtual void WriteProjectConfigurations( std::ostream& fout, const char* name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, @@ -132,7 +136,7 @@ protected: cmLocalGenerator* root); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); - virtual std::string WriteUtilityDepend(cmTarget* target); + virtual std::string WriteUtilityDepend(cmTarget const* target); virtual void WriteTargetsToSolution( std::ostream& fout, @@ -158,7 +162,7 @@ protected: std::string ConvertToSolutionPath(const char* path); std::set<std::string> IsPartOfDefaultBuild(const char* project, - cmTarget* target); + cmTarget const* target); std::vector<std::string> Configurations; std::map<cmStdString, cmStdString> GUIDMap; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index e4ce13f..12c240b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -415,7 +415,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends() //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator::WriteProjectDepends( - std::ostream& fout, const char*, const char*, cmTarget& t) + std::ostream& fout, const char*, const char*, cmTarget const& t) { TargetDependSet const& unordered = this->GetTargetDirectDepends(t); OrderedTargetDependSet depends(unordered); diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index ad01a24..5b952c4 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -84,7 +84,7 @@ protected: const char* platformMapping = NULL); virtual bool ComputeTargetDepends(); virtual void WriteProjectDepends(std::ostream& fout, const char* name, - const char* path, cmTarget &t); + const char* path, cmTarget const& t); std::string Name; std::string WindowsCEVersion; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 6c782e4..93a597c 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -315,7 +315,7 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget* target, +void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget const* target, TargetSet& linked) { if(linked.insert(target).second) @@ -348,7 +348,7 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmTarget* target) //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::FollowLinkDepends( - cmTarget* target, std::set<cmTarget*>& linked) + cmTarget const* target, std::set<cmTarget const*>& linked) { if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { @@ -397,7 +397,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() } //---------------------------------------------------------------------------- -static bool VSLinkable(cmTarget* t) +static bool VSLinkable(cmTarget const* t) { return t->IsLinkable() || t->GetType() == cmTarget::OBJECT_LIBRARY; } @@ -439,7 +439,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) // Collect implicit link dependencies (target_link_libraries). // Static libraries cannot depend on their link implementation // due to behavior (2), but they do not really need to. - std::set<cmTarget*> linkDepends; + std::set<cmTarget const*> linkDepends; if(target.GetType() != cmTarget::STATIC_LIBRARY) { for(TargetDependSet::const_iterator di = depends.begin(); @@ -454,7 +454,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } // Collect explicit util dependencies (add_dependencies). - std::set<cmTarget*> utilDepends; + std::set<cmTarget const*> utilDepends; for(TargetDependSet::const_iterator di = depends.begin(); di != depends.end(); ++di) { @@ -474,18 +474,18 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } // Emit link dependencies. - for(std::set<cmTarget*>::iterator di = linkDepends.begin(); + for(std::set<cmTarget const*>::iterator di = linkDepends.begin(); di != linkDepends.end(); ++di) { - cmTarget* dep = *di; + cmTarget const* dep = *di; vsTargetDepend.insert(dep->GetName()); } // Emit util dependencies. Possibly use intermediate targets. - for(std::set<cmTarget*>::iterator di = utilDepends.begin(); + for(std::set<cmTarget const*>::iterator di = utilDepends.begin(); di != utilDepends.end(); ++di) { - cmTarget* dep = *di; + cmTarget const* dep = *di; if(allowLinkable || !VSLinkable(dep) || linked.count(dep)) { // Direct dependency allowed. @@ -523,7 +523,8 @@ void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) } //---------------------------------------------------------------------------- -std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget* target) +std::string +cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget const* target) { UtilityDependsMap::iterator i = this->UtilityDepends.find(target); if(i == this->UtilityDepends.end()) @@ -845,7 +846,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, } } } -bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget& target) +bool +cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { // check to see if this is a fortran build std::set<cmStdString> languages; diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index da2d021..54e3c28 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -60,7 +60,7 @@ public: const char* vsSolutionFile = 0); // return true if target is fortran only - bool TargetIsFortranOnly(cmTarget& t); + bool TargetIsFortranOnly(cmTarget const& t); /** Get the top-level registry key for this VS version. */ std::string GetRegistryBase(); @@ -75,7 +75,7 @@ public: /** Return true if building for Windows CE */ virtual bool TargetsWindowsCE() const { return false; } - class TargetSet: public std::set<cmTarget*> {}; + class TargetSet: public std::set<cmTarget const*> {}; struct TargetCompare { bool operator()(cmTarget const* l, cmTarget const* r) const; @@ -96,15 +96,15 @@ protected: virtual bool ComputeTargetDepends(); class VSDependSet: public std::set<cmStdString> {}; - class VSDependMap: public std::map<cmTarget*, VSDependSet> {}; + class VSDependMap: public std::map<cmTarget const*, VSDependSet> {}; VSDependMap VSTargetDepends; void ComputeVSTargetDepends(cmTarget&); bool CheckTargetLinks(cmTarget& target, const char* name); std::string GetUtilityForTarget(cmTarget& target, const char*); - virtual std::string WriteUtilityDepend(cmTarget*) = 0; - std::string GetUtilityDepend(cmTarget* target); - typedef std::map<cmTarget*, cmStdString> UtilityDependsMap; + virtual std::string WriteUtilityDepend(cmTarget const*) = 0; + std::string GetUtilityDepend(cmTarget const* target); + typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap; UtilityDependsMap UtilityDepends; const char* AdditionalPlatformDefinition; @@ -113,11 +113,12 @@ private: void PrintCompilerAdvice(std::ostream&, std::string, const char*) {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; - void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked); + void FollowLinkDepends(cmTarget const* target, + std::set<cmTarget const*>& linked); class TargetSetMap: public std::map<cmTarget*, TargetSet> {}; TargetSetMap TargetLinkClosure; - void FillLinkClosure(cmTarget* target, TargetSet& linked); + void FillLinkClosure(cmTarget const* target, TargetSet& linked); TargetSet const& GetTargetLinkClosure(cmTarget* target); }; diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index 23e60a1..d5350ef 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -43,6 +43,8 @@ public: */ virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *, bool optional); + + virtual bool AllowNotParallel() const { return false; } }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 215d483..b5a46d0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2622,7 +2622,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } //---------------------------------------------------------------------------- -cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t) +cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t) { if(!t) { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index e8cbd14..6281c3b 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -125,7 +125,7 @@ private: multipleOutputPairs ); - cmXCodeObject* FindXCodeTarget(cmTarget*); + cmXCodeObject* FindXCodeTarget(cmTarget const*); std::string GetOrCreateId(const char* name, const char* id); // create cmXCodeObject from these functions so that memory can be managed diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7b9109e..68f45a6 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -328,9 +328,10 @@ cmInstallTargetGenerator::GetInstallFilename(const char* config) const } //---------------------------------------------------------------------------- -std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, - const char* config, - NameType nameType) +std::string +cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, + const char* config, + NameType nameType) { std::string fname; // Compute the name of the library. @@ -515,11 +516,12 @@ cmInstallTargetGenerator std::map<cmStdString, cmStdString> install_name_remap; if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { - std::set<cmTarget*> const& sharedLibs = cli->GetSharedLibrariesLinked(); - for(std::set<cmTarget*>::const_iterator j = sharedLibs.begin(); + std::set<cmTarget const*> const& sharedLibs + = cli->GetSharedLibrariesLinked(); + for(std::set<cmTarget const*>::const_iterator j = sharedLibs.begin(); j != sharedLibs.end(); ++j) { - cmTarget* tgt = *j; + cmTarget const* tgt = *j; // The install_name of an imported target does not change. if(tgt->IsImported()) diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8cf72f9..18c3957 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -53,7 +53,8 @@ public: NameReal }; - static std::string GetInstallFilename(cmTarget*target, const char* config, + static std::string GetInstallFilename(cmTarget const* target, + const char* config, NameType nameType = NameNormal); cmTarget* GetTarget() const { return this->Target; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c3c5299..455f542 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -261,6 +261,10 @@ void cmLocalGenerator::TraceDependencies() for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { + if (t->second->Target->IsImported()) + { + continue; + } t->second->TraceDependencies(); } } @@ -545,6 +549,10 @@ void cmLocalGenerator::GenerateTargetManifest() { continue; } + if (target.Target->IsImported()) + { + continue; + } if(configNames.empty()) { target.GenerateTargetManifest(0); @@ -1386,7 +1394,7 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, - cmTarget* target, + cmTarget const* target, const char* config) { std::vector<std::string> targetDefines; @@ -1469,27 +1477,6 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, includeBinaryDir = true; } - // Hack for VTK 4.0 - 4.4 which depend on the old behavior but do - // not set the backwards compatibility level automatically. - const char* vtkSourceDir = - this->Makefile->GetDefinition("VTK_SOURCE_DIR"); - if(vtkSourceDir) - { - const char* vtk_major = - this->Makefile->GetDefinition("VTK_MAJOR_VERSION"); - const char* vtk_minor = - this->Makefile->GetDefinition("VTK_MINOR_VERSION"); - vtk_major = vtk_major? vtk_major : "4"; - vtk_minor = vtk_minor? vtk_minor : "4"; - int vmajor = 0; - int vminor = 0; - if(sscanf(vtk_major, "%d", &vmajor) && - sscanf(vtk_minor, "%d", &vminor) && vmajor == 4 && vminor <= 4) - { - includeSourceDir = true; - } - } - // Do not repeat an include path. std::set<cmStdString> emitted; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9a89f0f..ad662d5 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -224,8 +224,9 @@ public: bool stripImplicitInclDirs = true); void AddCompileOptions(std::string& flags, cmTarget* target, const char* lang, const char* config); - void AddCompileDefinitions(std::set<std::string>& defines, cmTarget* target, - const char* config); + void AddCompileDefinitions(std::set<std::string>& defines, + cmTarget const* target, + const char* config); /** Compute the language used to compile the given source file. */ const char* GetSourceFileLanguage(const cmSourceFile& source); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 6ca386c..20e8eea 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -388,7 +388,6 @@ void cmLocalUnixMakefileGenerator3 (t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (t->second->GetType() == cmTarget::UTILITY)) { if (t->second->Target->IsImported()) @@ -1686,6 +1685,17 @@ void cmLocalUnixMakefileGenerator3 "default_target", depends, no_commands, true); + + // Help out users that try "gmake target1 target2 -j". + cmGlobalUnixMakefileGenerator3* gg = + static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); + if(gg->AllowNotParallel()) + { + std::vector<std::string> no_depends; + this->WriteMakeRule(ruleFileStream, + "Allow only one \"make -f Makefile2\" at a time, but pass parallelism.", + ".NOTPARALLEL", no_depends, no_commands, true); + } } this->WriteSpecialTargetsTop(ruleFileStream); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 35818ee..399b582 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -85,9 +85,6 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() case cmTarget::OBJECT_LIBRARY: this->WriteObjectLibraryRules(); break; - case cmTarget::INTERFACE_LIBRARY: - // Nothing to do. - break; default: // If language is not known, this is an error. cmSystemTools::Error("Unknown Library Type"); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 2063a24..6e70285 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -76,7 +76,6 @@ cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt) case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: case cmTarget::OBJECT_LIBRARY: - case cmTarget::INTERFACE_LIBRARY: result = new cmMakefileLibraryTargetGenerator(tgt); break; case cmTarget::UTILITY: diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 835e3b4..abf20cb 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -138,14 +138,14 @@ cmQtAutoGenerators::cmQtAutoGenerators() } } -static std::string getAutogenTargetName(cmTarget *target) +static std::string getAutogenTargetName(cmTarget const* target) { std::string autogenTargetName = target->GetName(); autogenTargetName += "_automoc"; return autogenTargetName; } -static std::string getAutogenTargetDir(cmTarget *target) +static std::string getAutogenTargetDir(cmTarget const* target) { cmMakefile* makefile = target->GetMakefile(); std::string targetDir = makefile->GetCurrentOutputDirectory(); @@ -221,6 +221,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) if (target->GetPropertyAsBool("AUTORCC")) { toolNames.push_back("rcc"); + this->InitializeAutoRccTarget(target); } std::string tools = toolNames[0]; @@ -295,7 +296,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) return true; } -static void GetCompileDefinitionsAndDirectories(cmTarget *target, +static void GetCompileDefinitionsAndDirectories(cmTarget const* target, const char * config, std::string &incs, std::string &defs) @@ -303,10 +304,12 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target, cmMakefile* makefile = target->GetMakefile(); cmLocalGenerator* localGen = makefile->GetLocalGenerator(); std::vector<std::string> includeDirs; - cmGeneratorTarget gtgt(target); + cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); // Get the include dirs for this target, without stripping the implicit // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667 - localGen->GetIncludeDirectories(includeDirs, >gt, "CXX", config, false); + localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false); const char* sep = ""; incs = ""; for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin(); @@ -332,7 +335,7 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target, } } -void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) +void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { cmMakefile* makefile = target->GetMakefile(); @@ -435,7 +438,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) } } -void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget* target, +void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, const std::string &autogenTargetName, std::map<std::string, std::string> &configIncludes, std::map<std::string, std::string> &configDefines) @@ -614,7 +617,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -static void GetUicOpts(cmTarget *target, const char * config, +static void GetUicOpts(cmTarget const* target, const char * config, std::string &optString) { std::vector<std::string> opts; @@ -631,7 +634,7 @@ static void GetUicOpts(cmTarget *target, const char * config, } } -void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget* target, +void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, std::map<std::string, std::string> &configUicOptions) { cmMakefile *makefile = target->GetMakefile(); @@ -801,14 +804,56 @@ void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) +void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target) { - std::string _rcc_files; - const char* sepRccFiles = ""; cmMakefile *makefile = target->GetMakefile(); + const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + std::vector<cmSourceFile*> newFiles; + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string ext = sf->GetExtension(); + if (ext == "qrc") + { + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); + + if (!skip) + { + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); + rcc_output_file += "/qrc_" + basename + ".cpp"; + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + rcc_output_file.c_str(), false); + cmSourceFile* rccCppSource + = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); + newFiles.push_back(rccCppSource); + } + } + } + + for(std::vector<cmSourceFile*>::const_iterator fileIt = newFiles.begin(); + fileIt != newFiles.end(); + ++fileIt) + { + target->AddSourceFile(*fileIt); + } +} + +void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) +{ + std::string _rcc_files; + const char* sepRccFiles = ""; + cmMakefile *makefile = target->GetMakefile(); + const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); std::string rccFileFiles; @@ -841,17 +886,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) _rcc_files += absFile; sepRccFiles = ";"; - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(absFile); - - std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); - rcc_output_file += "/qrc_" + basename + ".cpp"; - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - rcc_output_file.c_str(), false); - cmSourceFile* rccCppSource - = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); - newFiles.push_back(rccCppSource); - if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS")) { std::vector<std::string> optsVec; @@ -880,13 +914,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) } } - for(std::vector<cmSourceFile*>::const_iterator fileIt = newFiles.begin(); - fileIt != newFiles.end(); - ++fileIt) - { - target->AddSourceFile(*fileIt); - } - makefile->AddDefinition("_rcc_files", cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str()); @@ -1361,18 +1388,18 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) if (this->RunMocFailed) { - std::cerr << "moc failed..."<< std::endl; + std::cerr << "moc failed..." << std::endl; return false; } if (this->RunUicFailed) { - std::cerr << "uic failed..."<< std::endl; + std::cerr << "uic failed..." << std::endl; return false; } if (this->RunRccFailed) { - std::cerr << "rcc failed..."<< std::endl; + std::cerr << "rcc failed..." << std::endl; return false; } outStream.flush(); diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index e877f7d..80123d8 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -24,16 +24,17 @@ public: bool Run(const char* targetDirectory, const char *config); bool InitializeAutogenTarget(cmTarget* target); - void SetupAutoGenerateTarget(cmTarget* target); + void SetupAutoGenerateTarget(cmTarget const* target); private: - void SetupAutoMocTarget(cmTarget* target, + void SetupAutoMocTarget(cmTarget const* target, const std::string &autogenTargetName, std::map<std::string, std::string> &configIncludes, std::map<std::string, std::string> &configDefines); - void SetupAutoUicTarget(cmTarget* target, + void SetupAutoUicTarget(cmTarget const* target, std::map<std::string, std::string> &configUicOptions); - void SetupAutoRccTarget(cmTarget* target); + void InitializeAutoRccTarget(cmTarget* target); + void SetupAutoRccTarget(cmTarget const* target); cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, const char* targetDirectory); diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 7369fe6..eb6e52f 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -423,19 +423,19 @@ struct cmStrCmp { cmStrCmp(const char *test) : m_test(test) {} cmStrCmp(std::string &test) : m_test(test.c_str()) {} - bool operator()(const char * input) + bool operator()(const char * input) const { return strcmp(input, m_test) == 0; } // For use with binary_search - bool operator()(const char *str1, const char *str2) + bool operator()(const char *str1, const char *str2) const { return strcmp(str1, str2) < 0; } private: - const char *m_test; + const char * const m_test; }; #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9ea7f07..9faf0d9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -828,7 +828,8 @@ void cmTarget::GetDirectLinkLibraries(const char *config, //---------------------------------------------------------------------------- void cmTarget::GetInterfaceLinkLibraries(const char *config, - std::vector<std::string> &libs, cmTarget *head) const + std::vector<std::string> &libs, + cmTarget const* head) const { const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES"); if (prop) @@ -4903,6 +4904,15 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, const char** imp, std::string& suffix) const { + if (this->GetType() == INTERFACE_LIBRARY) + { + // This method attempts to find a config-specific LOCATION for the + // IMPORTED library. In the case of INTERFACE_LIBRARY, there is no + // LOCATION at all, so leaving *loc and *imp unchanged is the appropriate + // and valid response. + return true; + } + // Track the configuration-specific property suffix. suffix = "_"; suffix += desired_config; @@ -5035,8 +5045,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, const char* loc = 0; const char* imp = 0; std::string suffix; - if (this->GetType() != INTERFACE_LIBRARY && - !this->GetMappedConfig(desired_config, &loc, &imp, suffix)) + if (!this->GetMappedConfig(desired_config, &loc, &imp, suffix)) { return; } @@ -5648,7 +5657,7 @@ void cmTarget::ComputeLinkImplementation(const char* config, { e << "Target \"" << this->GetName() << "\" links to target \"" << item << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or a ALIAS target is " + "call is missing for an IMPORTED target, or an ALIAS target is " "missing?"; this->Makefile->GetCMakeInstance()->IssueMessage(messageType, e.str(), @@ -5805,7 +5814,8 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template<typename PropertyType> -void checkPropertyConsistency(cmTarget const* depender, cmTarget *dependee, +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, const char *propName, std::set<cmStdString> &emitted, const char *config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e43d138..e026c59 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -188,7 +188,7 @@ public: cmTarget const* head) const; void GetInterfaceLinkLibraries(const char *config, std::vector<std::string> &, - cmTarget *head) const; + cmTarget const* head) const; /** Compute the link type to use for the given configuration. */ LinkLibraryType ComputeLinkType(const char* config) const; diff --git a/Source/cmTargetDepend.h b/Source/cmTargetDepend.h index 258bacd..1feb072 100644 --- a/Source/cmTargetDepend.h +++ b/Source/cmTargetDepend.h @@ -20,17 +20,17 @@ class cmTarget; It may be marked as a 'link' or 'util' edge or both. */ class cmTargetDepend { - cmTarget* Target; + cmTarget const* Target; // The set order depends only on the Target, so we use // mutable members to acheive a map with set syntax. mutable bool Link; mutable bool Util; public: - cmTargetDepend(cmTarget* t): Target(t), Link(false), Util(false) {} - operator cmTarget*() const { return this->Target; } - cmTarget* operator->() const { return this->Target; } - cmTarget& operator*() const { return *this->Target; } + cmTargetDepend(cmTarget const* t): Target(t), Link(false), Util(false) {} + operator cmTarget const*() const { return this->Target; } + cmTarget const* operator->() const { return this->Target; } + cmTarget const& operator*() const { return *this->Target; } friend bool operator < (cmTargetDepend const& l, cmTargetDepend const& r) { return l.Target < r.Target; } void SetType(bool strong) const diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 10663b7..b9ae701 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1841,7 +1841,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() for( OrderedTargetDependSet::const_iterator i = depends.begin(); i != depends.end(); ++i) { - cmTarget* dt = *i; + cmTarget const* dt = *i; if(dt->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; diff --git a/Source/kwsys/Encoding.hxx.in b/Source/kwsys/Encoding.hxx.in index 60a4a8e..aba4175 100644 --- a/Source/kwsys/Encoding.hxx.in +++ b/Source/kwsys/Encoding.hxx.in @@ -14,6 +14,7 @@ #include <@KWSYS_NAMESPACE@/Configure.hxx> #include <@KWSYS_NAMESPACE@/stl/string> +#include <@KWSYS_NAMESPACE@/stl/vector> /* Define these macros temporarily to keep the code readable. */ #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS @@ -25,6 +26,36 @@ namespace @KWSYS_NAMESPACE@ class @KWSYS_NAMESPACE@_EXPORT Encoding { public: + + // Container class for argc/argv. + class CommandLineArguments + { + public: + // On Windows, get the program command line arguments + // in this Encoding module's 8 bit encoding. + // On other platforms the given argc/argv is used, and + // to be consistent, should be the argc/argv from main(). + static CommandLineArguments Main(int argc, char const* const* argv); + + // Construct CommandLineArguments with the given + // argc/argv. It is assumed that the string is already + // in the encoding used by this module. + CommandLineArguments(int argc, char const* const* argv); + + // Construct CommandLineArguments with the given + // argc and wide argv. This is useful if wmain() is used. + CommandLineArguments(int argc, wchar_t const* const* argv); + ~CommandLineArguments(); + CommandLineArguments(const CommandLineArguments&); + CommandLineArguments& operator=(const CommandLineArguments&); + + int argc() const; + char const* const* argv() const; + + protected: + std::vector<char*> argv_; + }; + /** * Convert between char and wchar_t */ diff --git a/Source/kwsys/EncodingC.c b/Source/kwsys/EncodingC.c index a36eecc..cda78e2 100644 --- a/Source/kwsys/EncodingC.c +++ b/Source/kwsys/EncodingC.c @@ -68,7 +68,7 @@ size_t kwsysEncoding_wcstombs(char* dest, const wchar_t* str, size_t n) char* kwsysEncoding_DupToNarrow(const wchar_t* str) { char* ret = NULL; - size_t length = kwsysEncoding_wcstombs(0, str, 0); + size_t length = kwsysEncoding_wcstombs(0, str, 0) + 1; if(length > 0) { ret = malloc(length); diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx index aebc148..f76deb5 100644 --- a/Source/kwsys/EncodingCXX.cxx +++ b/Source/kwsys/EncodingCXX.cxx @@ -29,6 +29,7 @@ #endif #include <stdlib.h> +#include <string.h> #ifdef _MSC_VER # pragma warning (disable: 4786) @@ -42,6 +43,98 @@ namespace KWSYS_NAMESPACE { +Encoding::CommandLineArguments +Encoding::CommandLineArguments::Main(int argc, char const* const* argv) +{ +#ifdef _WIN32 + (void) argc; + (void) argv; + + int ac; + LPWSTR* w_av = CommandLineToArgvW(GetCommandLineW(), &ac); + + std::vector<std::string> av1(ac); + std::vector<char const*> av2(ac); + for(int i=0; i<ac; i++) + { + av1[i] = ToNarrow(w_av[i]); + av2[i] = av1[i].c_str(); + } + LocalFree(w_av); + return CommandLineArguments(ac, &av2[0]); +#else + return CommandLineArguments(argc, argv); +#endif +} + +Encoding::CommandLineArguments::CommandLineArguments(int ac, + char const* const* av) +{ + this->argv_.resize(ac+1); + for(int i=0; i<ac; i++) + { + this->argv_[i] = strdup(av[i]); + } + this->argv_[ac] = 0; +} + +Encoding::CommandLineArguments::CommandLineArguments(int ac, + wchar_t const* const* av) +{ + this->argv_.resize(ac+1); + for(int i=0; i<ac; i++) + { + this->argv_[i] = kwsysEncoding_DupToNarrow(av[i]); + } + this->argv_[ac] = 0; +} + +Encoding::CommandLineArguments::~CommandLineArguments() +{ + for(size_t i=0; i<this->argv_.size(); i++) + { + free(argv_[i]); + } +} + +Encoding::CommandLineArguments:: + CommandLineArguments(const CommandLineArguments& other) +{ + this->argv_.resize(other.argv_.size()); + for(size_t i=0; i<this->argv_.size(); i++) + { + this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0; + } +} + +Encoding::CommandLineArguments& +Encoding::CommandLineArguments::operator=(const CommandLineArguments& other) +{ + size_t i; + for(i=0; i<this->argv_.size(); i++) + { + free(this->argv_[i]); + } + + this->argv_.resize(other.argv_.size()); + for(i=0; i<this->argv_.size(); i++) + { + this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0; + } + + return *this; +} + +int Encoding::CommandLineArguments::argc() const +{ + return static_cast<int>(this->argv_.size() - 1); +} + +char const* const* Encoding::CommandLineArguments::argv() const +{ + return &this->argv_[0]; +} + #if KWSYS_STL_HAS_WSTRING kwsys_stl::wstring Encoding::ToWide(const kwsys_stl::string& str) diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in index 8170fb3..c340c55 100644 --- a/Source/kwsys/FStream.hxx.in +++ b/Source/kwsys/FStream.hxx.in @@ -81,7 +81,7 @@ namespace @KWSYS_NAMESPACE@ internal_buffer_type *rdbuf() const { - return buf_.get(); + return buf_; } ~basic_ifstream() diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index b9af2f1..faeb967 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -2449,6 +2449,7 @@ static void kwsysProcessKill(pid_t process_id) if(f) { size_t nread = fread(buffer, 1, KWSYSPE_PIPE_BUFFER_SIZE, f); + fclose(f); buffer[nread] = '\0'; if(nread > 0) { @@ -2463,7 +2464,6 @@ static void kwsysProcessKill(pid_t process_id) } } } - fclose(f); } } } diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 2f6c949..5f20853 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -3162,8 +3162,17 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() kwsys_stl::string cores = this->ExtractValueFromCpuInfoFile(buffer,"cpu cores"); int numberOfCoresPerCPU=atoi(cores.c_str()); - this->NumberOfPhysicalCPU=static_cast<unsigned int>( - numberOfCoresPerCPU*(maxId+1)); + if (maxId > 0) + { + this->NumberOfPhysicalCPU=static_cast<unsigned int>( + numberOfCoresPerCPU*(maxId+1)); + } + else + { + // Linux Sparc: get cpu count + this->NumberOfPhysicalCPU= + atoi(this->ExtractValueFromCpuInfoFile(buffer,"ncpus active").c_str()); + } #else // __CYGWIN__ // does not have "physical id" entries, neither "cpu cores" @@ -3185,7 +3194,19 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() // CPU speed (checking only the first processor) kwsys_stl::string CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer,"cpu MHz"); - this->CPUSpeedInMHz = static_cast<float>(atof(CPUSpeed.c_str())); + if(!CPUSpeed.empty()) + { + this->CPUSpeedInMHz = static_cast<float>(atof(CPUSpeed.c_str())); + } +#ifdef __linux + else + { + // Linux Sparc: CPU speed is in Hz and encoded in hexadecimal + CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer,"Cpu0ClkTck"); + this->CPUSpeedInMHz = static_cast<float>( + strtoull(CPUSpeed.c_str(),0,16))/1000000.0f; + } +#endif // Chip family kwsys_stl::string familyStr = @@ -4991,7 +5012,12 @@ bool SystemInformationImplementation::QueryHPUXProcessor() case CPU_PA_RISC2_0: this->ChipID.Vendor = "Hewlett-Packard"; this->ChipID.Family = 0x200; +# ifdef CPU_HP_INTEL_EM_1_0 + case CPU_HP_INTEL_EM_1_0: +# endif +# ifdef CPU_IA64_ARCHREV_0 case CPU_IA64_ARCHREV_0: +# endif this->ChipID.Vendor = "GenuineIntel"; this->Features.HasIA64 = true; break; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 4649f3b..f4a443f 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2115,10 +2115,10 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) SystemTools::RemoveFile(destination); #if defined(_WIN32) || defined(__CYGWIN__) - kwsys_ios::ofstream fout(destination, + kwsys::ofstream fout(destination, kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc); #else - kwsys_ios::ofstream fout(destination, + kwsys::ofstream fout(destination, kwsys_ios::ios::out | kwsys_ios::ios::trunc); #endif if(!fout) diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx index 8e74a50..094588c 100644 --- a/Source/kwsys/testEncoding.cxx +++ b/Source/kwsys/testEncoding.cxx @@ -16,14 +16,18 @@ #endif #include KWSYS_HEADER(Encoding.hxx) +#include KWSYS_HEADER(Encoding.h) #include KWSYS_HEADER(ios/iostream) #include <locale.h> +#include <string.h> +#include <stdlib.h> // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 # include "Encoding.hxx.in" +# include "Encoding.h.in" # include "kwsys_ios_iostream.h.in" #endif @@ -68,11 +72,16 @@ static int testHelloWorldEncoding() std::cout << str << std::endl; std::wstring wstr = kwsys::Encoding::ToWide(str); std::string str2 = kwsys::Encoding::ToNarrow(wstr); - if(!wstr.empty() && str != str2) + wchar_t* c_wstr = kwsysEncoding_DupToWide(str.c_str()); + char* c_str2 = kwsysEncoding_DupToNarrow(c_wstr); + if(!wstr.empty() && (str != str2 || strcmp(c_str2, str.c_str()))) { std::cout << "converted string was different: " << str2 << std::endl; + std::cout << "converted string was different: " << c_str2 << std::endl; ret++; } + free(c_wstr); + free(c_str2); } return ret; } @@ -136,6 +145,36 @@ static int testRobustEncoding() return ret; } +static int testCommandLineArguments() +{ + int status = 0; + + char const* argv[2] = { + "./app.exe", + (char const*)helloWorldStrings[1] + }; + + kwsys::Encoding::CommandLineArguments args(2, argv); + kwsys::Encoding::CommandLineArguments arg2 = + kwsys::Encoding::CommandLineArguments(args); + + char const* const* u8_argv = args.argv(); + for(int i=0; i<args.argc(); i++) + { + char const* u8_arg = u8_argv[i]; + if(strcmp(argv[i], u8_arg) != 0) + { + std::cout << "argv[" << i << "] " << argv[i] << " != " + << u8_arg << std::endl; + status++; + } + } + + kwsys::Encoding::CommandLineArguments args3 = + kwsys::Encoding::CommandLineArguments::Main(2, argv); + + return status; +} //---------------------------------------------------------------------------- int testEncoding(int, char*[]) @@ -154,6 +193,7 @@ int testEncoding(int, char*[]) ret |= testHelloWorldEncoding(); ret |= testRobustEncoding(); + ret |= testCommandLineArguments(); return ret; } |