| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- // 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()
- {
- 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;
- }
- 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':
- this->m_WhereBuild = value;
- break;
- case 'G':
- this->m_GeneratorChoiceString = value;
- break;
- case 'H':
- this->m_WhereSource = value;
- break;
- }
- }
- // Call the base class to ensure proper command line processing
- CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
- }
|