cmIncludeExternalMSProjectCommand.cxx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmIncludeExternalMSProjectCommand.h"
  11. // cmIncludeExternalMSProjectCommand
  12. bool cmIncludeExternalMSProjectCommand
  13. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  14. {
  15. if(args.size() < 2)
  16. {
  17. this->SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect "
  18. "number of arguments");
  19. return false;
  20. }
  21. // only compile this for win32 to avoid coverage errors
  22. #ifdef _WIN32
  23. if(this->Makefile->GetDefinition("WIN32"))
  24. {
  25. enum Doing { DoingNone, DoingType, DoingGuid, DoingPlatform };
  26. Doing doing = DoingNone;
  27. std::string customType;
  28. std::string customGuid;
  29. std::string platformMapping;
  30. std::vector<std::string> depends;
  31. for (unsigned int i=2; i<args.size(); ++i)
  32. {
  33. if (args[i] == "TYPE")
  34. {
  35. doing = DoingType;
  36. }
  37. else if (args[i] == "GUID")
  38. {
  39. doing = DoingGuid;
  40. }
  41. else if (args[i] == "PLATFORM")
  42. {
  43. doing = DoingPlatform;
  44. }
  45. else
  46. {
  47. switch (doing)
  48. {
  49. case DoingNone: depends.push_back(args[i]); break;
  50. case DoingType: customType = args[i]; break;
  51. case DoingGuid: customGuid = args[i]; break;
  52. case DoingPlatform: platformMapping = args[i]; break;
  53. }
  54. doing = DoingNone;
  55. }
  56. }
  57. // Hack together a utility target storing enough information
  58. // to reproduce the target inclusion.
  59. std::string utility_name = args[0];
  60. std::string path = args[1];
  61. cmSystemTools::ConvertToUnixSlashes(path);
  62. if (!customGuid.empty())
  63. {
  64. std::string guidVariable = utility_name + "_GUID_CMAKE";
  65. this->Makefile->GetCMakeInstance()->AddCacheEntry(
  66. guidVariable.c_str(), customGuid.c_str(),
  67. "Stored GUID", cmState::INTERNAL);
  68. }
  69. // Create a target instance for this utility.
  70. cmTarget* target=this->Makefile->AddNewTarget(cmState::UTILITY,
  71. utility_name.c_str());
  72. target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str());
  73. target->SetProperty("EXTERNAL_MSPROJECT", path.c_str());
  74. target->SetProperty("EXCLUDE_FROM_ALL", "FALSE");
  75. if (!customType.empty())
  76. target->SetProperty("VS_PROJECT_TYPE",customType.c_str());
  77. if (!platformMapping.empty())
  78. target->SetProperty("VS_PLATFORM_MAPPING",platformMapping.c_str());
  79. for (std::vector<std::string>::const_iterator it = depends.begin();
  80. it != depends.end();
  81. ++it)
  82. {
  83. target->AddUtility(it->c_str());
  84. }
  85. }
  86. #endif
  87. return true;
  88. }