1 // CMakeCommandLineInfo.cpp : command line arguments
5 #include "CMakeCommandLineInfo.h"
6 #include "cmSystemTools.h"
11 static char THIS_FILE
[] = __FILE__
;
14 ///////////////////////////////////////////////////////////////
15 // CMakeCommandLineInfo
17 CMakeCommandLineInfo::CMakeCommandLineInfo()
19 this->m_WhereSource
= _T("");
20 this->m_WhereBuild
= _T("");
21 this->m_AdvancedValues
= FALSE
;
22 this->m_GeneratorChoiceString
= _T("");
23 this->m_LastUnknownParameter
= _T("");
25 // Find the path to the CMakeSetup executable.
27 ::GetModuleFileName(0, fname
, 4096);
29 m_Argv
.push_back(m_Argv0
.c_str());
32 CMakeCommandLineInfo::~CMakeCommandLineInfo()
36 int CMakeCommandLineInfo::GetBoolValue(const CString
& v
) {
46 else if (value
== "0" ||
56 ///////////////////////////////////////////////////////////////
59 void CMakeCommandLineInfo::ParseParam(LPCTSTR lpszParam
, BOOL bFlag
, BOOL bLast
)
61 // Construct the full name of the argument.
62 cmStdString param
= lpszParam
;
66 // Since bFlag is set, either a - or a / was removed from the
67 // parameter value. Assume it was a - unless the second character
68 // was a / which indicates a network path argument.
69 if(param
.length() > 0 && param
[0] == '/')
80 // Add the argument and reset the argv table in case strings were
82 m_Arguments
.push_back(value
);
84 m_Argv
.push_back(m_Argv0
.c_str());
85 for(unsigned int i
=0; i
< m_Arguments
.size(); ++i
)
87 m_Argv
.push_back(m_Arguments
[i
].c_str());
90 // Look for known flags.
93 this->m_LastUnknownParameter
= lpszParam
;
97 CString
sParam(lpszParam
);
98 // Single letter valued flag like /B=value or /B:value
100 if (sParam
[1] == '=' || sParam
[1] == ':')
102 value
= sParam
.Right(sParam
.GetLength() - 2);
106 value
= sParam
.Right(sParam
.GetLength()-1);
112 res
= CMakeCommandLineInfo::GetBoolValue(value
);
115 this->m_AdvancedValues
= TRUE
;
119 this->m_AdvancedValues
= FALSE
;
124 std::string path
= cmSystemTools::CollapseFullPath((const char*)value
);
125 this->m_WhereBuild
= path
.c_str();
129 this->m_GeneratorChoiceString
= value
;
133 std::string path
= cmSystemTools::CollapseFullPath((const char*)value
);
134 this->m_WhereSource
= path
.c_str();
140 // Call the base class to ensure proper command line processing
141 CCommandLineInfo::ParseParam(lpszParam
, bFlag
, bLast
);