2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2001-05-04 19:34:59 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2001-05-04 19:34:59 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2001-05-04 19:34:59 +04:00
|
|
|
#include "cmBuildNameCommand.h"
|
|
|
|
|
2003-06-23 22:10:12 +04:00
|
|
|
#include <cmsys/RegularExpression.hxx>
|
|
|
|
|
2001-05-04 19:34:59 +04:00
|
|
|
// cmBuildNameCommand
|
2008-01-23 18:28:26 +03:00
|
|
|
bool cmBuildNameCommand
|
|
|
|
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
|
2001-05-04 19:34:59 +04:00
|
|
|
{
|
2013-10-21 21:12:18 +04:00
|
|
|
if(this->Disallowed(cmPolicies::CMP0036,
|
|
|
|
"The build_name command should not be called; see CMP0036."))
|
|
|
|
{ return true; }
|
2001-05-04 19:34:59 +04:00
|
|
|
if(args.size() < 1 )
|
|
|
|
{
|
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
|
|
|
}
|
2014-03-11 03:04:11 +04:00
|
|
|
const char* cacheValue = this->Makefile->GetDefinition(args[0]);
|
2001-05-04 19:34:59 +04:00
|
|
|
if(cacheValue)
|
|
|
|
{
|
2012-08-13 21:42:58 +04:00
|
|
|
// do we need to correct the value?
|
2003-06-23 22:10:12 +04:00
|
|
|
cmsys::RegularExpression reg("[()/]");
|
2001-07-10 17:23:34 +04:00
|
|
|
if (reg.find(cacheValue))
|
|
|
|
{
|
|
|
|
std::string cv = cacheValue;
|
|
|
|
cmSystemTools::ReplaceString(cv,"/", "_");
|
|
|
|
cmSystemTools::ReplaceString(cv,"(", "_");
|
|
|
|
cmSystemTools::ReplaceString(cv,")", "_");
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->AddCacheDefinition(args[0],
|
2001-08-08 19:54:46 +04:00
|
|
|
cv.c_str(),
|
|
|
|
"Name of build.",
|
2015-04-07 23:45:54 +03:00
|
|
|
cmState::STRING);
|
2001-07-10 17:23:34 +04:00
|
|
|
}
|
2001-05-04 19:34:59 +04:00
|
|
|
return true;
|
|
|
|
}
|
2001-07-10 17:23:34 +04:00
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2001-05-16 23:15:21 +04:00
|
|
|
std::string buildname = "WinNT";
|
2006-03-15 19:02:08 +03:00
|
|
|
if(this->Makefile->GetDefinition("UNIX"))
|
2001-05-04 19:34:59 +04:00
|
|
|
{
|
|
|
|
buildname = "";
|
2003-08-04 06:33:35 +04:00
|
|
|
cmSystemTools::RunSingleCommand("uname -a", &buildname);
|
2015-01-16 01:39:38 +03:00
|
|
|
if(!buildname.empty())
|
2001-05-05 00:44:24 +04:00
|
|
|
{
|
|
|
|
std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
|
2003-06-23 22:10:12 +04:00
|
|
|
cmsys::RegularExpression reg( RegExp.c_str() );
|
2001-05-05 00:44:24 +04:00
|
|
|
if(reg.find(buildname.c_str()))
|
2002-10-24 02:03:27 +04:00
|
|
|
{
|
|
|
|
buildname = reg.match(1) + "-" + reg.match(2);
|
|
|
|
}
|
2001-05-05 00:44:24 +04:00
|
|
|
}
|
2001-05-04 19:34:59 +04:00
|
|
|
}
|
2002-04-26 17:55:32 +04:00
|
|
|
std::string compiler = "${CMAKE_CXX_COMPILER}";
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Makefile->ExpandVariablesInString ( compiler );
|
2002-04-26 17:55:32 +04:00
|
|
|
buildname += "-";
|
2001-07-03 00:30:40 +04:00
|
|
|
buildname += cmSystemTools::GetFilenameName(compiler);
|
|
|
|
cmSystemTools::ReplaceString(buildname,
|
|
|
|
"/", "_");
|
|
|
|
cmSystemTools::ReplaceString(buildname,
|
|
|
|
"(", "_");
|
|
|
|
cmSystemTools::ReplaceString(buildname,
|
|
|
|
")", "_");
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->AddCacheDefinition(args[0],
|
2001-08-08 19:54:46 +04:00
|
|
|
buildname.c_str(),
|
|
|
|
"Name of build.",
|
2015-04-07 23:45:54 +03:00
|
|
|
cmState::STRING);
|
2001-05-04 19:34:59 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|