2001-08-22 01:41:12 +04:00
|
|
|
// CMakeCommandLineInfo.cpp : command line arguments
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "CMakeCommandLineInfo.h"
|
2004-01-08 23:54:30 +03:00
|
|
|
#include "cmSystemTools.h"
|
2001-08-22 01:41:12 +04:00
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
#define new DEBUG_NEW
|
|
|
|
#undef THIS_FILE
|
|
|
|
static char THIS_FILE[] = __FILE__;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
// CMakeCommandLineInfo
|
|
|
|
|
|
|
|
CMakeCommandLineInfo::CMakeCommandLineInfo()
|
|
|
|
{
|
2002-07-21 23:56:08 +04:00
|
|
|
this->m_WhereSource = _T("");
|
|
|
|
this->m_WhereBuild = _T("");
|
|
|
|
this->m_AdvancedValues = FALSE;
|
|
|
|
this->m_GeneratorChoiceString = _T("");
|
|
|
|
this->m_LastUnknownParameter = _T("");
|
2003-07-24 01:31:25 +04:00
|
|
|
|
|
|
|
// Find the path to the CMakeSetup executable.
|
|
|
|
char fname[4096];
|
|
|
|
::GetModuleFileName(0, fname, 4096);
|
|
|
|
m_Argv0 = fname;
|
2001-08-22 01:41:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
CMakeCommandLineInfo::~CMakeCommandLineInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-12-03 23:59:17 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2001-08-22 01:41:12 +04:00
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
// Parse param
|
|
|
|
|
|
|
|
void CMakeCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
|
|
|
|
{
|
2003-07-24 01:31:25 +04:00
|
|
|
// Construct the full name of the argument.
|
2003-07-24 19:24:05 +04:00
|
|
|
cmStdString param = lpszParam;
|
2003-07-24 01:31:25 +04:00
|
|
|
cmStdString value;
|
|
|
|
if(bFlag)
|
|
|
|
{
|
2003-07-24 19:24:05 +04:00
|
|
|
// 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 = "-";
|
|
|
|
}
|
2003-07-24 01:31:25 +04:00
|
|
|
}
|
2003-07-24 19:24:05 +04:00
|
|
|
value += param;
|
2003-07-24 01:31:25 +04:00
|
|
|
|
|
|
|
// 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.
|
2002-07-21 23:56:08 +04:00
|
|
|
if(!bFlag)
|
|
|
|
{
|
|
|
|
this->m_LastUnknownParameter = lpszParam;
|
|
|
|
}
|
|
|
|
else
|
2001-08-22 01:41:12 +04:00
|
|
|
{
|
|
|
|
CString sParam(lpszParam);
|
|
|
|
// Single letter valued flag like /B=value or /B:value
|
2002-05-08 17:43:45 +04:00
|
|
|
CString value;
|
2001-08-22 01:41:12 +04:00
|
|
|
if (sParam[1] == '=' || sParam[1] == ':')
|
|
|
|
{
|
2002-05-08 17:43:45 +04:00
|
|
|
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)
|
|
|
|
{
|
2002-07-21 23:56:08 +04:00
|
|
|
this->m_AdvancedValues = TRUE;
|
2002-05-08 17:43:45 +04:00
|
|
|
}
|
|
|
|
else if (res == -1)
|
|
|
|
{
|
2002-07-21 23:56:08 +04:00
|
|
|
this->m_AdvancedValues = FALSE;
|
2002-05-08 17:43:45 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'B':
|
2004-01-08 23:54:30 +03:00
|
|
|
{
|
|
|
|
std::string path = cmSystemTools::CollapseFullPath((const char*)value);
|
|
|
|
this->m_WhereBuild = path.c_str();
|
2002-05-08 17:43:45 +04:00
|
|
|
break;
|
2004-01-08 23:54:30 +03:00
|
|
|
}
|
2002-05-08 17:43:45 +04:00
|
|
|
case 'G':
|
2002-07-21 23:56:08 +04:00
|
|
|
this->m_GeneratorChoiceString = value;
|
2002-05-08 17:43:45 +04:00
|
|
|
break;
|
|
|
|
case 'H':
|
2004-01-08 23:54:30 +03:00
|
|
|
{
|
|
|
|
std::string path = cmSystemTools::CollapseFullPath((const char*)value);
|
|
|
|
this->m_WhereSource = path.c_str();
|
2002-05-08 17:43:45 +04:00
|
|
|
break;
|
2001-08-22 01:41:12 +04:00
|
|
|
}
|
2004-01-08 23:54:30 +03:00
|
|
|
}
|
2001-08-22 01:41:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Call the base class to ensure proper command line processing
|
|
|
|
CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
|
|
|
|
}
|