diff options
-rw-r--r-- | Source/MFCDialog/CMakeCommandLineInfo.cpp | 52 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeCommandLineInfo.h | 40 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeSetup.cpp | 7 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeSetup.dsp | 8 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeSetupDialog.cpp | 18 | ||||
-rw-r--r-- | Source/MFCDialog/CMakeSetupDialog.h | 5 |
6 files changed, 123 insertions, 7 deletions
diff --git a/Source/MFCDialog/CMakeCommandLineInfo.cpp b/Source/MFCDialog/CMakeCommandLineInfo.cpp new file mode 100644 index 0000000..aefb349 --- /dev/null +++ b/Source/MFCDialog/CMakeCommandLineInfo.cpp @@ -0,0 +1,52 @@ +// CMakeCommandLineInfo.cpp : command line arguments +// + +#include "stdafx.h" +#include "CMakeCommandLineInfo.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +/////////////////////////////////////////////////////////////// +// CMakeCommandLineInfo + +CMakeCommandLineInfo::CMakeCommandLineInfo() +{ + m_WhereSource = _T(""); + m_WhereBuild = _T(""); +} + +CMakeCommandLineInfo::~CMakeCommandLineInfo() +{ +} + +/////////////////////////////////////////////////////////////// +// Parse param + +void CMakeCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast) +{ + if(bFlag) + { + CString sParam(lpszParam); + // Single letter valued flag like /B=value or /B:value + if (sParam[1] == '=' || sParam[1] == ':') + { + CString value(sParam.Right(sParam.GetLength() - 2)); + switch (sParam[0]) + { + case 'H': + m_WhereSource = value; + break; + case 'B': + m_WhereBuild = value; + break; + } + } + } + + // Call the base class to ensure proper command line processing + CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast); +} diff --git a/Source/MFCDialog/CMakeCommandLineInfo.h b/Source/MFCDialog/CMakeCommandLineInfo.h new file mode 100644 index 0000000..997f25c --- /dev/null +++ b/Source/MFCDialog/CMakeCommandLineInfo.h @@ -0,0 +1,40 @@ +// CMakeCommandLineInfo.h : main header file for the command line arguments +// + +#if !defined(CMAKECOMMANDLINEINFO_H) +#define CMAKECOMMANDLINEINFO_H + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ +#error include 'stdafx.h' before including this file for PCH +#endif + +/////////////////////////////////////////////////////////////// +// CMakeCommandLineInfo: +// See CMakeCommandLineInfo.cpp for the implementation of this class +// + +class CMakeCommandLineInfo : public CCommandLineInfo +{ + // Construction +public: + CMakeCommandLineInfo(); + + // Attributes +public: + CString m_WhereSource; + CString m_WhereBuild; + + // Operations +public: + void ParseParam(const TCHAR* pszParam, BOOL bFlag, BOOL bLast); + + // Implementation +public: + virtual ~CMakeCommandLineInfo(); +}; + +#endif // !defined(CMAKECOMMANDLINEINFO_H) diff --git a/Source/MFCDialog/CMakeSetup.cpp b/Source/MFCDialog/CMakeSetup.cpp index 22aa238..c97ca0f 100644 --- a/Source/MFCDialog/CMakeSetup.cpp +++ b/Source/MFCDialog/CMakeSetup.cpp @@ -4,6 +4,7 @@ #include "stdafx.h" #include "CMakeSetup.h" #include "CMakeSetupDialog.h" +#include "CMakeCommandLineInfo.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -54,7 +55,11 @@ BOOL CMakeSetup::InitInstance() Enable3dControlsStatic(); // Call this when linking to MFC statically #endif - CMakeSetupDialog dlg; + CMakeCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + CMakeSetupDialog dlg(cmdInfo); + m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) diff --git a/Source/MFCDialog/CMakeSetup.dsp b/Source/MFCDialog/CMakeSetup.dsp index 6c1c7f7..414adce 100644 --- a/Source/MFCDialog/CMakeSetup.dsp +++ b/Source/MFCDialog/CMakeSetup.dsp @@ -95,6 +95,10 @@ LINK32=link.exe # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
+SOURCE=.\CMakeCommandLineInfo.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\CMakeSetup.cpp
# End Source File
# Begin Source File
@@ -124,6 +128,10 @@ SOURCE=.\StdAfx.cpp # PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
+SOURCE=.\CMakeCommandLineInfo.h
+# End Source File
+# Begin Source File
+
SOURCE=.\CMakeSetup.h
# End Source File
# Begin Source File
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index 9209668..3f47424 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -5,6 +5,7 @@ #include "CMakeSetup.h" #include "PathDialog.h" #include "CMakeSetupDialog.h" +#include "CMakeCommandLineInfo.h" #include "../cmCacheManager.h" #include "../cmake.h" #ifdef _DEBUG @@ -62,14 +63,15 @@ BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) ///////////////////////////////////////////////////////////////////////////// // CMakeSetupDialog dialog -CMakeSetupDialog::CMakeSetupDialog(CWnd* pParent /*=NULL*/) +CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo, + CWnd* pParent /*=NULL*/) : CDialog(CMakeSetupDialog::IDD, pParent) { m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath"; //{{AFX_DATA_INIT(CMakeSetupDialog) - m_WhereSource = _T(""); - m_WhereBuild = _T(""); + m_WhereSource = cmdInfo.m_WhereSource; + m_WhereBuild = cmdInfo.m_WhereBuild; //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); @@ -339,8 +341,14 @@ void CMakeSetupDialog::LoadFromRegistry() else { // load some values - this->ReadRegistryValue(hKey, &(m_WhereSource),"WhereSource","C:\\"); - this->ReadRegistryValue(hKey, &(m_WhereBuild),"WhereBuild","C:\\"); + if (m_WhereSource.IsEmpty()) + { + this->ReadRegistryValue(hKey, &(m_WhereSource),"WhereSource","C:\\"); + } + if (m_WhereBuild.IsEmpty()) + { + this->ReadRegistryValue(hKey, &(m_WhereBuild),"WhereBuild","C:\\"); + } m_WhereSourceControl.AddString(m_WhereSource); m_WhereBuildControl.AddString(m_WhereBuild); diff --git a/Source/MFCDialog/CMakeSetupDialog.h b/Source/MFCDialog/CMakeSetupDialog.h index bb084d6..f2fdd9d 100644 --- a/Source/MFCDialog/CMakeSetupDialog.h +++ b/Source/MFCDialog/CMakeSetupDialog.h @@ -13,11 +13,14 @@ ///////////////////////////////////////////////////////////////////////////// // CMakeSetupDialog dialog +class CMakeCommandLineInfo; + class CMakeSetupDialog : public CDialog { // Construction public: - CMakeSetupDialog(CWnd* pParent = NULL); // standard constructor + CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo, + CWnd* pParent = NULL); protected: //! Load cache file from m_WhereBuild and display in GUI editor void LoadCacheFromDiskToGUI(); |