packaging: Initial packaging
[platform/upstream/cmake.git] / Source / cmExternalMakefileProjectGenerator.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
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 <assert.h>
13
14 #include "cmExternalMakefileProjectGenerator.h"
15
16 std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
17                                                    const char* globalGenerator,
18                                                    const char* extraGenerator)
19 {
20   std::string fullName;
21   if (globalGenerator)
22     {
23     if (extraGenerator && *extraGenerator)
24       {
25       fullName = extraGenerator;
26       fullName += " - ";
27       }
28     fullName += globalGenerator;
29     }
30   return fullName;
31 }
32
33 const char* cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
34                                                           const char* fullName)
35 {
36   // at least one global generator must be supported
37   assert(!this->SupportedGlobalGenerators.empty());
38
39   if (fullName==0)
40     {
41     return 0;
42     }
43
44   std::string currentName = fullName;
45   // if we get only the short name, take the first global generator as default
46   if (currentName == this->GetName())
47     {
48     return this->SupportedGlobalGenerators[0].c_str();
49     }
50
51   // otherwise search for the matching global generator
52   for (std::vector<std::string>::const_iterator
53        it = this->SupportedGlobalGenerators.begin();
54        it != this->SupportedGlobalGenerators.end();
55        ++it)
56     {
57       if (this->CreateFullGeneratorName(it->c_str(), this->GetName())
58                                                                 == currentName)
59       {
60         return it->c_str();
61       }
62     }
63   return 0;
64 }