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