You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.1 KiB

22 years ago
  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 "cmGetSourceFilePropertyCommand.h"
  14. #include "cmSourceFile.h"
  15. // cmSetSourceFilePropertyCommand
  16. bool cmGetSourceFilePropertyCommand::InitialPass(
  17. std::vector<std::string> const& args)
  18. {
  19. if(args.size() != 3 )
  20. {
  21. this->SetError("called with incorrect number of arguments");
  22. return false;
  23. }
  24. const char* var = args[0].c_str();
  25. const char* file = args[1].c_str();
  26. cmSourceFile* sf = this->Makefile->GetSource(file);
  27. // for the location we must create a source file first
  28. if (!sf && args[2] == "LOCATION")
  29. {
  30. sf = this->Makefile->GetOrCreateSource(file);
  31. }
  32. if(sf)
  33. {
  34. if(args[2] == "LOCATION")
  35. {
  36. // Make sure the location is known. Update: this is a hack to work
  37. // around a problem with const methods in cmSourceFile, by design
  38. // GetProperty("LOCATION") should work but right now it has to be
  39. // "primed" by calling GetFullPath() first on a non-const cmSourceFile
  40. // instance. This is because LOCATION is a computed-on-demand
  41. // property. Either GetProperty needs to be non-const or the map
  42. // needs to be changed to be mutable etc. for computed properties to
  43. // work properly.
  44. sf->GetFullPath();
  45. }
  46. const char *prop = sf->GetProperty(args[2].c_str());
  47. if (prop)
  48. {
  49. this->Makefile->AddDefinition(var, prop);
  50. return true;
  51. }
  52. }
  53. this->Makefile->AddDefinition(var, "NOTFOUND");
  54. return true;
  55. }