diff options
Diffstat (limited to 'Source')
44 files changed, 344 insertions, 159 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 5adced0..ea5c9be 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 20131119) +set(CMake_VERSION_TWEAK 20131125) #set(CMake_VERSION_RC 1) diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 39eeb70..e480fff 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -763,7 +763,7 @@ void cmCTestBuildHandler::GenerateXMLLaunchedFragment(std::ostream& os, bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname) { // error-{hash}.xml - return (strncmp(fname, "error-", 6) == 0 && + return (cmHasLiteralPrefix(fname, "error-") && strcmp(fname+strlen(fname)-4, ".xml") == 0); } @@ -771,7 +771,7 @@ bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname) bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname) { // warning-{hash}.xml - return (strncmp(fname, "warning-", 8) == 0 && + return (cmHasLiteralPrefix(fname, "warning-") && strcmp(fname+strlen(fname)-4, ".xml") == 0); } diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 5b34491..725f613 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -536,11 +536,11 @@ private: void DoHeaderLine() { // Look for header fields that we need. - if(strncmp(this->Line.c_str(), "commit ", 7) == 0) + if(cmHasLiteralPrefix(this->Line.c_str(), "commit ")) { this->Rev.Rev = this->Line.c_str()+7; } - else if(strncmp(this->Line.c_str(), "author ", 7) == 0) + else if(cmHasLiteralPrefix(this->Line.c_str(), "author ")) { Person author; this->ParsePerson(this->Line.c_str()+7, author); @@ -548,7 +548,7 @@ private: this->Rev.EMail = author.EMail; this->Rev.Date = this->FormatDateTime(author); } - else if(strncmp(this->Line.c_str(), "committer ", 10) == 0) + else if(cmHasLiteralPrefix(this->Line.c_str(), "committer ")) { Person committer; this->ParsePerson(this->Line.c_str()+10, committer); diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index f1f4649..4308a4d 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -102,6 +102,13 @@ if(APPLE) MACOSX_PACKAGE_LOCATION Resources) endif() +if(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL) + install(FILES ${CMake_SOURCE_DIR}/Licenses/LGPLv2.1.txt + DESTINATION ${CMAKE_DATA_DIR}/Licenses) + set_property(SOURCE CMakeSetupDialog.cxx + PROPERTY COMPILE_DEFINITIONS CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL) +endif() + set(CMAKE_INCLUDE_CURRENT_DIR ON) add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS}) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index a7665c8..1903c02 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -34,6 +34,7 @@ #include "QCMakeCacheView.h" #include "AddCacheEntry.h" #include "FirstConfigure.h" +#include "cmSystemTools.h" #include "cmVersion.h" QCMakeThread::QCMakeThread(QObject* p) @@ -807,12 +808,26 @@ void CMakeSetupDialog::doDeleteCache() void CMakeSetupDialog::doAbout() { - QString msg = tr("CMake %1\n" - "Using Qt %2\n" - "www.cmake.org"); - + QString msg = tr( + "CMake %1 (cmake.org).\n" + "CMake suite maintained by Kitware, Inc. (kitware.com).\n" + "Distributed under terms of the BSD 3-Clause License.\n" + "\n" + "CMake GUI maintained by csimsoft,\n" + "built using Qt %2 (qt-project.org).\n" +#ifdef CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL + "\n" + "The Qt Toolkit is Copyright (C) Digia Plc and/or its subsidiary(-ies).\n" + "Qt is licensed under terms of the GNU LGPLv2.1, available at:\n" + " \"%3\"" +#endif + ); msg = msg.arg(cmVersion::GetCMakeVersion()); msg = msg.arg(qVersion()); +#ifdef CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL + std::string lgpl = cmSystemTools::GetCMakeRoot()+"/Licenses/LGPLv2.1.txt"; + msg = msg.arg(lgpl.c_str()); +#endif QDialog dialog; dialog.setWindowTitle(tr("About")); @@ -946,6 +961,7 @@ void CMakeSetupDialog::saveBuildPaths(const QStringList& paths) void CMakeSetupDialog::setCacheModified() { this->CacheModified = true; + this->ConfigureNeeded = true; this->enterState(ReadyConfigure); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index bfabc9f..125a3bf 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1131,11 +1131,11 @@ int cmCTest::GetTestModelFromString(const char* str) return cmCTest::EXPERIMENTAL; } std::string rstr = cmSystemTools::LowerCase(str); - if ( strncmp(rstr.c_str(), "cont", 4) == 0 ) + if ( cmHasLiteralPrefix(rstr.c_str(), "cont") ) { return cmCTest::CONTINUOUS; } - if ( strncmp(rstr.c_str(), "nigh", 4) == 0 ) + if ( cmHasLiteralPrefix(rstr.c_str(), "nigh") ) { return cmCTest::NIGHTLY; } diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 3152c2a..0ef3d2e 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1902,6 +1902,10 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, if(use_build_rpath || use_link_rpath) { std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); + const char *stagePath + = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); + const char *installPrefix + = this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); cmSystemTools::ConvertToUnixSlashes(rootPath); std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath(); for(std::vector<std::string>::const_iterator ri = rdirs.begin(); @@ -1916,6 +1920,14 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, { d = d.substr(rootPath.size()); } + else if (stagePath && *stagePath && d.find(stagePath) == 0) + { + std::string suffix = d.substr(strlen(stagePath)); + d = installPrefix; + d += "/"; + d += suffix; + cmSystemTools::ConvertToUnixSlashes(d); + } if(emitted.insert(d).second) { runtimeDirs.push_back(d); @@ -1936,6 +1948,14 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, { d = d.substr(rootPath.size()); } + else if (stagePath && *stagePath && d.find(stagePath) == 0) + { + std::string suffix = d.substr(strlen(stagePath)); + d = installPrefix; + d += "/"; + d += suffix; + cmSystemTools::ConvertToUnixSlashes(d); + } if(emitted.insert(d).second) { runtimeDirs.push_back(d); diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 8029577..8576bf2 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -95,8 +95,12 @@ cmDocumentation::~cmDocumentation() //---------------------------------------------------------------------------- bool cmDocumentation::PrintVersion(std::ostream& os) { - os << this->GetNameString() << " version " - << cmVersion::GetCMakeVersion() << "\n"; + os << + this->GetNameString() << + " version " << cmVersion::GetCMakeVersion() << "\n" + "\n" + "CMake suite maintained by Kitware, Inc. (kitware.com).\n" + ; return true; } @@ -195,24 +199,27 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) void cmDocumentation::WarnFormFromFilename( - cmDocumentation::RequestedHelpItem& request) + cmDocumentation::RequestedHelpItem& request, bool& result) { std::string ext = cmSystemTools::GetFilenameLastExtension(request.Filename); ext = cmSystemTools::UpperCase(ext); if ((ext == ".HTM") || (ext == ".HTML")) { request.HelpType = cmDocumentation::None; + result = true; cmSystemTools::Message("Warning: HTML help format no longer supported"); } else if (ext == ".DOCBOOK") { request.HelpType = cmDocumentation::None; + result = true; cmSystemTools::Message("Warning: Docbook help format no longer supported"); } // ".1" to ".9" should be manpages else if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9')) { request.HelpType = cmDocumentation::None; + result = true; cmSystemTools::Message("Warning: Man help format no longer supported"); } } @@ -300,28 +307,28 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, help.HelpType = cmDocumentation::OneManual; help.Argument = "cmake-properties.7"; GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-policies") == 0) { help.HelpType = cmDocumentation::OneManual; help.Argument = "cmake-policies.7"; GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-variables") == 0) { help.HelpType = cmDocumentation::OneManual; help.Argument = "cmake-variables.7"; GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-modules") == 0) { help.HelpType = cmDocumentation::OneManual; help.Argument = "cmake-modules.7"; GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-custom-modules") == 0) { @@ -335,7 +342,7 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, help.HelpType = cmDocumentation::OneManual; help.Argument = "cmake-commands.7"; GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-compatcommands") == 0) { @@ -368,42 +375,42 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); help.Argument = cmSystemTools::LowerCase(help.Argument); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-module") == 0) { help.HelpType = cmDocumentation::OneModule; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-property") == 0) { help.HelpType = cmDocumentation::OneProperty; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-policy") == 0) { help.HelpType = cmDocumentation::OnePolicy; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-variable") == 0) { help.HelpType = cmDocumentation::OneVariable; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-manual") == 0) { help.HelpType = cmDocumentation::OneManual; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - this->WarnFormFromFilename(help); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-command-list") == 0) { diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 209cc27..05c0442 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -137,7 +137,7 @@ private: std::vector<RequestedHelpItem> RequestedHelpItems; cmDocumentationFormatter Formatter; - static void WarnFormFromFilename(RequestedHelpItem& request); + static void WarnFormFromFilename(RequestedHelpItem& request, bool& result); }; #endif diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index fdc075e..2ce4458 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -240,7 +240,7 @@ static bool checkInterfaceDirs(const std::string &prepro, { continue; } - if (strncmp(li->c_str(), "${_IMPORT_PREFIX}", 17) == 0) + if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}")) { continue; } diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 133944e..ad17556 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -81,10 +81,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) os << "# Compute the installation prefix relative to this file.\n" << "get_filename_component(_IMPORT_PREFIX" << " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; - if(strncmp(absDestS.c_str(), "/lib/", 5) == 0 || - strncmp(absDestS.c_str(), "/lib64/", 7) == 0 || - strncmp(absDestS.c_str(), "/usr/lib/", 9) == 0 || - strncmp(absDestS.c_str(), "/usr/lib64/", 11) == 0) + if(cmHasLiteralPrefix(absDestS.c_str(), "/lib/") || + cmHasLiteralPrefix(absDestS.c_str(), "/lib64/") || + cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib/") || + cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/")) { // Handle "/usr move" symlinks created by some Linux distros. os << diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx index 9c965cc..0d42c35 100644 --- a/Source/cmExternalMakefileProjectGenerator.cxx +++ b/Source/cmExternalMakefileProjectGenerator.cxx @@ -13,6 +13,12 @@ #include "cmExternalMakefileProjectGenerator.h" +void cmExternalMakefileProjectGenerator +::EnableLanguage(std::vector<std::string> const&, + cmMakefile *, bool) +{ +} + std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName( const char* globalGenerator, const char* extraGenerator) diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h index 182c1a8..bce441d 100644 --- a/Source/cmExternalMakefileProjectGenerator.h +++ b/Source/cmExternalMakefileProjectGenerator.h @@ -41,6 +41,8 @@ public: /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, const char* fullName) const = 0; + virtual void EnableLanguage(std::vector<std::string> const& languages, + cmMakefile *, bool optional); ///! set the global generator which will generate the makefiles virtual void SetGlobalGenerator(cmGlobalGenerator* generator) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 676d4ed..755b445 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -51,6 +51,29 @@ void cmExtraEclipseCDT4Generator } //---------------------------------------------------------------------------- +void cmExtraEclipseCDT4Generator +::EnableLanguage(std::vector<std::string> const& languages, + cmMakefile *, bool) +{ + for (std::vector<std::string>::const_iterator lit = languages.begin(); + lit != languages.end(); ++lit) + { + if (*lit == "CXX") + { + this->Natures.insert("org.eclipse.cdt.core.ccnature"); + } + else if (*lit == "C") + { + this->Natures.insert("org.eclipse.cdt.core.cnature"); + } + else if (*lit == "Java") + { + this->Natures.insert("org.eclipse.jdt.core.javanature"); + } + } +} + +//---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::Generate() { const cmMakefile* mf @@ -433,13 +456,28 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() // set natures for c/c++ projects fout << "\t<natures>\n" - // TODO: ccnature only if it is c++ ??? - "\t\t<nature>org.eclipse.cdt.core.ccnature</nature>\n" "\t\t<nature>org.eclipse.cdt.make.core.makeNature</nature>\n" - "\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\n" - "\t\t<nature>org.eclipse.cdt.core.cnature</nature>\n" - "\t</natures>\n" - ; + "\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\n"; + + for (std::set<std::string>::const_iterator nit=this->Natures.begin(); + nit != this->Natures.end(); ++nit) + { + fout << "\t\t<nature>" << *nit << "</nature>\n"; + } + + if (const char *extraNaturesProp = mf->GetCMakeInstance()-> + GetProperty("ECLIPSE_EXTRA_NATURES", cmProperty::GLOBAL)) + { + std::vector<std::string> extraNatures; + cmSystemTools::ExpandListArgument(extraNaturesProp, extraNatures); + for (std::vector<std::string>::const_iterator nit = extraNatures.begin(); + nit != extraNatures.end(); ++nit) + { + fout << "\t\t<nature>" << *nit << "</nature>\n"; + } + } + + fout << "\t</natures>\n"; fout << "\t<linkedResources>\n"; // create linked resources diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index b31cce7..9c89f85 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -41,6 +41,8 @@ public: virtual void GetDocumentation(cmDocumentationEntry& entry, const char* fullName) const; + virtual void EnableLanguage(std::vector<std::string> const& languages, + cmMakefile *, bool optional); virtual void Generate(); @@ -105,6 +107,7 @@ private: void CreateLinksForTargets(cmGeneratedFileStream& fout); std::vector<std::string> SrcLinkedResources; + std::set<std::string> Natures; std::string HomeDirectory; std::string HomeOutputDirectory; bool IsOutOfSourceBuild; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 8c42811..e8c8da3 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -165,6 +165,9 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) cmSystemTools::ConvertToUnixSlashes(*ri); } + const char* stagePrefix = + this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); + // Copy the original set of unrooted paths. std::vector<std::string> unrootedPaths = paths; paths.clear(); @@ -179,7 +182,9 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) // already inside. Skip the unrooted path if it is relative to // a user home directory or is empty. std::string rootedDir; - if(cmSystemTools::IsSubDirectory(ui->c_str(), ri->c_str())) + if(cmSystemTools::IsSubDirectory(ui->c_str(), ri->c_str()) + || (stagePrefix + && cmSystemTools::IsSubDirectory(ui->c_str(), stagePrefix))) { rootedDir = *ui; } diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 92dc054..7399c7b 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -173,8 +173,8 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt) return (strcmp(prop, "LINK_LIBRARIES") == 0 || strcmp(prop, "LINK_INTERFACE_LIBRARIES") == 0 || strcmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 - || strncmp(prop, "LINK_INTERFACE_LIBRARIES_", 25) == 0 - || strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_", 34) == 0) + || cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES_") + || cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_")) || strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0; } @@ -200,7 +200,7 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingCompileDefinitions() const const char *prop = this->Property.c_str(); return (strcmp(prop, "COMPILE_DEFINITIONS") == 0 || strcmp(prop, "INTERFACE_COMPILE_DEFINITIONS") == 0 - || strncmp(prop, "COMPILE_DEFINITIONS_", 20) == 0); + || cmHasLiteralPrefix(prop, "COMPILE_DEFINITIONS_")); } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 2ae5a22..67972b9 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -902,8 +902,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME) // Note that the above macro terminates with an else - /* else */ if (strncmp(propertyName.c_str(), - "COMPILE_DEFINITIONS_", 20) == 0) + /* else */ if (cmHasLiteralPrefix(propertyName.c_str(), + "COMPILE_DEFINITIONS_")) { interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS"; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b964f71..011fc6c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -611,8 +611,8 @@ const char* cmGeneratorTarget::GetCreateRuleVariable() const } //---------------------------------------------------------------------------- -std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories( - const char *config) +std::vector<std::string> +cmGeneratorTarget::GetIncludeDirectories(const char *config) const { return this->Target->GetIncludeDirectories(config); } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 177bc25..69d1bb2 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -70,7 +70,7 @@ public: const char* GetCreateRuleVariable() const; /** Get the include directories for this target. */ - std::vector<std::string> GetIncludeDirectories(const char *config); + std::vector<std::string> GetIncludeDirectories(const char *config) const; bool IsSystemIncludeDirectory(const char *dir, const char *config) const; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 65a7118..20cd15e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -695,6 +695,11 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, { mf->ReadListFile(0,projectCompatibility.c_str()); } + // Inform any extra generator of the new language. + if (this->ExtraGenerator) + { + this->ExtraGenerator->EnableLanguage(languages, mf, false); + } if(fatalError) { @@ -1981,7 +1986,7 @@ void cmGlobalGenerator::AddAlias(const char *name, cmTarget *tgt) } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::IsAlias(const char *name) +bool cmGlobalGenerator::IsAlias(const char *name) const { return this->AliasTargets.find(name) != this->AliasTargets.end(); } @@ -1989,15 +1994,16 @@ bool cmGlobalGenerator::IsAlias(const char *name) //---------------------------------------------------------------------------- cmTarget* cmGlobalGenerator::FindTarget(const char* project, const char* name, - bool excludeAliases) + bool excludeAliases) const { // if project specific if(project) { - std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project]; - for(unsigned int i = 0; i < gens->size(); ++i) + std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + gens = this->ProjectMap.find(project); + for(unsigned int i = 0; i < gens->second.size(); ++i) { - cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name, + cmTarget* ret = (gens->second)[i]->GetMakefile()->FindTarget(name, excludeAliases); if(ret) { @@ -2010,14 +2016,14 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name, { if (!excludeAliases) { - std::map<cmStdString, cmTarget*>::iterator ai + std::map<cmStdString, cmTarget*>::const_iterator ai = this->AliasTargets.find(name); if (ai != this->AliasTargets.end()) { return ai->second; } } - std::map<cmStdString,cmTarget *>::iterator i = + std::map<cmStdString,cmTarget *>::const_iterator i = this->TotalTargets.find ( name ); if ( i != this->TotalTargets.end() ) { @@ -2033,7 +2039,8 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name, } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) +bool +cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const { if(cmSystemTools::IsPathToFramework(libname.c_str())) { @@ -2407,7 +2414,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( // Store the custom command in the target. cmCustomCommand cc(0, no_outputs, no_depends, *commandLines, 0, workingDirectory); - target.GetPostBuildCommands().push_back(cc); + target.AddPostBuildCommand(cc); target.SetProperty("EchoString", message); std::vector<std::string>::iterator dit; for ( dit = depends.begin(); dit != depends.end(); ++ dit ) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ae139ed..eb720a8 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -207,14 +207,14 @@ public: ///! Find a target by name by searching the local generators. cmTarget* FindTarget(const char* project, const char* name, - bool excludeAliases = false); + bool excludeAliases = false) const; void AddAlias(const char *name, cmTarget *tgt); - bool IsAlias(const char *name); + bool IsAlias(const char *name) const; /** Determine if a name resolves to a framework on disk or a built target that is a framework. */ - bool NameResolvesToFramework(const std::string& libname); + bool NameResolvesToFramework(const std::string& libname) const; /** If check to see if the target is linked to by any other target in the project */ diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 273d4bb..ab7db51 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -75,7 +75,7 @@ void cmGlobalKdevelopGenerator::Generate() { if (ti->second.GetType()==cmTarget::EXECUTABLE) { - executable = ti->second.GetProperty("LOCATION"); + executable = ti->second.GetLocation(0); break; } } diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 29401c6..7d4abbd 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -28,7 +28,7 @@ static const char* cmVS10GenName(const char* name, std::string& genName) return 0; } const char* p = name + sizeof(vs10generatorName) - 6; - if(strncmp(p, " 2010", 5) == 0) + if(cmHasLiteralPrefix(p, " 2010")) { p += 5; } diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index f1d7312..1f0c47a 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -23,7 +23,7 @@ static const char* cmVS11GenName(const char* name, std::string& genName) return 0; } const char* p = name + sizeof(vs11generatorName) - 6; - if(strncmp(p, " 2012", 5) == 0) + if(cmHasLiteralPrefix(p, " 2012")) { p += 5; } diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index edd5567..3074794 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -23,7 +23,7 @@ static const char* cmVS12GenName(const char* name, std::string& genName) return 0; } const char* p = name + sizeof(vs12generatorName) - 6; - if(strncmp(p, " 2013", 5) == 0) + if(cmHasLiteralPrefix(p, " 2013")) { p += 5; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index d2784a9..cf5798f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -370,6 +370,11 @@ void cmLocalGenerator::GenerateInstallRules() prefix = "/usr/local"; } #endif + if (const char *stagingPrefix + = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX")) + { + prefix = stagingPrefix; + } // Compute the set of configurations. std::vector<std::string> configurationTypes; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 30c3d73..2fd1016 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -482,6 +482,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = {"AssemblerListingLocation", "Fa", "ASM List Location", "", cmVS7FlagTable::UserValue}, + {"ProgramDataBaseFileName", "Fd", "Program Database File Name", "", + cmVS7FlagTable::UserValue}, // boolean flags {"BufferSecurityCheck", "GS", "Buffer security check", "TRUE", 0}, diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ac8381c..989aa5f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -884,34 +884,61 @@ cmMakefile::AddCustomCommandToTarget(const char* target, { // Find the target to which to add the custom command. cmTargets::iterator ti = this->Targets.find(target); - if(ti != this->Targets.end()) + + if(ti == this->Targets.end()) { - if(ti->second.GetType() == cmTarget::OBJECT_LIBRARY) + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->GetPolicyStatus(cmPolicies::CMP0040)) { - cmOStringStream e; - e << "Target \"" << target << "\" is an OBJECT library " - "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands."; - this->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; + case cmPolicies::WARN: + issueMessage = true; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; } - // Add the command to the appropriate build step for the target. - std::vector<std::string> no_output; - cmCustomCommand cc(this, no_output, depends, - commandLines, comment, workingDir); - cc.SetEscapeOldStyle(escapeOldStyle); - cc.SetEscapeAllowMakeVars(true); - switch(type) + + if(issueMessage) { - case cmTarget::PRE_BUILD: - ti->second.GetPreBuildCommands().push_back(cc); - break; - case cmTarget::PRE_LINK: - ti->second.GetPreLinkCommands().push_back(cc); - break; - case cmTarget::POST_BUILD: - ti->second.GetPostBuildCommands().push_back(cc); - break; + cmOStringStream e; + e << (this->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0040)) << "\n"; + e << "The target name \"" << target << "\" is unknown in this context."; + IssueMessage(messageType, e.str().c_str()); } + + return; + } + + if(ti->second.GetType() == cmTarget::OBJECT_LIBRARY) + { + cmOStringStream e; + e << "Target \"" << target << "\" is an OBJECT library " + "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands."; + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + // Add the command to the appropriate build step for the target. + std::vector<std::string> no_output; + cmCustomCommand cc(this, no_output, depends, + commandLines, comment, workingDir); + cc.SetEscapeOldStyle(escapeOldStyle); + cc.SetEscapeAllowMakeVars(true); + switch(type) + { + case cmTarget::PRE_BUILD: + ti->second.AddPreBuildCommand(cc); + break; + case cmTarget::PRE_LINK: + ti->second.AddPreLinkCommand(cc); + break; + case cmTarget::POST_BUILD: + ti->second.AddPostBuildCommand(cc); + break; } } @@ -3822,21 +3849,19 @@ const char* cmMakefile::GetFeature(const char* feature, const char* config) return 0; } -cmTarget* cmMakefile::FindTarget(const char* name, bool excludeAliases) +cmTarget* cmMakefile::FindTarget(const char* name, bool excludeAliases) const { if (!excludeAliases) { - std::map<std::string, cmTarget*>::iterator i + std::map<std::string, cmTarget*>::const_iterator i = this->AliasTargets.find(name); if (i != this->AliasTargets.end()) { return i->second; } } - cmTargets& tgts = this->GetTargets(); - - cmTargets::iterator i = tgts.find ( name ); - if ( i != tgts.end() ) + cmTargets::iterator i = this->Targets.find( name ); + if ( i != this->Targets.end() ) { return &i->second; } @@ -4061,8 +4086,11 @@ bool cmMakefile::IsAlias(const char *name) //---------------------------------------------------------------------------- cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name) { - cmTarget *t = this->FindTargetToUse(name); - return this->LocalGenerator->GetGlobalGenerator()->GetGeneratorTarget(t); + if (cmTarget *t = this->FindTargetToUse(name)) + { + return this->LocalGenerator->GetGlobalGenerator()->GetGeneratorTarget(t); + } + return 0; } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 76958ca..44aaa66 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -533,7 +533,7 @@ public: this->GeneratorTargets = targets; } - cmTarget* FindTarget(const char* name, bool excludeAliases = false); + cmTarget* FindTarget(const char* name, bool excludeAliases = false) const; /** Find a target to use in place of the given name. The target returned may be imported or built within the project. */ @@ -902,7 +902,7 @@ protected: std::string ProjectName; // project name // libraries, classes, and executables - cmTargets Targets; + mutable cmTargets Targets; std::map<std::string, cmTarget*> AliasTargets; cmGeneratorTargetsType GeneratorTargets; std::vector<cmSourceFile*> SourceFiles; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 015654b..d8e9b34 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -534,7 +534,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/'); } - std::vector<cmCustomCommand> *cmdLists[3] = { + const std::vector<cmCustomCommand> *cmdLists[3] = { &this->GetTarget()->GetPreBuildCommands(), &this->GetTarget()->GetPreLinkCommands(), &this->GetTarget()->GetPostBuildCommands() diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 16b2bea..5de36ed 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -32,7 +32,7 @@ void cmLBDepend::DependWalk(cmDependInformation* info) std::string line; while(cmSystemTools::GetLineFromStream(fin, line)) { - if(!strncmp(line.c_str(), "#include", 8)) + if(cmHasLiteralPrefix(line.c_str(), "#include")) { // if it is an include line then create a string class std::string currentline = line; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index a18fc16..b9b469c 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -301,6 +301,11 @@ cmPolicies::cmPolicies() CMP0039, "CMP0039", "Utility targets may not have link dependencies.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0040, "CMP0040", + "The target in the TARGET signature of add_custom_command() must exist.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 361d820..6834121 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -92,6 +92,8 @@ public: /// should match a validity pattern. CMP0038, ///< Targets may not link directly to themselves CMP0039, ///< Utility targets may not have link dependencies + CMP0040, ///< The target in the TARGET signature of + /// add_custom_command() must exist. /** \brief Always the last entry. * diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 36cb368..35717ce 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -257,7 +257,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) workingDirectory.c_str()); cc.SetEscapeOldStyle(false); cc.SetEscapeAllowMakeVars(true); - target->GetPreBuildCommands().push_back(cc); + target->AddPreBuildCommand(cc); } else #endif diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index bb193bf..36363a1 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -23,7 +23,7 @@ bool cmSetCommand // watch for ENV signatures const char* variable = args[0].c_str(); // VAR is always first - if (!strncmp(variable,"ENV{",4) && strlen(variable) > 5) + if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) { // what is the variable name char *varName = new char [strlen(variable)]; diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 18d017d..1ccec68 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -377,13 +377,31 @@ static thisClass* SafeDownCast(cmObject *c) \ return 0;\ } +inline bool cmHasLiteralPrefixImpl(const std::string &str1, + const char *str2, + size_t N) +{ + return strncmp(str1.c_str(), str2, N) == 0; +} + +inline bool cmHasLiteralPrefixImpl(const char* str1, + const char *str2, + size_t N) +{ + return strncmp(str1, str2, N) == 0; +} + #if defined(_MSC_VER) && _MSC_VER < 1300 \ - || defined(__GNUC__) && __GNUC__ < 3 + || defined(__GNUC__) && __GNUC__ < 3 \ + || defined(__BORLANDC__) #define cmArrayBegin(a) a #define cmArraySize(a) (sizeof(a)/sizeof(*a)) #define cmArrayEnd(a) a + cmArraySize(a) +#define cmHasLiteralPrefix(STR1, STR2) \ + cmHasLiteralPrefixImpl(STR1, "" STR2 "", sizeof(STR2) - 1) + #else template<typename T, size_t N> @@ -393,6 +411,12 @@ const T* cmArrayEnd(const T (&a)[N]) { return a + N; } template<typename T, size_t N> size_t cmArraySize(const T (&)[N]) { return N; } +template<typename T, size_t N> +bool cmHasLiteralPrefix(T str1, const char (&str2)[N]) +{ + return cmHasLiteralPrefixImpl(str1, str2, N - 1); +} + #endif struct cmStrCmp { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c9905b6..120a666 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -91,8 +91,8 @@ public: } ~cmTargetInternals(); typedef cmTarget::SourceFileFlags SourceFileFlags; - std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; - bool SourceFileFlagsConstructed; + mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; + mutable bool SourceFileFlagsConstructed; // The backtrace when the target was created. cmListFileBacktrace Backtrace; @@ -438,7 +438,7 @@ bool cmTarget::IsExecutableWithExports() const } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkable() +bool cmTarget::IsLinkable() const { return (this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || @@ -560,7 +560,7 @@ cmSourceFile* cmTarget::AddSource(const char* s) //---------------------------------------------------------------------------- void cmTarget::ProcessSourceExpression(std::string const& expr) { - if(strncmp(expr.c_str(), "$<TARGET_OBJECTS:", 17) == 0 && + if(cmHasLiteralPrefix(expr.c_str(), "$<TARGET_OBJECTS:") && expr[expr.size()-1] == '>') { std::string objLibName = expr.substr(17, expr.size()-18); @@ -577,7 +577,7 @@ void cmTarget::ProcessSourceExpression(std::string const& expr) //---------------------------------------------------------------------------- struct cmTarget::SourceFileFlags -cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) +cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const { struct SourceFileFlags flags; this->ConstructSourceFileFlags(); @@ -591,7 +591,7 @@ cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) } //---------------------------------------------------------------------------- -void cmTarget::ConstructSourceFileFlags() +void cmTarget::ConstructSourceFileFlags() const { if(this->Internal->SourceFileFlagsConstructed) { @@ -769,9 +769,9 @@ void cmTarget::ClearDependencyInformation( cmMakefile& mf, } //---------------------------------------------------------------------------- -bool cmTarget::NameResolvesToFramework(const std::string& libname) +bool cmTarget::NameResolvesToFramework(const std::string& libname) const { - return this->GetMakefile()->GetLocalGenerator()->GetGlobalGenerator()-> + return this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> NameResolvesToFramework(libname); } @@ -811,7 +811,7 @@ void cmTarget::GetDirectLinkLibraries(const char *config, //---------------------------------------------------------------------------- void cmTarget::GetInterfaceLinkLibraries(const char *config, - std::vector<std::string> &libs, cmTarget *head) + std::vector<std::string> &libs, cmTarget *head) const { const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES"); if (prop) @@ -834,7 +834,7 @@ void cmTarget::GetInterfaceLinkLibraries(const char *config, //---------------------------------------------------------------------------- std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value, - cmTarget::LinkLibraryType llt) + cmTarget::LinkLibraryType llt) const { if (llt == GENERAL) { @@ -2199,11 +2199,11 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, void cmTarget::MaybeInvalidatePropertyCache(const char* prop) { // Wipe out maps caching information affected by this property. - if(this->IsImported() && strncmp(prop, "IMPORTED", 8) == 0) + if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED")) { this->Internal->ImportInfoMap.clear(); } - if(!this->IsImported() && strncmp(prop, "LINK_INTERFACE_", 15) == 0) + if(!this->IsImported() && cmHasLiteralPrefix(prop, "LINK_INTERFACE_")) { this->ClearLinkMaps(); } @@ -2276,24 +2276,24 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value, } //---------------------------------------------------------------------------- -void cmTarget::CheckProperty(const char* prop, cmMakefile* context) +void cmTarget::CheckProperty(const char* prop, cmMakefile* context) const { // Certain properties need checking. - if(strncmp(prop, "LINK_INTERFACE_LIBRARIES", 24) == 0) + if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) { if(const char* value = this->GetProperty(prop)) { cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, false); } } - if(strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES", 33) == 0) + if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES")) { if(const char* value = this->GetProperty(prop)) { cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true); } } - if(strncmp(prop, "INTERFACE_LINK_LIBRARIES", 24) == 0) + if(cmHasLiteralPrefix(prop, "INTERFACE_LINK_LIBRARIES")) { if(const char* value = this->GetProperty(prop)) { @@ -2382,7 +2382,7 @@ std::string cmTarget::GetDirectory(const char* config, bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBDirectory(const char* config) +std::string cmTarget::GetPDBDirectory(const char* config) const { if(OutputInfo const* info = this->GetOutputInfo(config)) { @@ -2453,7 +2453,7 @@ const char* cmTarget::NormalGetLocation(const char* config) const } //---------------------------------------------------------------------------- -void cmTarget::GetTargetVersion(int& major, int& minor) +void cmTarget::GetTargetVersion(int& major, int& minor) const { int patch; this->GetTargetVersion(false, major, minor, patch); @@ -2461,7 +2461,7 @@ void cmTarget::GetTargetVersion(int& major, int& minor) //---------------------------------------------------------------------------- void cmTarget::GetTargetVersion(bool soversion, - int& major, int& minor, int& patch) + int& major, int& minor, int& patch) const { // Set the default values. major = 0; @@ -2489,7 +2489,7 @@ void cmTarget::GetTargetVersion(bool soversion, } //---------------------------------------------------------------------------- -const char* cmTarget::GetFeature(const char* feature, const char* config) +const char* cmTarget::GetFeature(const char* feature, const char* config) const { if(config && *config) { @@ -2595,7 +2595,7 @@ const char *cmTarget::GetProperty(const char* prop, } // Support "LOCATION_<CONFIG>". - if(strncmp(prop, "LOCATION_", 9) == 0) + if(cmHasLiteralPrefix(prop, "LOCATION_")) { if (!this->HandleLocationPropertyPolicy()) { @@ -3145,7 +3145,7 @@ bool cmTarget::HasMacOSXRpath(const char* config) const } //---------------------------------------------------------------------------- -bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) +bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const { if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY) { @@ -3597,14 +3597,14 @@ void cmTarget::GetExecutableNames(std::string& name, } //---------------------------------------------------------------------------- -bool cmTarget::HasImplibGNUtoMS() +bool cmTarget::HasImplibGNUtoMS() const { return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); } //---------------------------------------------------------------------------- bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, - std::string& out, const char* newExt) + std::string& out, const char* newExt) const { if(this->HasImplibGNUtoMS() && gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a") @@ -3976,7 +3976,7 @@ bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const } //---------------------------------------------------------------------------- -bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) +bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) const { std::string dir; return this->ComputeOutputDir(config, implib, dir); @@ -4037,7 +4037,7 @@ std::string cmTarget::GetFrameworkVersion() const } //---------------------------------------------------------------------------- -const char* cmTarget::GetExportMacro() +const char* cmTarget::GetExportMacro() const { // Define the symbol for targets that export symbols. if(this->GetType() == cmTarget::SHARED_LIBRARY || diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b516a0a..35ec680 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -114,12 +114,18 @@ public: /** * Get the list of the custom commands for this target */ - std::vector<cmCustomCommand> &GetPreBuildCommands() + std::vector<cmCustomCommand> const &GetPreBuildCommands() const {return this->PreBuildCommands;} - std::vector<cmCustomCommand> &GetPreLinkCommands() + std::vector<cmCustomCommand> const &GetPreLinkCommands() const {return this->PreLinkCommands;} - std::vector<cmCustomCommand> &GetPostBuildCommands() + std::vector<cmCustomCommand> const &GetPostBuildCommands() const {return this->PostBuildCommands;} + void AddPreBuildCommand(cmCustomCommand const &cmd) + {this->PreBuildCommands.push_back(cmd);} + void AddPreLinkCommand(cmCustomCommand const &cmd) + {this->PreLinkCommands.push_back(cmd);} + void AddPostBuildCommand(cmCustomCommand const &cmd) + {this->PostBuildCommands.push_back(cmd);} /** * Get the list of the source files used by this target @@ -156,7 +162,8 @@ public: /** * Get the flags for a given source file as used in this target */ - struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf); + struct SourceFileFlags + GetTargetSourceFileFlags(const cmSourceFile* sf) const; /** * Add sources to the target. @@ -179,7 +186,7 @@ public: cmTarget const* head) const; void GetInterfaceLinkLibraries(const char *config, std::vector<std::string> &, - cmTarget *head); + cmTarget *head) const; /** Compute the link type to use for the given configuration. */ LinkLibraryType ComputeLinkType(const char* config) const; @@ -190,7 +197,7 @@ public: void ClearDependencyInformation(cmMakefile& mf, const char* target); // Check to see if a library is a framework and treat it different on Mac - bool NameResolvesToFramework(const std::string& libname); + bool NameResolvesToFramework(const std::string& libname) const; void AddLinkLibrary(cmMakefile& mf, const char *target, const char* lib, LinkLibraryType llt); @@ -212,14 +219,14 @@ public: * Set the path where this target should be installed. This is relative to * INSTALL_PREFIX */ - std::string GetInstallPath() {return this->InstallPath;} + std::string GetInstallPath() const {return this->InstallPath;} void SetInstallPath(const char *name) {this->InstallPath = name;} /** * Set the path where this target (if it has a runtime part) should be * installed. This is relative to INSTALL_PREFIX */ - std::string GetRuntimeInstallPath() {return this->RuntimeInstallPath;} + std::string GetRuntimeInstallPath() const {return this->RuntimeInstallPath;} void SetRuntimeInstallPath(const char *name) { this->RuntimeInstallPath = name; } @@ -246,9 +253,9 @@ public: const char *GetProperty(const char *prop) const; const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const; bool GetPropertyAsBool(const char *prop) const; - void CheckProperty(const char* prop, cmMakefile* context); + void CheckProperty(const char* prop, cmMakefile* context) const; - const char* GetFeature(const char* feature, const char* config); + const char* GetFeature(const char* feature, const char* config) const; bool IsImported() const {return this->IsImportedTarget;} @@ -330,7 +337,7 @@ public: If the configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical pdb output directory is given. */ - std::string GetPDBDirectory(const char* config = 0); + std::string GetPDBDirectory(const char* config = 0) const; /** Get the location of the target in the build tree for the given configuration. This location is suitable for use as the LOCATION @@ -340,12 +347,13 @@ public: /** Get the target major and minor version numbers interpreted from the VERSION property. Version 0 is returned if the property is not set or cannot be parsed. */ - void GetTargetVersion(int& major, int& minor); + void GetTargetVersion(int& major, int& minor) const; /** Get the target major, minor, and patch version numbers interpreted from the VERSION or SOVERSION property. Version 0 is returned if the property is not set or cannot be parsed. */ - void GetTargetVersion(bool soversion, int& major, int& minor, int& patch); + void + GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; /** * Make sure the full path to all source files is known. @@ -377,7 +385,7 @@ public: /** Test for special case of a third-party shared library that has no soname at all. */ - bool IsImportedSharedLibWithoutSOName(const char* config); + bool IsImportedSharedLibWithoutSOName(const char* config) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ @@ -399,12 +407,12 @@ public: std::string& pdbName, const char* config) const; /** Does this target have a GNU implib to convert to MS format? */ - bool HasImplibGNUtoMS(); + bool HasImplibGNUtoMS() const; /** Convert the given GNU import library name (.dll.a) to a name with a new extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, - const char* newExt = 0); + const char* newExt = 0) const; /** * Compute whether this target must be relinked before installing. @@ -442,7 +450,7 @@ public: /** Get the macro to define when building sources in this target. If no macro should be defined null is returned. */ - const char* GetExportMacro(); + const char* GetExportMacro() const; void GetCompileDefinitions(std::vector<std::string> &result, const char *config) const; @@ -459,10 +467,10 @@ public: bool IsExecutableWithExports() const; /** Return whether this target may be used to link another target. */ - bool IsLinkable(); + bool IsLinkable() const; /** Return whether or not the target is for a DLL platform. */ - bool IsDLLPlatform() { return this->DLLPlatform; } + bool IsDLLPlatform() const { return this->DLLPlatform; } /** Return whether or not the target has a DLL import library. */ bool HasImportLibrary() const; @@ -493,7 +501,7 @@ public: /** Return whether this target uses the default value for its output directory. */ - bool UsesDefaultOutputDir(const char* config, bool implib); + bool UsesDefaultOutputDir(const char* config, bool implib) const; /** @return the mac content directory for this target. */ std::string GetMacContentDirectory(const char* config, @@ -546,7 +554,7 @@ public: const char *config) const; std::string GetDebugGeneratorExpressions(const std::string &value, - cmTarget::LinkLibraryType llt); + cmTarget::LinkLibraryType llt) const; void AddSystemIncludeDirectories(const std::set<cmStdString> &incs); void AddSystemIncludeDirectories(const std::vector<std::string> &incs); @@ -671,7 +679,7 @@ private: bool HaveInstallRule; std::string InstallPath; std::string RuntimeInstallPath; - std::string ExportMacro; + mutable std::string ExportMacro; std::set<cmStdString> Utilities; bool RecordDependencies; mutable cmPropertyMap Properties; @@ -736,7 +744,7 @@ private: friend class cmTargetTraceDependencies; cmTargetInternalPointer Internal; - void ConstructSourceFileFlags(); + void ConstructSourceFileFlags() const; void ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index 46c9666..b567252 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -44,7 +44,7 @@ std::string cmTargetCompileDefinitionsCommand for(std::vector<std::string>::const_iterator it = content.begin(); it != content.end(); ++it) { - if (strncmp(it->c_str(), "-D", 2) == 0) + if (cmHasLiteralPrefix(it->c_str(), "-D")) { defs += sep + it->substr(2); } diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx index 84f3029..053cdfc 100644 --- a/Source/cmUnsetCommand.cxx +++ b/Source/cmUnsetCommand.cxx @@ -24,7 +24,7 @@ bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args, const char* variable = args[0].c_str(); // unset(ENV{VAR}) - if (!strncmp(variable,"ENV{",4) && strlen(variable) > 5) + if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) { // what is the variable name char *envVarName = new char [strlen(variable)]; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ace1eef..635d8cb 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1794,7 +1794,7 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName) void cmVisualStudio10TargetGenerator::WriteEvent( const char* name, - std::vector<cmCustomCommand> & commands, + std::vector<cmCustomCommand> const& commands, std::string const& configName) { if(commands.size() == 0) @@ -1807,10 +1807,10 @@ void cmVisualStudio10TargetGenerator::WriteEvent( std::string script; const char* pre = ""; std::string comment; - for(std::vector<cmCustomCommand>::iterator i = commands.begin(); + for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand& command = *i; + const cmCustomCommand& command = *i; comment += pre; comment += lg->ConstructComment(command); script += pre; diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 9a480a8..d1f3d19 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -87,7 +87,8 @@ private: void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring); void WriteLibOptions(std::string const& config); void WriteEvents(std::string const& configName); - void WriteEvent(const char* name, std::vector<cmCustomCommand> & commands, + void WriteEvent(const char* name, + std::vector<cmCustomCommand> const& commands, std::string const& configName); void WriteGroupSources(const char* name, ToolSources const& sources, std::vector<cmSourceGroup>& ); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 6ef0579..882b072 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -273,7 +273,7 @@ int do_cmake(int ac, char** av) list_all_cached = true; list_help = true; } - else if (strncmp(av[i], "-P", strlen("-P")) == 0) + else if (cmHasLiteralPrefix(av[i], "-P")) { if ( i == ac -1 ) { @@ -287,8 +287,7 @@ int do_cmake(int ac, char** av) args.push_back(av[i]); } } - else if (strncmp(av[i], "--find-package", - strlen("--find-package")) == 0) + else if (cmHasLiteralPrefix(av[i], "--find-package")) { workingMode = cmake::FIND_PACKAGE_MODE; args.push_back(av[i]); |