CMakeSetup.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. // CMakeSetupdialog.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "CMakeSetup.h"
  5. #include "CMakeSetupDialog.h"
  6. #include "CMakeCommandLineInfo.h"
  7. #include "../cmDocumentation.h"
  8. #include "../cmake.h"
  9. //----------------------------------------------------------------------------
  10. static const char * cmDocumentationName[][3] =
  11. {
  12. {0,
  13. " CMakeSetup - CMake Windows GUI.", 0},
  14. {0,0,0}
  15. };
  16. //----------------------------------------------------------------------------
  17. static const char * cmDocumentationUsage[][3] =
  18. {
  19. {0,
  20. " CMakeSetup [options]\n"
  21. " CMakeSetup [options] <path-to-source>\n"
  22. " CMakeSetup [options] <path-to-existing-build>", 0},
  23. {0,0,0}
  24. };
  25. //----------------------------------------------------------------------------
  26. static const char * cmDocumentationDescription[][3] =
  27. {
  28. {0,
  29. "The \"CMakeSetup\" executable is the CMake Windows GUI. Project "
  30. "configuration settings may be specified interactively. "
  31. "Brief instructions are provided at the bottom of the "
  32. "window when the program is running.", 0},
  33. CMAKE_STANDARD_INTRODUCTION,
  34. {0,0,0}
  35. };
  36. //----------------------------------------------------------------------------
  37. static const char * cmDocumentationOptions[][3] =
  38. {
  39. {"-A[on|off]", "Enable/disable display of advanced cache values.",
  40. "There are two categories of CMake cache values: non-advanced and "
  41. "advanced. Most users will not need to change the advanced options. "
  42. "The CMakeSetup GUI contains a checkbox to enable/disable display of "
  43. "advanced options. This command line flag changes its default setting."},
  44. {0,0,0}
  45. };
  46. #ifdef _DEBUG
  47. #define new DEBUG_NEW
  48. #undef THIS_FILE
  49. static char THIS_FILE[] = __FILE__;
  50. #endif
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CMakeSetup
  53. BEGIN_MESSAGE_MAP(CMakeSetup, CWinApp)
  54. //{{AFX_MSG_MAP(CMakeSetup)
  55. // NOTE - the ClassWizard will add and remove mapping macros here.
  56. // DO NOT EDIT what you see in these blocks of generated code!
  57. //}}AFX_MSG
  58. ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  59. END_MESSAGE_MAP();
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CMakeSetup construction
  62. CMakeSetup::CMakeSetup()
  63. {
  64. // TODO: add construction code here,
  65. // Place all significant initialization in InitInstance
  66. }
  67. /////////////////////////////////////////////////////////////////////////////
  68. // The one and only CMakeSetup object
  69. CMakeSetup theApp;
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CMakeSetup initialization
  72. BOOL CMakeSetup::InitInstance()
  73. {
  74. AfxEnableControlContainer();
  75. // Standard initialization
  76. // If you are not using these features and wish to reduce the size
  77. // of your final executable, you should remove from the following
  78. // the specific initialization routines you do not need.
  79. #if _MFC_VER <= 0x421
  80. #ifdef _AFXDLL
  81. Enable3dControls(); // Call this when using MFC in a shared DLL
  82. #else
  83. Enable3dControlsStatic(); // Call this when linking to MFC statically
  84. #endif
  85. #endif
  86. CMakeCommandLineInfo cmdInfo;
  87. ParseCommandLine(cmdInfo);
  88. // Check for documentation options. If there are no arguments skip
  89. // the check because the GUI should be displayed instead of showing
  90. // usage in this case.
  91. cmDocumentation doc;
  92. if(cmdInfo.GetArgC() > 1 &&
  93. doc.CheckOptions(cmdInfo.GetArgC(), cmdInfo.GetArgV()))
  94. {
  95. // Construct and print requested documentation.
  96. cmake hcm;
  97. hcm.AddCMakePaths(cmdInfo.GetArgV()[0]);
  98. doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT"));
  99. std::vector<cmDocumentationEntry> commands;
  100. std::vector<cmDocumentationEntry> compatCommands;
  101. std::vector<cmDocumentationEntry> generators;
  102. hcm.GetCommandDocumentation(commands, true, false);
  103. hcm.GetCommandDocumentation(compatCommands, false, true);
  104. hcm.GetGeneratorDocumentation(generators);
  105. doc.SetName("cmake");
  106. doc.SetSection("Name",cmDocumentationName);
  107. doc.SetSection("Usage",cmDocumentationUsage);
  108. doc.SetSection("Description",cmDocumentationDescription);
  109. doc.SetSection("Generators",generators);
  110. doc.SetSection("Options",cmDocumentationOptions);
  111. doc.SetSection("Commands",commands);
  112. doc.SetSection("Compatilbility Commands", compatCommands);
  113. return (doc.PrintRequestedDocumentation(std::cout)? 0:1);
  114. }
  115. CMakeSetupDialog dlg(cmdInfo);
  116. m_pMainWnd = &dlg;
  117. INT_PTR nResponse = dlg.DoModal();
  118. if (nResponse == IDOK)
  119. {
  120. // TODO: Place code here to handle when the dialog is
  121. // dismissed with OK
  122. }
  123. else if (nResponse == IDCANCEL)
  124. {
  125. // TODO: Place code here to handle when the dialog is
  126. // dismissed with Cancel
  127. }
  128. // Since the dialog has been closed, return FALSE so that we exit the
  129. // application, rather than start the application's message pump.
  130. return FALSE;
  131. }