cmIncludeExternalMSProjectCommand.cxx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmIncludeExternalMSProjectCommand.h"
  14. // cmIncludeExternalMSProjectCommand
  15. bool cmIncludeExternalMSProjectCommand
  16. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  17. {
  18. if(args.size() < 2)
  19. {
  20. this->SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect "
  21. "number of arguments");
  22. return false;
  23. }
  24. // only compile this for win32 to avoid coverage errors
  25. #ifdef _WIN32
  26. if(this->Makefile->GetDefinition("WIN32"))
  27. {
  28. std::string location = args[1];
  29. std::vector<std::string> depends;
  30. if (args.size() > 2)
  31. {
  32. for (unsigned int i=2; i<args.size(); ++i)
  33. {
  34. depends.push_back(args[i]);
  35. }
  36. }
  37. // Hack together a utility target storing enough information
  38. // to reproduce the target inclusion.
  39. std::string utility_name("INCLUDE_EXTERNAL_MSPROJECT");
  40. utility_name += "_";
  41. utility_name += args[0];
  42. std::string path = args[1];
  43. cmSystemTools::ConvertToUnixSlashes(path);
  44. // Create a target instance for this utility.
  45. cmTarget* target=this->Makefile->AddNewTarget(cmTarget::UTILITY,
  46. utility_name.c_str());
  47. target->SetProperty("EXCLUDE_FROM_ALL","FALSE");
  48. std::vector<std::string> no_outputs;
  49. cmCustomCommandLines commandLines;
  50. cmCustomCommandLine commandLine;
  51. commandLine.push_back(args[0]);
  52. commandLine.push_back(path);
  53. commandLines.push_back(commandLine);
  54. cmCustomCommand cc(no_outputs, depends, commandLines, 0, 0);
  55. target->GetPostBuildCommands().push_back(cc);
  56. }
  57. #endif
  58. return true;
  59. }