cmAddExecutableCommand.cxx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "cmAddExecutableCommand.h"
  14. // cmExecutableCommand
  15. bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args)
  16. {
  17. if(args.size() < 2 )
  18. {
  19. this->SetError("called with incorrect number of arguments");
  20. return false;
  21. }
  22. std::vector<std::string>::const_iterator s = args.begin();
  23. std::string exename = *s;
  24. ++s;
  25. bool use_win32 = false;
  26. bool use_macbundle = false;
  27. bool excludeFromAll = false;
  28. while ( s != args.end() )
  29. {
  30. if (*s == "WIN32")
  31. {
  32. ++s;
  33. use_win32 = true;
  34. }
  35. else if ( *s == "MACOSX_BUNDLE" )
  36. {
  37. ++s;
  38. use_macbundle = true;
  39. }
  40. else if(*s == "EXCLUDE_FROM_ALL")
  41. {
  42. ++s;
  43. excludeFromAll = true;
  44. }
  45. else
  46. {
  47. break;
  48. }
  49. }
  50. if (s == args.end())
  51. {
  52. this->SetError
  53. ("called with incorrect number of arguments, no sources provided");
  54. return false;
  55. }
  56. std::vector<std::string> srclists(s, args.end());
  57. cmTarget* tgt = this->Makefile->AddExecutable(exename.c_str(), srclists,
  58. excludeFromAll);
  59. if ( use_win32 )
  60. {
  61. tgt->SetProperty("WIN32_EXECUTABLE", "ON");
  62. }
  63. if ( use_macbundle)
  64. {
  65. tgt->SetProperty("MACOSX_BUNDLE", "ON");
  66. }
  67. return true;
  68. }