cmGetTargetPropertyCommand.cxx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 "cmGetTargetPropertyCommand.h"
  14. // cmSetTargetPropertyCommand
  15. bool cmGetTargetPropertyCommand::InitialPass(
  16. std::vector<std::string> const& args)
  17. {
  18. if(args.size() != 3 )
  19. {
  20. this->SetError("called with incorrect number of arguments");
  21. return false;
  22. }
  23. const char* var = args[0].c_str();
  24. const char* targetName = args[1].c_str();
  25. cmTargets& targets = m_Makefile->GetTargets();
  26. cmTargets::iterator i = targets.find(targetName);
  27. if ( i != targets.end())
  28. {
  29. cmTarget& target = i->second;
  30. if ( args[2] == "LOCATION" )
  31. {
  32. std::string target_location;
  33. switch( target.GetType() )
  34. {
  35. case cmTarget::STATIC_LIBRARY:
  36. case cmTarget::MODULE_LIBRARY:
  37. case cmTarget::SHARED_LIBRARY:
  38. target_location = m_Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
  39. break;
  40. case cmTarget::EXECUTABLE:
  41. target_location = m_Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
  42. break;
  43. default:
  44. m_Makefile->AddDefinition(var, "NOTFOUND");
  45. return true;
  46. }
  47. if ( target_location.size() == 0 )
  48. {
  49. target_location += m_Makefile->GetCurrentOutputDirectory();
  50. }
  51. if ( target_location.size() > 0 )
  52. {
  53. target_location += "/";
  54. }
  55. const char* cfgid = m_Makefile->GetDefinition("CMAKE_CFG_INTDIR");
  56. if ( cfgid && strcmp(cfgid, ".") != 0 )
  57. {
  58. target_location += cfgid;
  59. target_location += "/";
  60. }
  61. cmLocalGenerator* lg = m_Makefile->GetLocalGenerator();
  62. target_location += lg->GetFullTargetName(targetName, target);
  63. m_Makefile->AddDefinition(var, target_location.c_str());
  64. return true;
  65. }
  66. else
  67. {
  68. const char *prop = target.GetProperty(args[2].c_str());
  69. if (prop)
  70. {
  71. m_Makefile->AddDefinition(var, prop);
  72. return true;
  73. }
  74. }
  75. }
  76. m_Makefile->AddDefinition(var, "NOTFOUND");
  77. return true;
  78. }