cmGetSourceFilePropertyCommand.cxx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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->CreateSource(file);
  28. }
  29. if(sf)
  30. {
  31. if(args[2] == "LANGUAGE")
  32. {
  33. this->Makefile->AddDefinition(var, sf->GetLanguage().c_str());
  34. return true;
  35. }
  36. const char *prop = 0;
  37. if (!args[2].empty())
  38. {
  39. prop = sf->GetPropertyForUser(args[2]);
  40. }
  41. if (prop)
  42. {
  43. this->Makefile->AddDefinition(var, prop);
  44. return true;
  45. }
  46. }
  47. this->Makefile->AddDefinition(var, "NOTFOUND");
  48. return true;
  49. }