1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
// CMakeCommandLineInfo.cpp : command line arguments
//
#include "stdafx.h"
#include "CMakeCommandLineInfo.h"
#include "cmSystemTools.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
///////////////////////////////////////////////////////////////
// CMakeCommandLineInfo
CMakeCommandLineInfo::CMakeCommandLineInfo()
{
this->m_WhereSource = _T("");
this->m_WhereBuild = _T("");
this->m_AdvancedValues = FALSE;
this->m_GeneratorChoiceString = _T("");
this->m_LastUnknownParameter = _T("");
// Find the path to the CMakeSetup executable.
char fname[4096];
::GetModuleFileName(0, fname, 4096);
m_Argv0 = fname;
m_Argv.push_back(m_Argv0.c_str());
}
CMakeCommandLineInfo::~CMakeCommandLineInfo()
{
}
int CMakeCommandLineInfo::GetBoolValue(const CString& v) {
CString value = v;
value.MakeLower();
if (value == "1" ||
value == "on" ||
value == "true" ||
value == "yes")
{
return 1;
}
else if (value == "0" ||
value == "off" ||
value == "false" ||
value == "no")
{
return -1;
}
return 0;
}
///////////////////////////////////////////////////////////////
// Parse param
void CMakeCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
{
// Construct the full name of the argument.
cmStdString param = lpszParam;
cmStdString value;
if(bFlag)
{
// Since bFlag is set, either a - or a / was removed from the
// parameter value. Assume it was a - unless the second character
// was a / which indicates a network path argument.
if(param.length() > 0 && param[0] == '/')
{
value = "/";
}
else
{
value = "-";
}
}
value += param;
// Add the argument and reset the argv table in case strings were
// moved.
m_Arguments.push_back(value);
m_Argv.clear();
m_Argv.push_back(m_Argv0.c_str());
for(unsigned int i=0; i < m_Arguments.size(); ++i)
{
m_Argv.push_back(m_Arguments[i].c_str());
}
// Look for known flags.
if(!bFlag)
{
this->m_LastUnknownParameter = lpszParam;
}
else
{
CString sParam(lpszParam);
// Single letter valued flag like /B=value or /B:value
CString value;
if (sParam[1] == '=' || sParam[1] == ':')
{
value = sParam.Right(sParam.GetLength() - 2);
}
else
{
value = sParam.Right(sParam.GetLength()-1);
}
int res;
switch (sParam[0])
{
case 'A':
res = CMakeCommandLineInfo::GetBoolValue(value);
if (res == 1)
{
this->m_AdvancedValues = TRUE;
}
else if (res == -1)
{
this->m_AdvancedValues = FALSE;
}
break;
case 'B':
{
std::string path = cmSystemTools::CollapseFullPath((const char*)value);
this->m_WhereBuild = path.c_str();
break;
}
case 'G':
this->m_GeneratorChoiceString = value;
break;
case 'H':
{
std::string path = cmSystemTools::CollapseFullPath((const char*)value);
this->m_WhereSource = path.c_str();
break;
}
}
}
// Call the base class to ensure proper command line processing
CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
}
|