diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index 54604060f..ba6c28f53 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -956,6 +956,19 @@ void CMakeSetupDialog::LoadCacheFromDiskToGUI() if(m_WhereBuild != "") { cachem->LoadCache(m_WhereBuild); + cmCacheManager::CacheIterator itm = cachem->NewIterator(); + if ( itm.Find("CMAKE_HOME_DIRECTORY")) + { + std::string path = ConvertToWindowsPath(itm.GetValue()); + this->m_WhereSource = path.c_str(); + this->m_WhereSourceControl.SetWindowText(this->m_WhereSource); + this->OnChangeWhereSource(); + } + m_CMakeInstance->SetHomeDirectory(m_WhereSource); + m_CMakeInstance->SetStartDirectory(m_WhereSource); + m_CMakeInstance->SetHomeOutputDirectory(m_WhereBuild); + m_CMakeInstance->SetStartOutputDirectory(m_WhereBuild); + m_CMakeInstance->PreLoadCMakeFiles(); this->FillCacheGUIFromCacheManager(); cmCacheManager::CacheIterator it = cachem->GetCacheIterator("CMAKE_GENERATOR"); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b8e3c2474..ca07acf23 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1182,16 +1182,22 @@ bool cmake::CacheVersionMatches() void cmake::PreLoadCMakeFiles() { std::string pre_load = this->GetHomeDirectory(); - pre_load += "/PreLoad.cmake"; - if ( cmSystemTools::FileExists(pre_load.c_str()) ) + if ( pre_load.size() > 0 ) { - this->ReadListFile(pre_load.c_str()); + pre_load += "/PreLoad.cmake"; + if ( cmSystemTools::FileExists(pre_load.c_str()) ) + { + this->ReadListFile(pre_load.c_str()); + } } pre_load = this->GetHomeOutputDirectory(); - pre_load += "/PreLoad.cmake"; - if ( cmSystemTools::FileExists(pre_load.c_str()) ) + if ( pre_load.size() > 0 ) { - this->ReadListFile(pre_load.c_str()); + pre_load += "/PreLoad.cmake"; + if ( cmSystemTools::FileExists(pre_load.c_str()) ) + { + this->ReadListFile(pre_load.c_str()); + } } }