FIX: added AddDefinition() to store site name and build name in makefile. Also stripped

white space from the result of hostname.
This commit is contained in:
Jim Miller 2001-06-25 13:34:09 -04:00
parent c40e8c5017
commit d2c2cf3296
2 changed files with 17 additions and 0 deletions

View File

@ -86,6 +86,8 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string>& args)
buildname.c_str(), buildname.c_str(),
"Name of build.", "Name of build.",
cmCacheManager::STRING); cmCacheManager::STRING);
m_Makefile->AddDefinition("BUILDNAME", buildname.c_str());
return true; return true;
} }

View File

@ -69,9 +69,22 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string>& args)
std::string host; std::string host;
cmSystemTools::RunCommand(hostname, cmSystemTools::RunCommand(hostname,
host); host);
if (host.length())
{
// remove any white space from the host name
std::string hostRegExp = "[ \t\n\r]*([^\t\n\r ]*)[ \t\n\r]*";
cmRegularExpression hostReg (hostRegExp.c_str());
if (hostReg.find(host.c_str()))
{
// strip whitespace
host = hostReg.match(1);
}
}
std::string siteName = host; std::string siteName = host;
if(host.length()) if(host.length())
{ {
// try to find the domain name for this computer
std::string nsCmd = nslookup; std::string nsCmd = nslookup;
nsCmd += " "; nsCmd += " ";
nsCmd += host; nsCmd += host;
@ -93,6 +106,8 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string>& args)
siteName.c_str(), siteName.c_str(),
"Name of the computer/site where compile is being run", "Name of the computer/site where compile is being run",
cmCacheManager::STRING); cmCacheManager::STRING);
m_Makefile->AddDefinition("SITE", siteName.c_str());
return true; return true;
} }