CMakeSetup now handles command-line arguments (ex: /H=source_dir /B=build_dir)
This commit is contained in:
parent
a159c2d306
commit
9b25981068
|
@ -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);
|
||||
}
|
|
@ -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)
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue