1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmBuildNameCommand.cxx,v $
6 Date: $Date: 2008/01/23 15:27:59 $
7 Version: $Revision: 1.19 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmBuildNameCommand.h"
19 #include <cmsys/RegularExpression.hxx>
22 bool cmBuildNameCommand
23 ::InitialPass(std::vector
<std::string
> const& args
, cmExecutionStatus
&)
27 this->SetError("called with incorrect number of arguments");
30 const char* cacheValue
= this->Makefile
->GetDefinition(args
[0].c_str());
33 // do we need to correct the value?
34 cmsys::RegularExpression
reg("[()/]");
35 if (reg
.find(cacheValue
))
37 std::string cv
= cacheValue
;
38 cmSystemTools::ReplaceString(cv
,"/", "_");
39 cmSystemTools::ReplaceString(cv
,"(", "_");
40 cmSystemTools::ReplaceString(cv
,")", "_");
41 this->Makefile
->AddCacheDefinition(args
[0].c_str(),
44 cmCacheManager::STRING
);
50 std::string buildname
= "WinNT";
51 if(this->Makefile
->GetDefinition("UNIX"))
54 cmSystemTools::RunSingleCommand("uname -a", &buildname
);
55 if(buildname
.length())
57 std::string RegExp
= "([^ ]*) [^ ]* ([^ ]*) ";
58 cmsys::RegularExpression
reg( RegExp
.c_str() );
59 if(reg
.find(buildname
.c_str()))
61 buildname
= reg
.match(1) + "-" + reg
.match(2);
65 std::string compiler
= "${CMAKE_CXX_COMPILER}";
66 this->Makefile
->ExpandVariablesInString ( compiler
);
68 buildname
+= cmSystemTools::GetFilenameName(compiler
);
69 cmSystemTools::ReplaceString(buildname
,
71 cmSystemTools::ReplaceString(buildname
,
73 cmSystemTools::ReplaceString(buildname
,
76 this->Makefile
->AddCacheDefinition(args
[0].c_str(),
79 cmCacheManager::STRING
);