bool operator()(WorkspaceConfigurationPtr one, WorkspaceConfigurationPtr two) const { return one->GetName().Lower().CmpNoCase(two->GetName().Lower()) < 0; }
void clCxxWorkspace::AddProjectToBuildMatrix(ProjectPtr prj) { if(!prj) { wxMessageBox(_("AddProjectToBuildMatrix was called with NULL project"), _("CodeLite"), wxICON_WARNING | wxOK); return; } BuildMatrixPtr matrix = GetBuildMatrix(); wxString selConfName = matrix->GetSelectedConfigurationName(); std::list<WorkspaceConfigurationPtr> wspList = matrix->GetConfigurations(); std::list<WorkspaceConfigurationPtr>::iterator iter = wspList.begin(); for(; iter != wspList.end(); iter++) { WorkspaceConfigurationPtr workspaceConfig = (*iter); WorkspaceConfiguration::ConfigMappingList prjList = workspaceConfig->GetMapping(); wxString wspCnfName = workspaceConfig->GetName(); ProjectSettingsCookie cookie; // getSettings is a bit misleading, since it actually create new instance which represents the layout // of the XML ProjectSettingsPtr settings = prj->GetSettings(); BuildConfigPtr prjBldConf = settings->GetFirstBuildConfiguration(cookie); BuildConfigPtr matchConf; if(!prjBldConf) { // the project does not have any settings, create new one and add it prj->SetSettings(settings); settings = prj->GetSettings(); prjBldConf = settings->GetFirstBuildConfiguration(cookie); matchConf = prjBldConf; } else { matchConf = prjBldConf; // try to locate the best match to add to the workspace while(prjBldConf) { wxString projBldConfName = prjBldConf->GetName(); if(wspCnfName == projBldConfName) { // we found a suitable match use it instead of the default one matchConf = prjBldConf; break; } prjBldConf = settings->GetNextBuildConfiguration(cookie); } } ConfigMappingEntry entry(prj->GetName(), matchConf->GetName()); prjList.push_back(entry); (*iter)->SetConfigMappingList(prjList); matrix->SetConfiguration((*iter)); } // and set the configuration name matrix->SetSelectedConfigurationName(selConfName); // this will also reset the build matrix pointer SetBuildMatrix(matrix); }