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
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
cmExecutionStatus&)
|
2001-05-04 19:34:59 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Disallowed(
|
|
|
|
cmPolicies::CMP0036,
|
|
|
|
"The build_name command should not be called; see CMP0036.")) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (args.size() < 1) {
|
2001-05-04 19:34:59 +04:00
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-11 03:04:11 +04:00
|
|
|
const char* cacheValue = this->Makefile->GetDefinition(args[0]);
|
2016-05-16 17:34:04 +03: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("[()/]");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (reg.find(cacheValue)) {
|
2001-07-10 17:23:34 +04:00
|
|
|
std::string cv = cacheValue;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ReplaceString(cv, "/", "_");
|
|
|
|
cmSystemTools::ReplaceString(cv, "(", "_");
|
|
|
|
cmSystemTools::ReplaceString(cv, ")", "_");
|
|
|
|
this->Makefile->AddCacheDefinition(args[0], cv.c_str(), "Name of build.",
|
|
|
|
cmState::STRING);
|
2001-05-04 19:34:59 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return true;
|
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2001-05-16 23:15:21 +04:00
|
|
|
std::string buildname = "WinNT";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->GetDefinition("UNIX")) {
|
2001-05-04 19:34:59 +04:00
|
|
|
buildname = "";
|
2015-04-20 22:36:57 +03:00
|
|
|
cmSystemTools::RunSingleCommand("uname -a", &buildname, &buildname);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!buildname.empty()) {
|
2001-05-05 00:44:24 +04:00
|
|
|
std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
|
2016-05-16 17:34:04 +03:00
|
|
|
cmsys::RegularExpression reg(RegExp.c_str());
|
|
|
|
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
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-04-26 17:55:32 +04:00
|
|
|
std::string compiler = "${CMAKE_CXX_COMPILER}";
|
2016-05-16 17:34:04 +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);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ReplaceString(buildname, "/", "_");
|
|
|
|
cmSystemTools::ReplaceString(buildname, "(", "_");
|
|
|
|
cmSystemTools::ReplaceString(buildname, ")", "_");
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddCacheDefinition(args[0], buildname.c_str(),
|
|
|
|
"Name of build.", cmState::STRING);
|
2001-05-04 19:34:59 +04:00
|
|
|
return true;
|
|
|
|
}
|