cmAddExecutableCommand.cxx 2.2 KB

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