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.

90 lines
2.2 KiB

  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. bool importTarget = false;
  29. while ( s != args.end() )
  30. {
  31. if (*s == "WIN32")
  32. {
  33. ++s;
  34. use_win32 = true;
  35. }
  36. else if ( *s == "MACOSX_BUNDLE" )
  37. {
  38. ++s;
  39. use_macbundle = true;
  40. }
  41. else if(*s == "EXCLUDE_FROM_ALL")
  42. {
  43. ++s;
  44. excludeFromAll = true;
  45. }
  46. else if(*s == "IMPORT")
  47. {
  48. ++s;
  49. importTarget = true;
  50. }
  51. else
  52. {
  53. break;
  54. }
  55. }
  56. if (importTarget)
  57. {
  58. this->Makefile->AddNewTarget(cmTarget::EXECUTABLE, exename.c_str(), true);
  59. return true;
  60. }
  61. if (s == args.end())
  62. {
  63. this->SetError
  64. ("called with incorrect number of arguments, no sources provided");
  65. return false;
  66. }
  67. std::vector<std::string> srclists(s, args.end());
  68. cmTarget* tgt = this->Makefile->AddExecutable(exename.c_str(), srclists,
  69. excludeFromAll);
  70. if ( use_win32 )
  71. {
  72. tgt->SetProperty("WIN32_EXECUTABLE", "ON");
  73. }
  74. if ( use_macbundle)
  75. {
  76. tgt->SetProperty("MACOSX_BUNDLE", "ON");
  77. }
  78. return true;
  79. }