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 "cmIncludeExternalMSProjectCommand.h"
14 // cmIncludeExternalMSProjectCommand
15 bool cmIncludeExternalMSProjectCommand
16 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
20 this->SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect "
21 "number of arguments");
24 // only compile this for win32 to avoid coverage errors
26 if(this->Makefile->GetDefinition("WIN32"))
28 enum Doing { DoingNone, DoingType, DoingGuid, DoingPlatform };
30 Doing doing = DoingNone;
32 std::string customType;
33 std::string customGuid;
34 std::string platformMapping;
36 std::vector<std::string> depends;
37 for (unsigned int i=2; i<args.size(); ++i)
39 if (args[i] == "TYPE")
43 else if (args[i] == "GUID")
47 else if (args[i] == "PLATFORM")
49 doing = DoingPlatform;
55 case DoingNone: depends.push_back(args[i]); break;
56 case DoingType: customType = args[i]; break;
57 case DoingGuid: customGuid = args[i]; break;
58 case DoingPlatform: platformMapping = args[i]; break;
64 // Hack together a utility target storing enough information
65 // to reproduce the target inclusion.
66 std::string utility_name = args[0];
68 std::string path = args[1];
69 cmSystemTools::ConvertToUnixSlashes(path);
71 if (!customGuid.empty())
73 std::string guidVariable = utility_name + "_GUID_CMAKE";
74 this->Makefile->GetCMakeInstance()->AddCacheEntry(
75 guidVariable.c_str(), customGuid.c_str(),
76 "Stored GUID", cmCacheManager::INTERNAL);
79 // Create a target instance for this utility.
80 cmTarget* target=this->Makefile->AddNewTarget(cmTarget::UTILITY,
81 utility_name.c_str());
83 target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str());
84 target->SetProperty("EXTERNAL_MSPROJECT", path.c_str());
85 target->SetProperty("EXCLUDE_FROM_ALL", "FALSE");
87 if (!customType.empty())
88 target->SetProperty("VS_PROJECT_TYPE",customType.c_str());
89 if (!platformMapping.empty())
90 target->SetProperty("VS_PLATFORM_MAPPING",platformMapping.c_str());
92 for (std::vector<std::string>::const_iterator it = depends.begin();
96 target->AddUtility(it->c_str());