1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmBuildNameCommand.h"
14 #include <cmsys/RegularExpression.hxx>
17 bool cmBuildNameCommand
18 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
22 this->SetError("called with incorrect number of arguments");
25 const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str());
28 // do we need to correct the value?
29 cmsys::RegularExpression reg("[()/]");
30 if (reg.find(cacheValue))
32 std::string cv = cacheValue;
33 cmSystemTools::ReplaceString(cv,"/", "_");
34 cmSystemTools::ReplaceString(cv,"(", "_");
35 cmSystemTools::ReplaceString(cv,")", "_");
36 this->Makefile->AddCacheDefinition(args[0].c_str(),
39 cmCacheManager::STRING);
45 std::string buildname = "WinNT";
46 if(this->Makefile->GetDefinition("UNIX"))
49 cmSystemTools::RunSingleCommand("uname -a", &buildname);
50 if(buildname.length())
52 std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
53 cmsys::RegularExpression reg( RegExp.c_str() );
54 if(reg.find(buildname.c_str()))
56 buildname = reg.match(1) + "-" + reg.match(2);
60 std::string compiler = "${CMAKE_CXX_COMPILER}";
61 this->Makefile->ExpandVariablesInString ( compiler );
63 buildname += cmSystemTools::GetFilenameName(compiler);
64 cmSystemTools::ReplaceString(buildname,
66 cmSystemTools::ReplaceString(buildname,
68 cmSystemTools::ReplaceString(buildname,
71 this->Makefile->AddCacheDefinition(args[0].c_str(),
74 cmCacheManager::STRING);