diff options
Diffstat (limited to 'Source')
29 files changed, 409 insertions, 103 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index b824e47..9b12393 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -33,6 +33,7 @@ #include <float.h> #include <memory> // auto_ptr +#include <set> //---------------------------------------------------------------------- class cmCTestSubdirCommand : public cmCommand @@ -617,9 +618,13 @@ int cmCTestTestHandler::ProcessHandler() << "The following tests FAILED:" << std::endl); this->StartLogFile("TestsFailed", ofs); - std::vector<cmCTestTestHandler::cmCTestTestResult>::iterator ftit; - for(ftit = this->TestResults.begin(); - ftit != this->TestResults.end(); ++ftit) + typedef std::set<cmCTestTestHandler::cmCTestTestResult, + cmCTestTestResultLess> SetOfTests; + SetOfTests resultsSet(this->TestResults.begin(), + this->TestResults.end()); + + for(SetOfTests::iterator ftit = resultsSet.begin(); + ftit != resultsSet.end(); ++ftit) { if ( ftit->Status != cmCTestTestHandler::COMPLETED ) { diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 3089d35..8e59e59 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -125,7 +125,16 @@ public: cmCTestTestProperties* Properties; }; - // add configuraitons to a search path for an executable + struct cmCTestTestResultLess + { + bool operator() (const cmCTestTestResult &lhs, + const cmCTestTestResult &rhs) const + { + return lhs.TestCount < rhs.TestCount; + } + }; + + // add configurations to a search path for an executable static void AddConfigurations(cmCTest *ctest, std::vector<std::string> &attempted, std::vector<std::string> &attemptedConfigs, @@ -141,7 +150,7 @@ public: typedef std::vector<cmCTestTestProperties> ListOfTests; protected: - // comput a final test list + // compute a final test list virtual int PreProcessHandler(); virtual int PostProcessHandler(); virtual void GenerateTestCommand(std::vector<std::string>& args); diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h index 703ff88..1d247d2 100644 --- a/Source/cmBuildCommand.h +++ b/Source/cmBuildCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmBuildCommand - * \brief Build a CMAKE variable + * \brief build_command command * - * cmBuildCommand sets a variable to a value with expansion. + * cmBuildCommand implements the build_command CMake command */ class cmBuildCommand : public cmCommand { diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h index 35c0ae0..29a680f 100644 --- a/Source/cmBuildNameCommand.h +++ b/Source/cmBuildNameCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmBuildNameCommand - * \brief BuildName a CMAKE variable + * \brief build_name command * - * cmBuildNameCommand sets a variable to a value with expansion. + * cmBuildNameCommand implements the build_name CMake command */ class cmBuildNameCommand : public cmCommand { diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h index 9bf7ef8..1121386 100644 --- a/Source/cmCMakeMinimumRequired.h +++ b/Source/cmCMakeMinimumRequired.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmCMakeMinimumRequired - * \brief Build a CMAKE variable + * \brief cmake_minimum_required command * - * cmCMakeMinimumRequired sets a variable to a value with expansion. + * cmCMakeMinimumRequired implements the cmake_minimum_required CMake command */ class cmCMakeMinimumRequired : public cmCommand { diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index a4ca363..3a0ed06 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -276,9 +276,11 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, for(std::set<cmStdString>::const_iterator i = utils.begin(); i != utils.end(); ++i) { - cmTarget* transitive_dependee = - dependee->GetMakefile()->FindTargetToUse(i->c_str()); - this->AddTargetDepend(depender_index, transitive_dependee, false); + if(cmTarget* transitive_dependee = + dependee->GetMakefile()->FindTargetToUse(i->c_str())) + { + this->AddTargetDepend(depender_index, transitive_dependee, false); + } } } else diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 5aed5e2..2e72b58 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -191,6 +191,9 @@ void cmFindPackageCommand::GenerateDocumentation() "\"<config-file>-version.cmake\" or \"<config-file>Version.cmake\". " "If no such version file is available then the configuration file " "is assumed to not be compatible with any requested version. " + "A basic version file containing generic version matching code can be " + "created using the macro write_basic_config_version_file(), see its " + "documentation for more details. " "When a version file is found it is loaded to check the requested " "version number. " "The version file is loaded in a nested scope in which the following " diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 27acf98..d62fb44 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -783,7 +783,7 @@ void cmGlobalGenerator::Configure() // so create the map from project name to vector of local generators this->FillProjectMap(); - if ( !this->CMakeInstance->GetScriptMode() ) + if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) { const char* msg = "Configuring done"; if(cmSystemTools::GetErrorOccuredFlag()) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b3e2e7a..f67b029 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -336,6 +336,9 @@ cmGlobalXCodeGenerator::PostBuildMakeTarget(std::string const& tName, } //---------------------------------------------------------------------------- +#define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK" + +//---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& gens) @@ -366,8 +369,18 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, makecommand.push_back(this->CurrentXCodeHackMakefile.c_str()); makecommand.push_back(""); // placeholder, see below - // Add Re-Run CMake rules - this->CreateReRunCMakeFile(root, gens); + // Add ZERO_CHECK + bool regenerate = !mf->IsOn("CMAKE_SUPPRESS_REGENERATION"); + if (regenerate) + { + this->CreateReRunCMakeFile(root, gens); + std::string file = this->ConvertToRelativeForMake( + this->CurrentReRunCMakeMakefile.c_str()); + cmSystemTools::ReplaceString(file, "\\ ", " "); + mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, no_depends, + no_working_directory, + "make", "-f", file.c_str()); + } // now make the allbuild depend on all the non-utility targets // in the project @@ -379,10 +392,17 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, { continue; } + cmTargets& tgts = lg->GetMakefile()->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& target = l->second; + + if (regenerate && (l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)) + { + target.AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); + } + // make all exe, shared libs and modules // run the depend check makefile as a post build rule // this will make sure that when the next target is built @@ -402,8 +422,8 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str()); - } + if(!target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) { allbuild->AddUtility(target.GetName()); @@ -469,6 +489,7 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects() delete this->XCodeObjects[i]; } this->XCodeObjects.clear(); + this->XCodeObjectIDs.clear(); this->GroupMap.clear(); this->GroupNameMap.clear(); this->TargetGroup.clear(); @@ -476,6 +497,27 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects() } //---------------------------------------------------------------------------- +void cmGlobalXCodeGenerator::addObject(cmXCodeObject *obj) +{ + if(obj->GetType() == cmXCodeObject::OBJECT) + { + cmStdString id = obj->GetId(); + + // If this is a duplicate id, it's an error: + // + if(this->XCodeObjectIDs.count(id)) + { + cmSystemTools::Error( + "Xcode generator: duplicate object ids not allowed"); + } + + this->XCodeObjectIDs.insert(id); + } + + this->XCodeObjects.push_back(obj); +} + +//---------------------------------------------------------------------------- cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) { @@ -488,7 +530,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) { obj = new cmXCode21Object(ptype, cmXCodeObject::OBJECT); } - this->XCodeObjects.push_back(obj); + this->addObject(obj); return obj; } @@ -497,7 +539,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type) { cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, type); - this->XCodeObjects.push_back(obj); + this->addObject(obj); return obj; } @@ -1114,11 +1156,6 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, commands.push_back(*(*i)->GetCustomCommand()); } } - std::vector<cmCustomCommand> reruncom; - cmXCodeObject* cmakeReRunPhase = - this->CreateBuildPhase("CMake ReRun", "cmakeReRunPhase", - cmtarget, reruncom); - buildPhases->AddObject(cmakeReRunPhase); // create prebuild phase cmXCodeObject* cmakeRulesBuildPhase = this->CreateBuildPhase("CMake Rules", @@ -1207,20 +1244,6 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, const & commands, const char* name) { - if(strcmp(name, "cmakeReRunPhase") == 0) - { - std::string cdir = this->CurrentMakefile->GetHomeOutputDirectory(); - cdir = this->ConvertToRelativeForMake(cdir.c_str()); - std::string makecmd = "make -C "; - makecmd += cdir; - makecmd += " -f "; - makecmd += - this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile.c_str()); - cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); - buildphase->AddAttribute("shellScript", - this->CreateString(makecmd.c_str())); - return; - } // collect multiple outputs of custom commands into a set // which will be used for every configuration @@ -1757,7 +1780,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, default: break; } - if(this->XcodeVersion >= 22) + if(this->XcodeVersion >= 22 && this->XcodeVersion < 40) { buildSettings->AddAttribute("PREBINDING", this->CreateString("NO")); @@ -2039,6 +2062,9 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) } } + target->SetId(this->GetOrCreateId( + cmtarget.GetName(), target->GetId()).c_str()); + return target; } @@ -2187,6 +2213,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, target->AddAttribute("productType", this->CreateString(productType)); } target->SetTarget(&cmtarget); + target->SetId(this->GetOrCreateId( + cmtarget.GetName(), target->GetId()).c_str()); return target; } @@ -2210,6 +2238,26 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t) } //---------------------------------------------------------------------------- +std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name, + const char* id) +{ + std::string guidStoreName = name; + guidStoreName += "_GUID_CMAKE"; + const char* storedGUID = + this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str()); + + if(storedGUID) + { + return storedGUID; + } + + this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), + id, "Stored Xcode object GUID", cmCacheManager::INTERNAL); + + return id; +} + +//---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target, cmXCodeObject* dependTarget) { @@ -2738,6 +2786,12 @@ void cmGlobalXCodeGenerator this->RootObject = this->CreateObject(cmXCodeObject::PBXProject); this->RootObject->SetComment("Project object"); + + std::string project_id = "PROJECT_"; + project_id += root->GetMakefile()->GetProjectName(); + this->RootObject->SetId(this->GetOrCreateId( + project_id.c_str(), this->RootObject->GetId()).c_str()); + group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); this->RootObject->AddAttribute("mainGroup", this->CreateObjectReference(mainGroup)); @@ -3136,6 +3190,11 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, } this->WriteXCodePBXProj(fout, root, generators); this->ClearXCodeObjects(); + + // Since this call may have created new cache entries, save the cache: + // + root->GetMakefile()->GetCacheManager()->SaveCache( + root->GetMakefile()->GetHomeOutputDirectory()); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 39a5fd7..fa55ff0 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -123,6 +123,8 @@ private: ); cmXCodeObject* FindXCodeTarget(cmTarget*); + std::string GetOrCreateId(const char* name, const char* id); + // create cmXCodeObject from these functions so that memory can be managed // correctly. All objects created are stored in this->XCodeObjects. cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype); @@ -197,9 +199,11 @@ protected: unsigned int XcodeVersion; std::string VersionString; + std::set<cmStdString> XCodeObjectIDs; std::vector<cmXCodeObject*> XCodeObjects; cmXCodeObject* RootObject; private: + void addObject(cmXCodeObject *obj); std::string PostBuildMakeTarget(std::string const& tName, std::string const& configName); cmXCodeObject* MainGroupChildren; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index aebf9f3..a204a73 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -307,7 +307,6 @@ public: std::string const& dir_max, bool* hasSourceExtension = 0); -protected: /** Fill out these strings for the given target. Libraries to link, * flags, and linkflags. */ void GetTargetFlags(std::string& linkLibs, @@ -315,6 +314,7 @@ protected: std::string& linkFlags, cmTarget&target); +protected: ///! put all the libraries for a target on into the given stream virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 6ab5c2a..2eae9d0 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1276,6 +1276,7 @@ cmLocalUnixMakefileGenerator3 // and there are no "." charactors in the string, then return the // unmodified combination. if((!this->MakefileVariableSize && unmodified.find('.') == s.npos) + && (!this->MakefileVariableSize && unmodified.find('+') == s.npos) && (!this->MakefileVariableSize && unmodified.find('-') == s.npos)) { return unmodified; @@ -1297,6 +1298,7 @@ cmLocalUnixMakefileGenerator3 { cmSystemTools::ReplaceString(ret, ".", "_"); cmSystemTools::ReplaceString(ret, "-", "__"); + cmSystemTools::ReplaceString(ret, "+", "___"); int ni = 0; char buffer[5]; // make sure the _ version is not already used, if diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 1850c16..ef378f9 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -93,10 +93,18 @@ void cmLocalVisualStudio10Generator::Generate() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { - cmVisualStudio10TargetGenerator tg( - &l->second, static_cast<cmGlobalVisualStudio10Generator*>( - this->GetGlobalGenerator())); - tg.Generate(); + if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) + ->TargetIsFortranOnly(l->second)) + { + this->CreateSingleVCProj(l->first.c_str(),l->second); + } + else + { + cmVisualStudio10TargetGenerator tg( + &l->second, static_cast<cmGlobalVisualStudio10Generator*>( + this->GetGlobalGenerator())); + tg.Generate(); + } } this->WriteStampFiles(); } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 372e644..1f99cba 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -846,6 +846,13 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, tool = "VFMIDLTool"; } fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"; + fout << "\t\t\t\tAdditionalIncludeDirectories=\""; + for(i = includes.begin(); i != includes.end(); ++i) + { + std::string ipath = this->ConvertToXMLOutputPath(i->c_str()); + fout << ipath << ";"; + } + fout << "\"\n"; fout << "\t\t\t\tMkTypLibCompatible=\"FALSE\"\n"; if( this->PlatformName == "x64" ) { @@ -1643,6 +1650,10 @@ WriteCustomRule(std::ostream& fout, } std::string script = this->ConstructScript(command, i->c_str()); + if(this->FortranProject) + { + cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str()); + } fout << "\t\t\t\t\t<Tool\n" << "\t\t\t\t\tName=\"" << customTool << "\"\n" << "\t\t\t\t\tDescription=\"" diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index d1b5b00..cdd714e 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -74,6 +74,8 @@ public: virtual void ReadAndStoreExternalGUID(const char* name, const char* path); +protected: + void CreateSingleVCProj(const char *lname, cmTarget &tgt); private: typedef cmVisualStudioGeneratorOptions Options; typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo; @@ -84,7 +86,6 @@ private: void WriteVCProjHeader(std::ostream& fout, const char *libName, cmTarget &tgt, std::vector<cmSourceGroup> &sgs); void WriteVCProjFooter(std::ostream& fout, cmTarget &target); - void CreateSingleVCProj(const char *lname, cmTarget &tgt); void WriteVCProjFile(std::ostream& fout, const char *libName, cmTarget &tgt); void WriteConfigurations(std::ostream& fout, diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 45165e5..e5b5443 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -384,7 +384,9 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, // Decide whether to invoke the command. if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() && - (!this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable())) + (this->GetCMakeInstance()->GetWorkingMode() != cmake::SCRIPT_MODE + || pcmd->IsScriptable())) + { // if trace is one, print out invoke information if(this->GetCMakeInstance()->GetTrace()) @@ -411,7 +413,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError()); } result = false; - if ( this->GetCMakeInstance()->GetScriptMode() ) + if ( this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE) { cmSystemTools::SetFatalErrorOccured(); } @@ -422,7 +424,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, this->UsedCommands.push_back(pcmd.release()); } } - else if ( this->GetCMakeInstance()->GetScriptMode() + else if ( this->GetCMakeInstance()->GetWorkingMode() == cmake::SCRIPT_MODE && !pcmd->IsScriptable() ) { std::string error = "Command "; @@ -3025,8 +3027,15 @@ cmCacheManager *cmMakefile::GetCacheManager() const void cmMakefile::DisplayStatus(const char* message, float s) { - this->GetLocalGenerator()->GetGlobalGenerator() - ->GetCMakeInstance()->UpdateProgress(message, s); + cmake* cm = this->GetLocalGenerator()->GetGlobalGenerator() + ->GetCMakeInstance(); + if (cm->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) + { + // don't output any STATUS message in FIND_PACKAGE_MODE, since they will + // directly be fed to the compiler, which will be confused. + return; + } + cm->UpdateProgress(message, s); } std::string cmMakefile::GetModulesFile(const char* filename) diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h index 0a5eb9e..26e0a07 100644 --- a/Source/cmMarkAsAdvancedCommand.h +++ b/Source/cmMarkAsAdvancedCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmMarkAsAdvancedCommand - * \brief MarkAsAdvanced a CMAKE variable + * \brief mark_as_advanced command * - * cmMarkAsAdvancedCommand sets a variable to a value with expansion. + * cmMarkAsAdvancedCommand implements the mark_as_advanced CMake command */ class cmMarkAsAdvancedCommand : public cmCommand { diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h index 87c416f..bae2ee1 100644 --- a/Source/cmRemoveCommand.h +++ b/Source/cmRemoveCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmRemoveCommand - * \brief Set a CMAKE variable + * \brief remove command * - * cmRemoveCommand sets a variable to a value with expansion. + * cmRemoveCommand implements the remove CMake command */ class cmRemoveCommand : public cmCommand { diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h index 10b3c40..736f066 100644 --- a/Source/cmSeparateArgumentsCommand.h +++ b/Source/cmSeparateArgumentsCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmSeparateArgumentsCommand - * \brief SeparateArguments a CMAKE variable + * \brief separate_arguments command * - * cmSeparateArgumentsCommand sets a variable to a value with expansion. + * cmSeparateArgumentsCommand implements the separate_arguments CMake command */ class cmSeparateArgumentsCommand : public cmCommand { diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h index 6357569..ac7f426 100644 --- a/Source/cmSiteNameCommand.h +++ b/Source/cmSiteNameCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmSiteNameCommand - * \brief SiteName a CMAKE variable + * \brief site_name command * - * cmSiteNameCommand sets a variable to a value with expansion. + * cmSiteNameCommand implements the site_name CMake command */ class cmSiteNameCommand : public cmCommand { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ac4296c..551b0ad 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -437,7 +437,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, (*this->BuildFileStream ) << sep << out; sep = ";"; } - (*this->BuildFileStream ) << ";%(Outputs)</Outputs>\n"; + (*this->BuildFileStream ) << "</Outputs>\n"; } this->WriteString("</CustomBuild>\n", 2); } @@ -1578,6 +1578,13 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() i != depends.end(); ++i) { cmTarget* dt = *i; + // skip fortran targets as they can not be processed by MSBuild + // the only reference will be in the .sln file + if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) + ->TargetIsFortranOnly(*dt)) + { + continue; + } this->WriteString("<ProjectReference Include=\"", 2); cmMakefile* mf = dt->GetMakefile(); std::string name = dt->GetName(); diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 71c7c25..30ade96 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -12,6 +12,8 @@ #include "cmXCodeObject.h" #include "cmSystemTools.h" +#include <CoreFoundation/CoreFoundation.h> // CFUUIDCreate + //---------------------------------------------------------------------------- const char* cmXCodeObject::PBXTypeNames[] = { "PBXGroup", "PBXBuildStyle", "PBXProject", "PBXHeadersBuildPhase", @@ -39,35 +41,35 @@ cmXCodeObject::cmXCodeObject(PBXType ptype, Type type) this->PBXTargetDependencyValue = 0; this->Target = 0; this->Object =0; - + this->IsA = ptype; + if(type == OBJECT) { - cmOStringStream str; - str << (void*)this; - str << (void*)this; - str << (void*)this; - this->Id = str.str(); + // Set the Id of an Xcode object to a unique string for each instance. + // However the Xcode user file references certain Ids: for those cases, + // override the generated Id using SetId(). + // + char cUuid[40] = {0}; + CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault); + CFStringRef s = CFUUIDCreateString(kCFAllocatorDefault, uuid); + CFStringGetCString(s, cUuid, sizeof(cUuid), kCFStringEncodingUTF8); + this->Id = cUuid; + CFRelease(s); + CFRelease(uuid); } else { - this->Id = - "Temporary cmake object, should not be refered to in xcode file"; - } - cmSystemTools::ReplaceString(this->Id, "0x", ""); - this->Id = cmSystemTools::UpperCase(this->Id); - if(this->Id.size() < 24) - { - int diff = 24 - this->Id.size(); - for(int i =0; i < diff; ++i) - { - this->Id += "0"; - } + this->Id = + "Temporary cmake object, should not be referred to in Xcode file"; } + + cmSystemTools::ReplaceString(this->Id, "-", ""); if(this->Id.size() > 24) { - this->Id = this->Id.substr(0,24); + this->Id = this->Id.substr(0, 24); } + this->TypeValue = type; if(this->TypeValue == OBJECT) { @@ -241,7 +243,7 @@ void cmXCodeObject::PrintString(std::ostream& os,cmStdString String) // considered special by the Xcode project file parser. bool needQuote = (String.empty() || - String.find_first_of(" <>.+-=@$[]") != String.npos); + String.find_first_of(" <>.+-=@$[],") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 369fe66..2fb96f3 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -83,6 +83,10 @@ public: { return this->Id.c_str(); } + void SetId(const char* id) + { + this->Id = id; + } cmTarget* GetTarget() { return this->Target; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 99b1844..2b8c718 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -183,7 +183,7 @@ cmake::cmake() this->GlobalGenerator = 0; this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; - this->ScriptMode = false; + this->CurrentWorkingMode = NORMAL_MODE; #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch = new cmVariableWatch; @@ -356,6 +356,7 @@ void cmake::RemoveUnscriptableCommands() // Parse the args bool cmake::SetCacheArgs(const std::vector<std::string>& args) { + bool findPackageMode = false; for(unsigned int i=1; i < args.size(); ++i) { std::string arg = args[i]; @@ -483,7 +484,17 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } this->ReadListFile(args, path.c_str()); } + else if (arg.find("--find-package",0) == 0) + { + findPackageMode = true; + } } + + if (findPackageMode) + { + return this->FindPackage(args); + } + return true; } @@ -514,7 +525,7 @@ void cmake::ReadListFile(const std::vector<std::string>& args, (cmSystemTools::GetCurrentWorkingDirectory().c_str()); lg->GetMakefile()->SetStartDirectory (cmSystemTools::GetCurrentWorkingDirectory().c_str()); - if (this->GetScriptMode()) + if (this->GetWorkingMode() != NORMAL_MODE) { std::string file(cmSystemTools::CollapseFullPath(path)); cmSystemTools::ConvertToUnixSlashes(file); @@ -535,6 +546,111 @@ void cmake::ReadListFile(const std::vector<std::string>& args, } } + +bool cmake::FindPackage(const std::vector<std::string>& args) +{ + // if a generator was not yet created, temporarily create one + cmGlobalGenerator *gg = new cmGlobalGenerator; + gg->SetCMakeInstance(this); + this->SetGlobalGenerator(gg); + + // read in the list file to fill the cache + std::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator()); + cmMakefile* mf = lg->GetMakefile(); + mf->SetHomeOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetStartOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetHomeDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetStartDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + + mf->SetArgcArgv(args); + + std::string systemFile = mf->GetModulesFile("CMakeFindPackageMode.cmake"); + mf->ReadListFile(0, systemFile.c_str()); + + std::string language = mf->GetSafeDefinition("LANGUAGE"); + std::string mode = mf->GetSafeDefinition("MODE"); + std::string packageName = mf->GetSafeDefinition("NAME"); + bool packageFound = mf->IsOn("PACKAGE_FOUND"); + bool quiet = mf->IsOn("PACKAGE_QUIET"); + + if (!packageFound) + { + if (!quiet) + { + printf("%s not found.\n", packageName.c_str()); + } + } + else if (mode == "EXIST") + { + if (!quiet) + { + printf("%s found.\n", packageName.c_str()); + } + } + else if (mode == "COMPILE") + { + std::string includes = mf->GetSafeDefinition("PACKAGE_INCLUDE_DIRS"); + std::vector<std::string> includeDirs; + cmSystemTools::ExpandListArgument(includes, includeDirs); + for(std::vector<std::string>::const_iterator dirIt=includeDirs.begin(); + dirIt != includeDirs.end(); + ++dirIt) + { + mf->AddIncludeDirectory(dirIt->c_str(), false); + } + + std::string includeFlags = lg->GetIncludeFlags(language.c_str(), false); + std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS"); + printf("%s %s\n", includeFlags.c_str(), definitions.c_str()); + } + else if (mode == "LINK") + { + const char* targetName = "dummy"; + std::vector<std::string> srcs; + cmTarget* tgt = mf->AddExecutable(targetName, srcs, true); + tgt->SetProperty("LINKER_LANGUAGE", language.c_str()); + + std::string libs = mf->GetSafeDefinition("PACKAGE_LIBRARIES"); + std::vector<std::string> libList; + cmSystemTools::ExpandListArgument(libs, libList); + for(std::vector<std::string>::const_iterator libIt=libList.begin(); + libIt != libList.end(); + ++libIt) + { + mf->AddLinkLibraryForTarget(targetName, libIt->c_str(), + cmTarget::GENERAL); + } + + + std::string linkLibs; + std::string flags; + std::string linkFlags; + lg->GetTargetFlags(linkLibs, flags, linkFlags, *tgt); + + printf("%s\n", linkLibs.c_str() ); + +/* if ( use_win32 ) + { + tgt->SetProperty("WIN32_EXECUTABLE", "ON"); + } + if ( use_macbundle) + { + tgt->SetProperty("MACOSX_BUNDLE", "ON"); + }*/ + } + + // free generic one if generated +// this->SetGlobalGenerator(0); // setting 0-pointer is not possible +// delete gg; // this crashes inside the cmake instance + + return packageFound; +} + + // Parse the args void cmake::SetArgs(const std::vector<std::string>& args, bool directoriesSetBefore) @@ -607,6 +723,11 @@ void cmake::SetArgs(const std::vector<std::string>& args, // skip for now i++; } + else if(arg.find("--find-package",0) == 0) + { + // skip for now + i++; + } else if(arg.find("-Wno-dev",0) == 0) { // skip for now @@ -2035,7 +2156,7 @@ int cmake::ActualConfigure() this->CleanupCommandsAndMacros(); int res = 0; - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { res = this->DoPreConfigureChecks(); } @@ -2223,7 +2344,7 @@ int cmake::ActualConfigure() this->CacheManager->RemoveCacheEntry("CMAKE_EXTRA_GENERATOR"); } // only save the cache if there were no fatal errors - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); } @@ -2289,7 +2410,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) // set the cmake command this->CMakeCommand = args[0]; - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { // load the cache if(this->LoadCache() < 0) @@ -2310,7 +2431,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) } // In script mode we terminate after running the script. - if(this->ScriptMode) + if(this->GetWorkingMode() != NORMAL_MODE) { if(cmSystemTools::GetErrorOccuredFlag()) { @@ -2356,7 +2477,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) this->SetStartDirectory(this->GetHomeDirectory()); this->SetStartOutputDirectory(this->GetHomeOutputDirectory()); int ret = this->Configure(); - if (ret || this->ScriptMode) + if (ret || this->GetWorkingMode() != NORMAL_MODE) { #if defined(CMAKE_HAVE_VS_GENERATORS) if(!this->VSSolutionFile.empty() && this->GlobalGenerator) diff --git a/Source/cmake.h b/Source/cmake.h index 09f6c37..ae56e85 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -64,6 +64,25 @@ class cmake WARNING, LOG }; + + + /** Describes the working modes of cmake. + * NORMAL_MODE: cmake runs to create project files + * SCRIPT_MODE: in script mode there is no generator and no cache. Also, + * language are not enabled, so add_executable and things do + * not do anything. Started by using -P + * FIND_PACKAGE_MODE: cmake runs in pkg-config like mode, i.e. it just + * searches for a package and prints the results to stdout. + * This is similar to SCRIPT_MODE, but commands like + * add_library() work too, since they may be used e.g. in + * exported target files. Started via --find-package + */ + enum WorkingMode + { + NORMAL_MODE, + SCRIPT_MODE, + FIND_PACKAGE_MODE + }; typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap; ///! construct an instance of cmake @@ -274,13 +293,8 @@ class cmake ///! Do all the checks before running configure int DoPreConfigureChecks(); - /** - * Set and get the script mode option. In script mode there is no - * generator and no cache. Also, language are not enabled, so - * add_executable and things do not do anything. - */ - void SetScriptMode(bool mode) { this->ScriptMode = mode; } - bool GetScriptMode() { return this->ScriptMode; } + void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; } + WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; } ///! Debug the try compile stuff by not delelting the files bool GetDebugTryCompile(){return this->DebugTryCompile;} @@ -409,6 +423,7 @@ protected: ///! read in a cmake list file to initialize the cache void ReadListFile(const std::vector<std::string>& args, const char *path); + bool FindPackage(const std::vector<std::string>& args); ///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file. /// If it is set, truncate it to 50kb @@ -462,7 +477,7 @@ private: void* ProgressCallbackClientData; bool Verbose; bool InTryCompile; - bool ScriptMode; + WorkingMode CurrentWorkingMode; bool DebugOutput; bool Trace; bool WarnUninitialized; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 1fe9e82..9f213a5 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -103,6 +103,11 @@ static const char * cmDocumentationOptions[][3] = "No configure or generate step is performed and the cache is not" " modified. If variables are defined using -D, this must be done " "before the -P argument."}, + {"--find-package", "Run in pkg-config like mode.", + "Search a package using find_package() and print the resulting flags " + "to stdout. This can be used to use cmake instead of pkg-config to find " + "installed libraries in plain Makefile-based projects or in " + "autoconf-based projects (via share/aclocal/cmake.m4)."}, {"--graphviz=[file]", "Generate graphviz of dependencies.", "Generate a graphviz input file that will contain all the library and " "executable dependencies in the project."}, @@ -434,7 +439,7 @@ int do_cmake(int ac, char** av) bool list_all_cached = false; bool list_help = false; bool view_only = false; - bool script_mode = false; + cmake::WorkingMode workingMode = cmake::NORMAL_MODE; std::vector<std::string> args; for(int i =0; i < ac; ++i) { @@ -482,12 +487,18 @@ int do_cmake(int ac, char** av) } else { - script_mode = true; + workingMode = cmake::SCRIPT_MODE; args.push_back(av[i]); i++; args.push_back(av[i]); } } + else if (!command && strncmp(av[i], "--find-package", + strlen("--find-package")) == 0) + { + workingMode = cmake::FIND_PACKAGE_MODE; + args.push_back(av[i]); + } else { args.push_back(av[i]); @@ -512,7 +523,7 @@ int do_cmake(int ac, char** av) cmake cm; cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm); cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm); - cm.SetScriptMode(script_mode); + cm.SetWorkingMode(workingMode); int res = cm.Run(args, view_only); if ( list_cached || list_all_cached ) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index c4aff4a..695949a 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -4573,8 +4573,6 @@ void SystemTools::ClassInitialize() // for windows because drive letters need to be maintained. Also, // there are not sym-links and mount points on windows anyway. #if !defined(_WIN32) || defined(__CYGWIN__) - // Work-around an SGI problem by always adding this mapping: - SystemTools::AddTranslationPath("/tmp_mnt/", "/"); // The tmp path is frequently a logical path so always keep it: SystemTools::AddKeepPath("/tmp/"); diff --git a/Source/kwsys/hash_fun.hxx.in b/Source/kwsys/hash_fun.hxx.in index f21efc5..8c5eb6a 100644 --- a/Source/kwsys/hash_fun.hxx.in +++ b/Source/kwsys/hash_fun.hxx.in @@ -38,8 +38,9 @@ #define @KWSYS_NAMESPACE@_hash_fun_hxx #include <@KWSYS_NAMESPACE@/Configure.hxx> - +#include <@KWSYS_NAMESPACE@/FundamentalType.h> #include <@KWSYS_NAMESPACE@/cstddef> // size_t +#include <@KWSYS_NAMESPACE@/stl/string> // string namespace @KWSYS_NAMESPACE@ { @@ -66,6 +67,18 @@ struct hash<const char*> { }; @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION + struct hash<@KWSYS_NAMESPACE@_stl::string> { + size_t operator()(const @KWSYS_NAMESPACE@_stl::string & __s) const { return _stl_hash_string(__s.c_str()); } +}; + +#if !defined(__BORLANDC__) +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION + struct hash<const @KWSYS_NAMESPACE@_stl::string> { + size_t operator()(const @KWSYS_NAMESPACE@_stl::string & __s) const { return _stl_hash_string(__s.c_str()); } +}; +#endif + +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION struct hash<char> { size_t operator()(char __x) const { return __x; } }; @@ -110,6 +123,28 @@ struct hash<unsigned long> { size_t operator()(unsigned long __x) const { return __x; } }; +// use long long or __int64 +#if @KWSYS_NAMESPACE@_USE_LONG_LONG +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION +struct hash<long long> { + size_t operator()(long long __x) const { return __x; } +}; + +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION +struct hash<unsigned long long> { + size_t operator()(unsigned long long __x) const { return __x; } +}; +#elif @KWSYS_NAMESPACE@_USE___INT64 +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION +struct hash<__int64> { + size_t operator()(__int64 __x) const { return __x; } +}; +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION +struct hash<unsigned __int64> { + size_t operator()(unsigned __int64 __x) const { return __x; } +}; +#endif // use long long or __int64 + } // namespace @KWSYS_NAMESPACE@ #endif diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 9526dcd..4558e2a 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 08) +SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 07) +SET(KWSYS_DATE_STAMP_DAY 01) |