cmGetSourceFilePropertyCommand.cxx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 "cmGetSourceFilePropertyCommand.h"
  11. #include "cmSourceFile.h"
  12. // cmSetSourceFilePropertyCommand
  13. bool cmGetSourceFilePropertyCommand
  14. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  15. {
  16. if(args.size() != 3 )
  17. {
  18. this->SetError("called with incorrect number of arguments");
  19. return false;
  20. }
  21. const char* var = args[0].c_str();
  22. const char* file = args[1].c_str();
  23. cmSourceFile* sf = this->Makefile->GetSource(file);
  24. // for the location we must create a source file first
  25. if (!sf && args[2] == "LOCATION")
  26. {
  27. sf = this->Makefile->GetOrCreateSource(file);
  28. }
  29. if(sf)
  30. {
  31. if(args[2] == "LANGUAGE")
  32. {
  33. this->Makefile->AddDefinition(var, sf->GetLanguage());
  34. return true;
  35. }
  36. const char *prop = sf->GetPropertyForUser(args[2].c_str());
  37. if (prop)
  38. {
  39. this->Makefile->AddDefinition(var, prop);
  40. return true;
  41. }
  42. }
  43. this->Makefile->AddDefinition(var, "NOTFOUND");
  44. return true;
  45. }