Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / MFCDialog / CMakeGenDialog.cpp
blobe1769b6aafc95c7e863ffc0c48037d5a9778b1ac
1 // CMakeGenDialog.cpp : implementation file
2 //
4 #include "stdafx.h"
5 #include "CMakeSetup.h"
6 #include "CMakeGenDialog.h"
7 #include "../cmake.h"
9 #ifdef _DEBUG
10 #define new DEBUG_NEW
11 #undef THIS_FILE
12 static char THIS_FILE[] = __FILE__;
13 #endif
15 /////////////////////////////////////////////////////////////////////////////
16 // CCMakeGenDialog dialog
19 CCMakeGenDialog::CCMakeGenDialog(CWnd* pParent /*=NULL*/)
20 : CDialog(CCMakeGenDialog::IDD, pParent)
22 //{{AFX_DATA_INIT(CCMakeGenDialog)
23 //}}AFX_DATA_INIT
27 void CCMakeGenDialog::DoDataExchange(CDataExchange* pDX)
29 CDialog::DoDataExchange(pDX);
30 //{{AFX_DATA_MAP(CCMakeGenDialog)
31 DDX_Control(pDX, IDC_BuildForLabel, m_BuildForLabel);
32 DDX_Control(pDX, IDC_Generator, m_GeneratorChoice);
33 DDX_CBStringExact(pDX, IDC_Generator, m_GeneratorChoiceString);
34 //}}AFX_DATA_MAP
38 BEGIN_MESSAGE_MAP(CCMakeGenDialog, CDialog)
39 //{{AFX_MSG_MAP(CCMakeGenDialog)
40 // NOTE: the ClassWizard will add message map macros here
41 ON_CBN_EDITCHANGE(IDC_Generator, OnEditchangeGenerator)
42 //}}AFX_MSG_MAP
43 END_MESSAGE_MAP()
45 /////////////////////////////////////////////////////////////////////////////
46 // CCMakeGenDialog message handler
48 void CCMakeGenDialog::OnEditchangeGenerator()
50 // TODO: Add your control notification handler code here
55 BOOL CCMakeGenDialog::OnInitDialog()
57 CDialog::OnInitDialog();
58 std::vector<std::string> names;
59 this->m_CMakeInstance->GetRegisteredGenerators(names);
60 for(std::vector<std::string>::iterator i = names.begin();
61 i != names.end(); ++i)
63 m_GeneratorChoice.AddString(i->c_str());
66 // we want to pick the best generator for their system first we check to
67 // see if they have run cmake before, if so we use that generator
68 std::string mp;
69 bool done = false;
71 // is the last generator set? If so use it
72 mp = "[HKEY_CURRENT_USER\\Software\\Kitware"
73 "\\CMakeSetup\\Settings\\StartPath;LastGenerator]";
74 cmSystemTools::ExpandRegistryValues(mp);
75 if(mp != "/registry")
77 m_GeneratorChoiceString = mp.c_str();
78 done = true;
80 struct regToGen
82 const char* Registry;
83 const char* GeneratorName;
85 regToGen installedGenerators[] = {
86 // VS 9
87 { "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft"
88 "\\VisualStudio\\9.0\\Setup;Dbghelp_path]", "Visual Studio 9 2008"},
89 // VS 8
90 { "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft"
91 "\\VisualStudio\\8.0\\Setup;Dbghelp_path]", "Visual Studio 8 2005"},
92 // VS 7.1
93 {"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft"
94 "\\VisualStudio\\7.1;InstallDir]", "Visual Studio 7 .NET 2003"},
95 // VS 7
96 {"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft"
97 "\\VisualStudio\\7.0;InstallDir]", "Visual Studio 7"},
98 {0,0}
100 for(regToGen* ptr = installedGenerators; ptr->Registry != 0 && !done; ptr++)
102 mp = ptr->Registry;
103 cmSystemTools::ExpandRegistryValues(mp);
104 if(mp != "/registry")
106 m_GeneratorChoiceString = ptr->GeneratorName;
107 done = true;
111 // if still not done just guess on VS 6
112 if (!done)
114 m_GeneratorChoiceString = "Visual Studio 6";
117 this->UpdateData(FALSE);
119 return TRUE; // return TRUE unless you set the focus to a control