CMakeGenDialog.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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\\CMakeSetup\\Settings\\StartPath;LastGenerator]";
  57. cmSystemTools::ExpandRegistryValues(mp);
  58. if(mp != "/registry")
  59. {
  60. m_GeneratorChoiceString = mp.c_str();
  61. done = true;
  62. }
  63. // look for VS8
  64. if (!done)
  65. {
  66. // check for vs8 in registry then decide what default to use
  67. mp =
  68. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup;Dbghelp_path]";
  69. cmSystemTools::ExpandRegistryValues(mp);
  70. if(mp != "/registry")
  71. {
  72. m_GeneratorChoiceString = "Visual Studio 8 2005";
  73. done = true;
  74. }
  75. }
  76. // look for VS7.1
  77. if (!done)
  78. {
  79. mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1;InstallDir]";
  80. cmSystemTools::ExpandRegistryValues(mp);
  81. if (mp != "/registry")
  82. {
  83. m_GeneratorChoiceString = "Visual Studio 7 .NET 2003";
  84. done = true;
  85. }
  86. }
  87. // look for VS7
  88. if (!done)
  89. {
  90. mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.0;InstallDir]";
  91. cmSystemTools::ExpandRegistryValues(mp);
  92. if (mp != "/registry")
  93. {
  94. m_GeneratorChoiceString = "Visual Studio 7";
  95. done = true;
  96. }
  97. }
  98. // if still not done just guess on VS 6
  99. if (!done)
  100. {
  101. m_GeneratorChoiceString = "Visual Studio 6";
  102. }
  103. this->UpdateData(FALSE);
  104. return TRUE; // return TRUE unless you set the focus to a control
  105. }