CMakeSetupDialog.cpp 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293
  1. // pcbuilderdialogDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "shellapi.h"
  5. // a fun undef for DOT NET
  6. #undef DEBUG
  7. #include "CMakeSetup.h"
  8. #include "MakeHelp.h"
  9. #include "PathDialog.h"
  10. #include "CMakeSetupDialog.h"
  11. #include "CMakeCommandLineInfo.h"
  12. #include "../cmCacheManager.h"
  13. #include "../cmake.h"
  14. #include "../cmGlobalGenerator.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. // Convert to Win32 path (slashes). But it's not in cmSystemTools, so
  21. // the 2 billions people that are using the CMake API can not mistake
  22. // it with cmMakeMyCoffeeButNoSugarPlease().
  23. std::string ConvertToWindowsPath(const char* path)
  24. {
  25. // Convert to output path.
  26. // Remove the "" around it (if any) since it's an output path for
  27. // the shell. If another shell-oriented feature is not designed
  28. // for a GUI use, then we are in trouble.
  29. std::string s = cmSystemTools::ConvertToOutputPath(path);
  30. std::string::iterator i = s.begin();
  31. if (*i == '\"')
  32. {
  33. s.erase(i, i + 1);
  34. }
  35. i = s.begin() + s.length() - 1;
  36. if (*i == '\"')
  37. {
  38. s.erase(i, i + 1);
  39. }
  40. return s;
  41. }
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CAboutDlg dialog used for App About
  44. class CAboutDlg : public CDialog
  45. {
  46. public:
  47. CAboutDlg();
  48. // Dialog Data
  49. //{{AFX_DATA(CAboutDlg)
  50. enum { IDD = IDD_ABOUTBOX };
  51. //}}AFX_DATA
  52. // ClassWizard generated virtual function overrides
  53. //{{AFX_VIRTUAL(CAboutDlg)
  54. protected:
  55. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  56. //}}AFX_VIRTUAL
  57. // Implementation
  58. protected:
  59. //{{AFX_MSG(CAboutDlg)
  60. //}}AFX_MSG
  61. DECLARE_MESSAGE_MAP()
  62. };
  63. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  64. {
  65. //{{AFX_DATA_INIT(CAboutDlg)
  66. //}}AFX_DATA_INIT
  67. }
  68. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  69. {
  70. CDialog::DoDataExchange(pDX);
  71. //{{AFX_DATA_MAP(CAboutDlg)
  72. //}}AFX_DATA_MAP
  73. }
  74. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  75. //{{AFX_MSG_MAP(CAboutDlg)
  76. // No message handlers
  77. //}}AFX_MSG_MAP
  78. END_MESSAGE_MAP();
  79. void MFCMessageCallback(const char* m, const char* title, bool& nomore)
  80. {
  81. std::string message = m;
  82. message += "\n\n(Press Cancel to suppress any further messages.)";
  83. if(::MessageBox(0, message.c_str(), title,
  84. MB_OKCANCEL|MB_TASKMODAL) == IDCANCEL)
  85. {
  86. nomore = true;
  87. }
  88. }
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CMakeSetupDialog dialog
  91. CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
  92. CWnd* pParent /*=NULL*/)
  93. : CDialog(CMakeSetupDialog::IDD, pParent)
  94. {
  95. cmSystemTools::SetErrorCallback(MFCMessageCallback);
  96. m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath";
  97. m_CacheEntriesList.m_CMakeSetupDialog = this;
  98. //{{AFX_DATA_INIT(CMakeSetupDialog)
  99. // Get the parameters from the command line info
  100. // If an unknown parameter is found, try to interpret it too, since it
  101. // is likely to be a file dropped on the shortcut :)
  102. if (cmdInfo.m_LastUnknownParameter.IsEmpty())
  103. {
  104. this->m_WhereSource = cmdInfo.m_WhereSource;
  105. this->m_WhereBuild = cmdInfo.m_WhereBuild;
  106. this->m_GeneratorChoiceString = cmdInfo.m_GeneratorChoiceString;
  107. this->m_AdvancedValues = cmdInfo.m_AdvancedValues;
  108. }
  109. else
  110. {
  111. this->m_WhereSource = _T("");
  112. this->m_WhereBuild = _T("");
  113. this->m_AdvancedValues = FALSE;
  114. this->m_GeneratorChoiceString = _T("");
  115. this->ChangeDirectoriesFromFile((LPCTSTR)cmdInfo.m_LastUnknownParameter);
  116. }
  117. //}}AFX_DATA_INIT
  118. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  119. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  120. m_BuildPathChanged = false;
  121. // Find the path to the cmake.exe executable
  122. char fname[1024];
  123. ::GetModuleFileName(NULL,fname,1023);
  124. // extract just the path part
  125. m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str();
  126. // add the cmake.exe to the path
  127. m_PathToExecutable += "/cmake.exe";
  128. m_oldCX = -1;
  129. m_deltaXRemainder = 0;
  130. m_CMakeInstance = new cmake;
  131. }
  132. void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
  133. {
  134. CDialog::DoDataExchange(pDX);
  135. //{{AFX_DATA_MAP(CMakeSetupDialog)
  136. DDX_Control(pDX, IDC_HELP_BUTTON, m_HelpButton);
  137. DDX_Control(pDX, IDC_Generator, m_GeneratorChoice);
  138. DDX_Control(pDX, IDC_OK, m_OKButton);
  139. DDX_Control(pDX, IDCANCEL, m_CancelButton);
  140. DDX_CBStringExact(pDX, IDC_WhereSource, m_WhereSource);
  141. DDX_CBStringExact(pDX, IDC_WhereBuild, m_WhereBuild);
  142. DDX_Control(pDX, IDC_FRAME, m_ListFrame);
  143. DDX_Control(pDX, IDC_WhereSource, m_WhereSourceControl);
  144. DDX_Control(pDX, IDC_WhereBuild, m_WhereBuildControl);
  145. DDX_Control(pDX, IDC_LIST2, m_CacheEntriesList);
  146. DDX_Control(pDX, IDC_MouseHelpCaption, m_MouseHelp);
  147. DDX_Control(pDX, IDC_CMAKE_VERSION, m_VersionDisplay);
  148. DDX_Control(pDX, IDC_BuildProjects, m_Configure);
  149. DDX_CBStringExact(pDX, IDC_Generator, m_GeneratorChoiceString);
  150. DDX_Check(pDX, IDC_AdvancedValues, m_AdvancedValues);
  151. //}}AFX_DATA_MAP
  152. }
  153. BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog)
  154. //{{AFX_MSG_MAP(CMakeSetupDialog)
  155. ON_WM_SYSCOMMAND()
  156. ON_WM_PAINT()
  157. ON_WM_QUERYDRAGICON()
  158. ON_WM_DROPFILES()
  159. ON_BN_CLICKED(IDC_BUTTON2, OnBrowseWhereSource)
  160. ON_BN_CLICKED(IDC_BuildProjects, OnConfigure)
  161. ON_BN_CLICKED(IDC_BUTTON3, OnBrowseWhereBuild)
  162. ON_CBN_EDITCHANGE(IDC_WhereBuild, OnChangeWhereBuild)
  163. ON_CBN_SELCHANGE(IDC_WhereBuild, OnSelendokWhereBuild)
  164. ON_CBN_EDITCHANGE(IDC_WhereSource, OnChangeWhereSource)
  165. ON_CBN_SELENDOK(IDC_WhereSource, OnSelendokWhereSource)
  166. ON_WM_SIZE()
  167. ON_WM_GETMINMAXINFO()
  168. ON_BN_CLICKED(IDC_OK, OnOk)
  169. ON_CBN_EDITCHANGE(IDC_Generator, OnEditchangeGenerator)
  170. ON_BN_CLICKED(IDC_HELP_BUTTON, OnHelpButton)
  171. ON_BN_CLICKED(IDCANCEL, OnCancel)
  172. ON_BN_CLICKED(IDC_AdvancedValues, OnAdvancedValues)
  173. ON_BN_DOUBLECLICKED(IDC_AdvancedValues, OnDoubleclickedAdvancedValues)
  174. //}}AFX_MSG_MAP
  175. END_MESSAGE_MAP()
  176. /////////////////////////////////////////////////////////////////////////////
  177. // CMakeSetupDialog message handlers
  178. BOOL CMakeSetupDialog::OnInitDialog()
  179. {
  180. CDialog::OnInitDialog();
  181. this->DragAcceptFiles(true);
  182. // Add "Create shortcut" menu item to system menu.
  183. // IDM_CREATESHORTCUT must be in the system command range.
  184. ASSERT((IDM_CREATESHORTCUT & 0xFFF0) == IDM_CREATESHORTCUT);
  185. ASSERT(IDM_CREATESHORTCUT < 0xF000);
  186. // Add "About..." menu item to system menu.
  187. // IDM_ABOUTBOX must be in the system command range.
  188. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  189. ASSERT(IDM_ABOUTBOX < 0xF000);
  190. CMenu* pSysMenu = GetSystemMenu(FALSE);
  191. if (pSysMenu != NULL)
  192. {
  193. CString strCreateShortcutMenu;
  194. strCreateShortcutMenu.LoadString(IDS_CREATESHORTCUT);
  195. if (!strCreateShortcutMenu.IsEmpty())
  196. {
  197. pSysMenu->AppendMenu(MF_SEPARATOR);
  198. pSysMenu->AppendMenu(MF_STRING,
  199. IDM_CREATESHORTCUT,
  200. strCreateShortcutMenu);
  201. }
  202. CString strAboutMenu;
  203. strAboutMenu.LoadString(IDS_ABOUTBOX);
  204. if (!strAboutMenu.IsEmpty())
  205. {
  206. pSysMenu->AppendMenu(MF_SEPARATOR);
  207. pSysMenu->AppendMenu(MF_STRING,
  208. IDM_ABOUTBOX,
  209. strAboutMenu);
  210. }
  211. }
  212. // Set the icon for this dialog. The framework does this automatically
  213. // when the application's main window is not a dialog
  214. SetIcon(m_hIcon, TRUE); // Set big icon
  215. SetIcon(m_hIcon, FALSE); // Set small icon
  216. // Load source and build dirs from registry
  217. this->LoadFromRegistry();
  218. std::vector<std::string> names;
  219. this->m_CMakeInstance->GetRegisteredGenerators(names);
  220. for(std::vector<std::string>::iterator i = names.begin();
  221. i != names.end(); ++i)
  222. {
  223. m_GeneratorChoice.AddString(i->c_str());
  224. }
  225. if (m_GeneratorChoiceString == _T(""))
  226. {
  227. m_GeneratorChoiceString = "Visual Studio 6";
  228. }
  229. // try to load the cmake cache from disk
  230. this->LoadCacheFromDiskToGUI();
  231. m_WhereBuildControl.LimitText(2048);
  232. m_WhereSourceControl.LimitText(2048);
  233. m_GeneratorChoice.LimitText(2048);
  234. // Set the version number
  235. char tmp[1024];
  236. sprintf(tmp,"Version %d.%d - %s", cmake::GetMajorVersion(),
  237. cmake::GetMinorVersion(), cmake::GetReleaseVersion());
  238. SetDlgItemText(IDC_CMAKE_VERSION, tmp);
  239. this->UpdateData(FALSE);
  240. return TRUE; // return TRUE unless you set the focus to a control
  241. }
  242. // About dialog invoke
  243. void CMakeSetupDialog::OnSysCommand(UINT nID, LPARAM lParam)
  244. {
  245. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  246. {
  247. CAboutDlg dlgAbout;
  248. dlgAbout.DoModal();
  249. }
  250. else if ((nID & 0xFFF0) == IDM_CREATESHORTCUT)
  251. {
  252. CreateShortcut();
  253. }
  254. else
  255. {
  256. CDialog::OnSysCommand(nID, lParam);
  257. }
  258. }
  259. // If you add a minimize button to your dialog, you will need the code below
  260. // to draw the icon. For MFC applications using the document/view model,
  261. // this is automatically done for you by the framework.
  262. void CMakeSetupDialog::OnPaint()
  263. {
  264. if (IsIconic())
  265. {
  266. CPaintDC dc(this); // device context for painting
  267. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  268. // Center icon in client rectangle
  269. int cxIcon = GetSystemMetrics(SM_CXICON);
  270. int cyIcon = GetSystemMetrics(SM_CYICON);
  271. CRect rect;
  272. GetClientRect(&rect);
  273. int x = (rect.Width() - cxIcon + 1) / 2;
  274. int y = (rect.Height() - cyIcon + 1) / 2;
  275. // Draw the icon
  276. dc.DrawIcon(x, y, m_hIcon);
  277. }
  278. else
  279. {
  280. CDialog::OnPaint();
  281. }
  282. }
  283. // The system calls this to obtain the cursor to display while the user drags
  284. // the minimized window.
  285. HCURSOR CMakeSetupDialog::OnQueryDragIcon()
  286. {
  287. return (HCURSOR) m_hIcon;
  288. }
  289. // Browse button
  290. bool CMakeSetupDialog::Browse(CString &result, const char *title)
  291. {
  292. CPathDialog dlg("Select Path", title, result);
  293. if(dlg.DoModal()==IDOK)
  294. {
  295. result = dlg.GetPathName();
  296. return true;
  297. }
  298. else
  299. {
  300. return false;
  301. }
  302. }
  303. void CMakeSetupDialog::SaveToRegistry()
  304. {
  305. HKEY hKey;
  306. DWORD dwDummy;
  307. if(RegCreateKeyEx(HKEY_CURRENT_USER,
  308. m_RegistryKey,
  309. 0, "", REG_OPTION_NON_VOLATILE, KEY_READ|KEY_WRITE,
  310. NULL, &hKey, &dwDummy) != ERROR_SUCCESS)
  311. {
  312. return;
  313. }
  314. else
  315. {
  316. // save some values
  317. CString regvalue;
  318. this->ReadRegistryValue(hKey, &(regvalue),"WhereSource1","C:\\");
  319. int shiftEnd = 9;
  320. if(m_WhereSource != regvalue)
  321. {
  322. char keyName[1024];
  323. char keyName2[1024];
  324. int i;
  325. for (i = 2; i < 10; ++i)
  326. {
  327. regvalue = "";
  328. sprintf(keyName,"WhereSource%i",i);
  329. this->ReadRegistryValue(hKey, &(regvalue),keyName,"");
  330. // check for short circuit, if the new value is already in
  331. // the list then we stop
  332. if (m_WhereSource == regvalue)
  333. {
  334. shiftEnd = i - 1;
  335. }
  336. }
  337. for (i = shiftEnd; i; --i)
  338. {
  339. regvalue = "";
  340. sprintf(keyName,"WhereSource%i",i);
  341. sprintf(keyName2,"WhereSource%i",i+1);
  342. this->ReadRegistryValue(hKey, &(regvalue),keyName,"");
  343. if (strlen(regvalue))
  344. {
  345. RegSetValueEx(hKey, _T(keyName2), 0, REG_SZ,
  346. (CONST BYTE *)(const char *)regvalue,
  347. regvalue.GetLength());
  348. }
  349. }
  350. RegSetValueEx(hKey, _T("WhereSource1"), 0, REG_SZ,
  351. (CONST BYTE *)(const char *)m_WhereSource,
  352. m_WhereSource.GetLength());
  353. }
  354. this->ReadRegistryValue(hKey, &(regvalue),"WhereBuild1","C:\\");
  355. if(m_WhereBuild != regvalue)
  356. {
  357. int i;
  358. char keyName[1024];
  359. char keyName2[1024];
  360. for (i = 2; i < 10; ++i)
  361. {
  362. regvalue = "";
  363. sprintf(keyName,"WhereBuild%i",i);
  364. this->ReadRegistryValue(hKey, &(regvalue),keyName,"");
  365. // check for short circuit, if the new value is already in
  366. // the list then we stop
  367. if (m_WhereBuild == regvalue)
  368. {
  369. shiftEnd = i - 1;
  370. }
  371. }
  372. for (i = shiftEnd; i; --i)
  373. {
  374. regvalue = "";
  375. sprintf(keyName,"WhereBuild%i",i);
  376. sprintf(keyName2,"WhereBuild%i",i+1);
  377. this->ReadRegistryValue(hKey, &(regvalue),keyName,"");
  378. if (strlen(regvalue))
  379. {
  380. RegSetValueEx(hKey, _T(keyName2), 0, REG_SZ,
  381. (CONST BYTE *)(const char *)regvalue,
  382. regvalue.GetLength());
  383. }
  384. }
  385. RegSetValueEx(hKey, _T("WhereBuild1"), 0, REG_SZ,
  386. (CONST BYTE *)(const char *)m_WhereBuild,
  387. m_WhereBuild.GetLength());
  388. }
  389. }
  390. RegCloseKey(hKey);
  391. }
  392. void CMakeSetupDialog::ReadRegistryValue(HKEY hKey,
  393. CString *val,
  394. const char *key,
  395. const char *adefault)
  396. {
  397. DWORD dwType, dwSize;
  398. char *pb;
  399. dwType = REG_SZ;
  400. pb = val->GetBuffer(MAX_PATH);
  401. dwSize = MAX_PATH;
  402. if(RegQueryValueEx(hKey,_T(key), NULL, &dwType,
  403. (BYTE *)pb, &dwSize) != ERROR_SUCCESS)
  404. {
  405. val->ReleaseBuffer();
  406. *val = _T(adefault);
  407. }
  408. else
  409. {
  410. val->ReleaseBuffer();
  411. }
  412. }
  413. void CMakeSetupDialog::LoadFromRegistry()
  414. {
  415. HKEY hKey;
  416. if(RegOpenKeyEx(HKEY_CURRENT_USER,
  417. m_RegistryKey,
  418. 0, KEY_READ, &hKey) != ERROR_SUCCESS)
  419. {
  420. return;
  421. }
  422. else
  423. {
  424. // load some values
  425. if (m_WhereSource.IsEmpty())
  426. {
  427. this->ReadRegistryValue(hKey, &(m_WhereSource),"WhereSource1","C:\\");
  428. }
  429. if (m_WhereBuild.IsEmpty())
  430. {
  431. this->ReadRegistryValue(hKey, &(m_WhereBuild),"WhereBuild1","C:\\");
  432. }
  433. m_WhereSourceControl.AddString(m_WhereSource);
  434. m_WhereBuildControl.AddString(m_WhereBuild);
  435. char keyname[1024];
  436. CString regvalue;
  437. int i;
  438. for (i = 2; i <= 10; ++i)
  439. {
  440. sprintf(keyname,"WhereSource%i",i);
  441. regvalue = "";
  442. this->ReadRegistryValue(hKey, &(regvalue),keyname,"C:\\");
  443. if (strcmp("C:\\",regvalue))
  444. {
  445. m_WhereSourceControl.AddString(regvalue);
  446. }
  447. sprintf(keyname,"WhereBuild%i",i);
  448. regvalue = "";
  449. this->ReadRegistryValue(hKey, &(regvalue),keyname,"C:\\");
  450. if (strcmp("C:\\",regvalue))
  451. {
  452. m_WhereBuildControl.AddString(regvalue);
  453. }
  454. }
  455. }
  456. RegCloseKey(hKey);
  457. }
  458. // Callback for browse source button
  459. void CMakeSetupDialog::OnBrowseWhereSource()
  460. {
  461. this->UpdateData();
  462. Browse(m_WhereSource, "Enter Path to Source");
  463. this->UpdateData(false);
  464. this->OnChangeWhereSource();
  465. }
  466. // Callback for browser build button
  467. void CMakeSetupDialog::OnBrowseWhereBuild()
  468. {
  469. this->UpdateData();
  470. Browse(m_WhereBuild, "Enter Path to Build");
  471. this->UpdateData(false);
  472. this->OnChangeWhereBuild();
  473. }
  474. void CMakeSetupDialog::RunCMake(bool generateProjectFiles)
  475. {
  476. if(!cmSystemTools::FileExists(m_WhereBuild))
  477. {
  478. std::string message =
  479. "Build directory does not exist, should I create it?\n\n"
  480. "Directory: ";
  481. message += (const char*)m_WhereBuild;
  482. if(MessageBox(message.c_str(), "Create Directory", MB_OKCANCEL) == IDOK)
  483. {
  484. cmSystemTools::MakeDirectory(m_WhereBuild);
  485. }
  486. else
  487. {
  488. MessageBox("Build Project aborted, nothing done.");
  489. return;
  490. }
  491. }
  492. // set the wait cursor
  493. ::SetCursor(LoadCursor(NULL, IDC_WAIT));
  494. // get all the info from the dialog
  495. this->UpdateData();
  496. // always save the current gui values to disk
  497. this->SaveCacheFromGUI();
  498. // Make sure we are working from the cache on disk
  499. this->LoadCacheFromDiskToGUI();
  500. m_OKButton.EnableWindow(false);
  501. // setup the cmake instance
  502. if (generateProjectFiles)
  503. {
  504. if(m_CMakeInstance->Generate() != 0)
  505. {
  506. cmSystemTools::Error(
  507. "Error in generation process, project files may be invalid");
  508. }
  509. }
  510. else
  511. {
  512. m_CMakeInstance->SetHomeDirectory(m_WhereSource);
  513. m_CMakeInstance->SetStartDirectory(m_WhereSource);
  514. m_CMakeInstance->SetHomeOutputDirectory(m_WhereBuild);
  515. m_CMakeInstance->SetStartOutputDirectory(m_WhereBuild);
  516. m_CMakeInstance->SetGlobalGenerator(
  517. m_CMakeInstance->CreateGlobalGenerator(m_GeneratorChoiceString));
  518. if(m_CMakeInstance->Configure(m_PathToExecutable) != 0)
  519. {
  520. cmSystemTools::Error(
  521. "Error in configuration process, project files may be invalid");
  522. }
  523. // update the GUI with any new values in the caused by the
  524. // generation process
  525. this->LoadCacheFromDiskToGUI();
  526. }
  527. // save source and build paths to registry
  528. this->SaveToRegistry();
  529. // path is up-to-date now
  530. m_BuildPathChanged = false;
  531. // put the cursor back
  532. ::SetCursor(LoadCursor(NULL, IDC_ARROW));
  533. cmSystemTools::ResetErrorOccuredFlag();
  534. }
  535. // Callback for build projects button
  536. void CMakeSetupDialog::OnConfigure()
  537. {
  538. // enable error messages each time configure is pressed
  539. cmSystemTools::EnableMessages();
  540. this->RunCMake(false);
  541. }
  542. // callback for combo box menu where build selection
  543. void CMakeSetupDialog::OnSelendokWhereBuild()
  544. {
  545. m_WhereBuildControl.GetLBText(m_WhereBuildControl.GetCurSel(),
  546. m_WhereBuild);
  547. m_WhereBuildControl.SetWindowText( m_WhereBuild);
  548. this->UpdateData(FALSE);
  549. this->OnChangeWhereBuild();
  550. }
  551. // callback for combo box menu where source selection
  552. void CMakeSetupDialog::OnSelendokWhereSource()
  553. {
  554. m_WhereSourceControl.GetLBText(m_WhereSourceControl.GetCurSel(),
  555. m_WhereSource);
  556. this->UpdateData(FALSE);
  557. this->OnChangeWhereSource();
  558. }
  559. // callback for chaing source directory
  560. void CMakeSetupDialog::OnChangeWhereSource()
  561. {
  562. }
  563. // callback for changing the build directory
  564. void CMakeSetupDialog::OnChangeWhereBuild()
  565. {
  566. this->UpdateData();
  567. // The build dir has changed, check if there is a cache, and
  568. // grab the source dir from it
  569. std::string path = this->m_WhereBuild;
  570. cmSystemTools::ConvertToUnixSlashes(path);
  571. // adjust the cmake instance
  572. m_CMakeInstance->SetHomeOutputDirectory(m_WhereBuild);
  573. m_CMakeInstance->SetStartOutputDirectory(m_WhereBuild);
  574. std::string cache_file = path;
  575. cache_file += "/CMakeCache.txt";
  576. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  577. if (cmSystemTools::FileExists(cache_file.c_str()) &&
  578. cachem->LoadCache(path.c_str()) &&
  579. cachem->GetCacheEntry("CMAKE_HOME_DIRECTORY"))
  580. {
  581. path = ConvertToWindowsPath(
  582. cachem->GetCacheEntry("CMAKE_HOME_DIRECTORY")->m_Value.c_str());
  583. this->m_WhereSource = path.c_str();
  584. this->m_WhereSourceControl.SetWindowText(this->m_WhereSource);
  585. this->OnChangeWhereSource();
  586. }
  587. m_CacheEntriesList.RemoveAll();
  588. m_CacheEntriesList.ShowWindow(SW_SHOW);
  589. this->LoadCacheFromDiskToGUI();
  590. m_BuildPathChanged = true;
  591. }
  592. // copy from the cache manager to the cache edit list box
  593. void CMakeSetupDialog::FillCacheGUIFromCacheManager()
  594. {
  595. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  596. size_t size = m_CacheEntriesList.GetItems().size();
  597. bool reverseOrder = false;
  598. // if there are already entries in the cache, then
  599. // put the new ones in the top, so they show up first
  600. if(size)
  601. {
  602. reverseOrder = true;
  603. }
  604. // all the current values are not new any more
  605. std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
  606. for(std::set<CPropertyItem*>::iterator i = items.begin();
  607. i != items.end(); ++i)
  608. {
  609. CPropertyItem* item = *i;
  610. item->m_NewValue = false;
  611. }
  612. for(cmCacheManager::CacheIterator i = cachem->NewIterator();
  613. !i.IsAtEnd(); i.Next())
  614. {
  615. const char* key = i.GetName();
  616. cmCacheManager::CacheEntry value = i.GetEntry();
  617. // if value has trailing space or tab, enclose it in single quotes
  618. // to enforce the fact that it has 'invisible' trailing stuff
  619. if (value.m_Value.size() &&
  620. (value.m_Value[value.m_Value.size() - 1] == ' ' ||
  621. value.m_Value[value.m_Value.size() - 1] == '\t'))
  622. {
  623. value.m_Value = '\'' + value.m_Value + '\'';
  624. }
  625. if(!m_AdvancedValues)
  626. {
  627. if(cachem->IsAdvanced(key))
  628. {
  629. m_CacheEntriesList.RemoveProperty(key);
  630. continue;
  631. }
  632. }
  633. switch(value.m_Type )
  634. {
  635. case cmCacheManager::BOOL:
  636. if(cmSystemTools::IsOn(value.m_Value.c_str()))
  637. {
  638. m_CacheEntriesList.AddProperty(key,
  639. "ON",
  640. value.m_HelpString.c_str(),
  641. CPropertyList::COMBO,"ON|OFF",
  642. reverseOrder
  643. );
  644. }
  645. else
  646. {
  647. m_CacheEntriesList.AddProperty(key,
  648. "OFF",
  649. value.m_HelpString.c_str(),
  650. CPropertyList::COMBO,"ON|OFF",
  651. reverseOrder
  652. );
  653. }
  654. break;
  655. case cmCacheManager::PATH:
  656. m_CacheEntriesList.AddProperty(key,
  657. value.m_Value.c_str(),
  658. value.m_HelpString.c_str(),
  659. CPropertyList::PATH,"",
  660. reverseOrder
  661. );
  662. break;
  663. case cmCacheManager::FILEPATH:
  664. m_CacheEntriesList.AddProperty(key,
  665. value.m_Value.c_str(),
  666. value.m_HelpString.c_str(),
  667. CPropertyList::FILE,"",
  668. reverseOrder
  669. );
  670. break;
  671. case cmCacheManager::STRING:
  672. m_CacheEntriesList.AddProperty(key,
  673. value.m_Value.c_str(),
  674. value.m_HelpString.c_str(),
  675. CPropertyList::EDIT,"",
  676. reverseOrder
  677. );
  678. break;
  679. case cmCacheManager::INTERNAL:
  680. m_CacheEntriesList.RemoveProperty(key);
  681. break;
  682. }
  683. }
  684. m_OKButton.EnableWindow(false);
  685. if(cachem->GetSize() > 0 && !cmSystemTools::GetErrorOccuredFlag())
  686. {
  687. bool enable = true;
  688. items = m_CacheEntriesList.GetItems();
  689. for(std::set<CPropertyItem*>::iterator i = items.begin();
  690. i != items.end(); ++i)
  691. {
  692. CPropertyItem* item = *i;
  693. if(item->m_NewValue)
  694. {
  695. // if one new value then disable to OK button
  696. enable = false;
  697. break;
  698. }
  699. }
  700. if(enable)
  701. {
  702. m_OKButton.EnableWindow(true);
  703. }
  704. }
  705. // redraw the list
  706. m_CacheEntriesList.SetTopIndex(0);
  707. m_CacheEntriesList.Invalidate();
  708. }
  709. // copy from the list box to the cache manager
  710. void CMakeSetupDialog::FillCacheManagerFromCacheGUI()
  711. {
  712. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  713. std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
  714. for(std::set<CPropertyItem*>::iterator i = items.begin();
  715. i != items.end(); ++i)
  716. {
  717. CPropertyItem* item = *i;
  718. cmCacheManager::CacheEntry *entry = cachem->GetCacheEntry(
  719. (const char*)item->m_propName);
  720. if (entry)
  721. {
  722. // if value is enclosed in single quotes ('foo') then remove them
  723. // they were used to enforce the fact that it had 'invisible'
  724. // trailing stuff
  725. if (item->m_curValue.GetLength() >= 2 &&
  726. item->m_curValue[0] == '\'' &&
  727. item->m_curValue[item->m_curValue.GetLength() - 1] == '\'')
  728. {
  729. entry->m_Value = item->m_curValue.Mid(1,
  730. item->m_curValue.GetLength() - 2);
  731. }
  732. else
  733. {
  734. entry->m_Value = item->m_curValue;
  735. }
  736. }
  737. }
  738. }
  739. //! Load cache file from m_WhereBuild and display in GUI editor
  740. void CMakeSetupDialog::LoadCacheFromDiskToGUI()
  741. {
  742. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  743. if(m_WhereBuild != "")
  744. {
  745. cachem->LoadCache(m_WhereBuild);
  746. this->FillCacheGUIFromCacheManager();
  747. if(cachem->GetCacheEntry("CMAKE_GENERATOR"))
  748. {
  749. std::string curGen =
  750. cachem->GetCacheEntry("CMAKE_GENERATOR")->m_Value;
  751. if(m_GeneratorChoiceString != curGen.c_str())
  752. {
  753. m_GeneratorChoiceString = curGen.c_str();
  754. this->UpdateData(FALSE);
  755. }
  756. }
  757. }
  758. }
  759. //! Save GUI values to cmCacheManager and then save to disk.
  760. void CMakeSetupDialog::SaveCacheFromGUI()
  761. {
  762. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  763. this->FillCacheManagerFromCacheGUI();
  764. if(m_WhereBuild != "")
  765. {
  766. cachem->SaveCache(m_WhereBuild);
  767. }
  768. }
  769. void CMakeSetupDialog::OnSize(UINT nType, int cx, int cy)
  770. {
  771. if (nType == SIZE_MINIMIZED)
  772. {
  773. CDialog::OnSize(nType, cx, cy);
  774. return;
  775. }
  776. if (m_oldCX == -1)
  777. {
  778. m_oldCX = cx;
  779. m_oldCY = cy;
  780. }
  781. int deltax = cx - m_oldCX;
  782. int deltay = cy - m_oldCY;
  783. m_oldCX = cx;
  784. m_oldCY = cy;
  785. CDialog::OnSize(nType, cx, cy);
  786. if (deltax == 0 && deltay == 0)
  787. {
  788. return;
  789. }
  790. if(m_CacheEntriesList.m_hWnd)
  791. {
  792. // get the original sizes/positions
  793. CRect cRect;
  794. m_ListFrame.GetWindowRect(&cRect);
  795. m_ListFrame.SetWindowPos(&wndTop, cRect.left, cRect.top,
  796. cRect.Width() + deltax,
  797. cRect.Height() + deltay,
  798. SWP_NOMOVE | SWP_NOZORDER);
  799. m_CacheEntriesList.GetWindowRect(&cRect);
  800. m_CacheEntriesList.SetWindowPos(&wndTop, cRect.left, cRect.top,
  801. cRect.Width() + deltax,
  802. cRect.Height() + deltay,
  803. SWP_NOMOVE | SWP_NOZORDER);
  804. m_VersionDisplay.SetWindowPos(&wndTop, 5, cy-23, 0, 0,
  805. SWP_NOSIZE | SWP_NOZORDER);
  806. deltax = int(deltax + m_deltaXRemainder);
  807. m_deltaXRemainder = float(deltax%2);
  808. m_MouseHelp.GetWindowRect(&cRect);
  809. this->ScreenToClient(&cRect);
  810. m_MouseHelp.SetWindowPos(&wndTop, cRect.left + deltax/2,
  811. cRect.top + deltay,
  812. 0, 0,
  813. SWP_NOSIZE | SWP_NOZORDER);
  814. m_Configure.GetWindowRect(&cRect);
  815. this->ScreenToClient(&cRect);
  816. m_Configure.SetWindowPos(&wndTop, cRect.left + deltax/2,
  817. cRect.top + deltay,
  818. 0, 0,
  819. SWP_NOSIZE | SWP_NOZORDER);
  820. m_CancelButton.GetWindowRect(&cRect);
  821. this->ScreenToClient(&cRect);
  822. m_CancelButton.SetWindowPos(&wndTop, cRect.left + deltax/2,
  823. cRect.top + deltay,
  824. 0, 0,
  825. SWP_NOSIZE | SWP_NOZORDER);
  826. m_OKButton.GetWindowRect(&cRect);
  827. this->ScreenToClient(&cRect);
  828. m_OKButton.SetWindowPos(&wndTop, cRect.left + deltax/2,
  829. cRect.top + deltay,
  830. 0, 0,
  831. SWP_NOSIZE | SWP_NOZORDER);
  832. m_HelpButton.GetWindowRect(&cRect);
  833. this->ScreenToClient(&cRect);
  834. m_HelpButton.SetWindowPos(&wndTop, cRect.left + deltax/2,
  835. cRect.top + deltay,
  836. 0, 0,
  837. SWP_NOSIZE | SWP_NOZORDER);
  838. }
  839. }
  840. void CMakeSetupDialog::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI )
  841. {
  842. lpMMI->ptMinTrackSize.x = 550;
  843. lpMMI->ptMinTrackSize.y = 272;
  844. }
  845. void CMakeSetupDialog::OnCancel()
  846. {
  847. if(m_CacheEntriesList.IsDirty())
  848. {
  849. if(MessageBox("You have changed options but not rebuilt, "
  850. "are you sure you want to exit?", "Confirm Exit",
  851. MB_YESNO) == IDYES)
  852. {
  853. CDialog::OnOK();
  854. }
  855. }
  856. else
  857. {
  858. CDialog::OnOK();
  859. }
  860. }
  861. void CMakeSetupDialog::OnOk()
  862. {
  863. // enable error messages each time configure is pressed
  864. cmSystemTools::EnableMessages();
  865. m_CacheEntriesList.ClearDirty();
  866. this->RunCMake(true);
  867. if (!(::GetKeyState(VK_SHIFT) & 0x1000))
  868. {
  869. CDialog::OnOK();
  870. }
  871. }
  872. void CMakeSetupDialog::OnEditchangeGenerator()
  873. {
  874. // TODO: Add your control notification handler code here
  875. }
  876. // Create a shortcut on the desktop with the current Source/Build dir.
  877. int CMakeSetupDialog::CreateShortcut()
  878. {
  879. // Find the desktop folder and create the link name
  880. HKEY hKey;
  881. if(RegOpenKeyEx(HKEY_CURRENT_USER,
  882. "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
  883. 0, KEY_READ, &hKey) != ERROR_SUCCESS)
  884. {
  885. AfxMessageBox ("Create shortcut: unable to find 'Shell Folders' key in registry!");
  886. return 1;
  887. }
  888. DWORD dwType, dwSize;
  889. #define MAXPATH 1024
  890. char link_name[MAXPATH];
  891. dwSize = MAXPATH;
  892. if(RegQueryValueEx(hKey,
  893. (LPCTSTR)"Desktop",
  894. NULL,
  895. &dwType,
  896. (BYTE *)link_name,
  897. &dwSize) != ERROR_SUCCESS)
  898. {
  899. AfxMessageBox ("Create shortcut: unable to find 'Desktop' registry value in 'Shell Folders' key!");
  900. return 1;
  901. }
  902. if(dwType != REG_SZ)
  903. {
  904. AfxMessageBox ("Create shortcut: 'Desktop' registry value in 'Shell Folders' key has wrong type!");
  905. return 1;
  906. }
  907. strcat(link_name, "\\CMake - ");
  908. std::string current_dir = cmSystemTools::GetFilenameName((LPCTSTR)m_WhereSource);
  909. strcat(link_name, current_dir.c_str());
  910. strcat(link_name, ".lnk");
  911. // Find the path to the current executable
  912. char path_to_current_exe[MAXPATH];
  913. ::GetModuleFileName(NULL, path_to_current_exe, MAXPATH);
  914. // Create the shortcut
  915. HRESULT hres;
  916. IShellLink *psl;
  917. // Initialize the COM library
  918. hres = CoInitialize(NULL);
  919. if (! SUCCEEDED (hres))
  920. {
  921. AfxMessageBox ("Create shortcut: unable to initialize the COM library!");
  922. return 1;
  923. }
  924. // Create an IShellLink object and get a pointer to the IShellLink
  925. // interface (returned from CoCreateInstance).
  926. hres = CoCreateInstance(CLSID_ShellLink,
  927. NULL,
  928. CLSCTX_INPROC_SERVER,
  929. IID_IShellLink,
  930. (void **)&psl);
  931. if (! SUCCEEDED (hres))
  932. {
  933. AfxMessageBox ("Create shortcut: unable to create IShellLink instance!");
  934. return 1;
  935. }
  936. IPersistFile *ppf;
  937. // Query IShellLink for the IPersistFile interface for
  938. // saving the shortcut in persistent storage.
  939. hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
  940. if (SUCCEEDED (hres))
  941. {
  942. // Set the path to the shortcut target.
  943. hres = psl->SetPath(path_to_current_exe);
  944. if (! SUCCEEDED (hres))
  945. {
  946. AfxMessageBox ("Create shortcut: SetPath failed!");
  947. }
  948. // Set the arguments of the shortcut.
  949. CString args = " /H=\"" + m_WhereSource + "\" /B=\"" + m_WhereBuild + "\" /G=\"" + m_GeneratorChoiceString + "\" /A=\"" + (m_AdvancedValues ? "TRUE" : "FALSE") + "\"";
  950. hres = psl->SetArguments(args);
  951. if (! SUCCEEDED (hres))
  952. {
  953. AfxMessageBox ("Create shortcut: SetArguments failed!");
  954. }
  955. // Set the description of the shortcut.
  956. hres = psl->SetDescription("Shortcut to CMakeSetup");
  957. if (! SUCCEEDED (hres))
  958. {
  959. AfxMessageBox ("Create shortcut: SetDescription failed!");
  960. }
  961. // Ensure that the string consists of ANSI characters.
  962. WORD wsz[MAX_PATH];
  963. MultiByteToWideChar(CP_ACP, 0, link_name, -1, wsz, MAX_PATH);
  964. // Save the shortcut via the IPersistFile::Save member function.
  965. hres = ppf->Save(wsz, TRUE);
  966. if (! SUCCEEDED (hres))
  967. {
  968. AfxMessageBox ("Create shortcut: Save failed!");
  969. }
  970. // Release the pointer to IPersistFile.
  971. ppf->Release ();
  972. }
  973. // Release the pointer to IShellLink.
  974. psl->Release ();
  975. return 0;
  976. }
  977. void CMakeSetupDialog::OnHelpButton()
  978. {
  979. CMakeHelp dialog;
  980. dialog.DoModal();
  981. }
  982. void CMakeSetupDialog::ShowAdvancedValues()
  983. {
  984. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  985. for(cmCacheManager::CacheIterator i = cachem->NewIterator();
  986. !i.IsAtEnd(); i.Next())
  987. {
  988. const char* key = i.GetName();
  989. const cmCacheManager::CacheEntry& value = i.GetEntry();
  990. if(!cachem->IsAdvanced(key))
  991. {
  992. continue;
  993. }
  994. switch(value.m_Type )
  995. {
  996. case cmCacheManager::BOOL:
  997. if(cmSystemTools::IsOn(value.m_Value.c_str()))
  998. {
  999. m_CacheEntriesList.AddProperty(key,
  1000. "ON",
  1001. value.m_HelpString.c_str(),
  1002. CPropertyList::COMBO,"ON|OFF",
  1003. true
  1004. );
  1005. }
  1006. else
  1007. {
  1008. m_CacheEntriesList.AddProperty(key,
  1009. "OFF",
  1010. value.m_HelpString.c_str(),
  1011. CPropertyList::COMBO,"ON|OFF",
  1012. true
  1013. );
  1014. }
  1015. break;
  1016. case cmCacheManager::PATH:
  1017. m_CacheEntriesList.AddProperty(key,
  1018. value.m_Value.c_str(),
  1019. value.m_HelpString.c_str(),
  1020. CPropertyList::PATH,"",
  1021. true
  1022. );
  1023. break;
  1024. case cmCacheManager::FILEPATH:
  1025. m_CacheEntriesList.AddProperty(key,
  1026. value.m_Value.c_str(),
  1027. value.m_HelpString.c_str(),
  1028. CPropertyList::FILE,"",
  1029. true
  1030. );
  1031. break;
  1032. case cmCacheManager::STRING:
  1033. m_CacheEntriesList.AddProperty(key,
  1034. value.m_Value.c_str(),
  1035. value.m_HelpString.c_str(),
  1036. CPropertyList::EDIT,"",
  1037. true
  1038. );
  1039. break;
  1040. case cmCacheManager::INTERNAL:
  1041. m_CacheEntriesList.RemoveProperty(key);
  1042. break;
  1043. }
  1044. }
  1045. }
  1046. void CMakeSetupDialog::RemoveAdvancedValues()
  1047. {
  1048. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  1049. for(cmCacheManager::CacheIterator i = cachem->NewIterator();
  1050. !i.IsAtEnd(); i.Next())
  1051. {
  1052. const char* key = i.GetName();
  1053. const cmCacheManager::CacheEntry& value = i.GetEntry();
  1054. if(cachem->IsAdvanced(key))
  1055. {
  1056. m_CacheEntriesList.RemoveProperty(key);
  1057. }
  1058. }
  1059. }
  1060. void CMakeSetupDialog::OnAdvancedValues()
  1061. {
  1062. this->UpdateData();
  1063. if(m_AdvancedValues)
  1064. {
  1065. this->ShowAdvancedValues();
  1066. }
  1067. else
  1068. {
  1069. this->RemoveAdvancedValues();
  1070. }
  1071. }
  1072. void CMakeSetupDialog::OnDoubleclickedAdvancedValues()
  1073. {
  1074. this->OnAdvancedValues();
  1075. }
  1076. // Handle param or single dropped file.
  1077. // If the dropped file is a build directory or any file in a
  1078. // build directory, set the source dir from the cache file,
  1079. // otherwise set the source and build dirs to this file (or dir).
  1080. void CMakeSetupDialog::ChangeDirectoriesFromFile(const char* buffer)
  1081. {
  1082. // Get the path to this file
  1083. std::string path = buffer;
  1084. if (!cmSystemTools::FileIsDirectory(path.c_str()))
  1085. {
  1086. path = cmSystemTools::GetFilenamePath(path);
  1087. }
  1088. else
  1089. {
  1090. cmSystemTools::ConvertToUnixSlashes(path);
  1091. }
  1092. // Check if it's a build dir and grab the cache
  1093. std::string cache_file = path;
  1094. cache_file += "/CMakeCache.txt";
  1095. cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
  1096. if (cmSystemTools::FileExists(cache_file.c_str()) &&
  1097. cachem->LoadCache(path.c_str()) &&
  1098. cachem->GetCacheEntry("CMAKE_HOME_DIRECTORY"))
  1099. {
  1100. path = ConvertToWindowsPath(path.c_str());
  1101. this->m_WhereBuild = path.c_str();
  1102. path = ConvertToWindowsPath(
  1103. cachem->GetCacheEntry("CMAKE_HOME_DIRECTORY")->m_Value.c_str());
  1104. this->m_WhereSource = path.c_str();
  1105. }
  1106. else
  1107. {
  1108. path = ConvertToWindowsPath(path.c_str());
  1109. this->m_WhereSource = this->m_WhereBuild = path.c_str();
  1110. }
  1111. }
  1112. // The framework calls this member function when the user releases the
  1113. // left mouse button over a window that has registered itself as the
  1114. // recipient of dropped files.
  1115. void CMakeSetupDialog::OnDropFiles(HDROP hDropInfo)
  1116. {
  1117. UINT nb_files = DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, 0);
  1118. if (nb_files > 0)
  1119. {
  1120. UINT buffer_size = DragQueryFile(hDropInfo, 0, NULL, 0);
  1121. char *buffer = new char [buffer_size + 1];
  1122. DragQueryFile(hDropInfo, 0, buffer, buffer_size + 1);
  1123. this->ChangeDirectoriesFromFile(buffer);
  1124. delete [] buffer;
  1125. this->m_WhereSourceControl.SetWindowText(this->m_WhereSource);
  1126. this->m_WhereBuildControl.SetWindowText(this->m_WhereBuild);
  1127. this->UpdateData(FALSE);
  1128. this->OnChangeWhereSource();
  1129. this->OnChangeWhereBuild();
  1130. }
  1131. DragFinish(hDropInfo);
  1132. }