CMakeGenDialog.cpp 3.2 KB

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