cmProjectCommand.cxx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 "cmProjectCommand.h"
  14. // cmProjectCommand
  15. bool cmProjectCommand::InitialPass(std::vector<std::string> const& argsIn)
  16. {
  17. if(argsIn.size() < 1 )
  18. {
  19. this->SetError("PROJECT called with incorrect number of arguments");
  20. return false;
  21. }
  22. std::vector<std::string> args;
  23. cmSystemTools::ExpandListArguments(argsIn, args);
  24. m_Makefile->SetProjectName(args[0].c_str());
  25. std::string bindir = args[0];
  26. bindir += "_BINARY_DIR";
  27. std::string srcdir = args[0];
  28. srcdir += "_SOURCE_DIR";
  29. m_Makefile->AddCacheDefinition(bindir.c_str(),
  30. m_Makefile->GetCurrentOutputDirectory(),
  31. "Value Computed by CMake", cmCacheManager::STATIC);
  32. m_Makefile->AddCacheDefinition(srcdir.c_str(),
  33. m_Makefile->GetCurrentDirectory(),
  34. "Value Computed by CMake", cmCacheManager::STATIC);
  35. bindir = "PROJECT_BINARY_DIR";
  36. srcdir = "PROJECT_SOURCE_DIR";
  37. m_Makefile->AddDefinition(bindir.c_str(),
  38. m_Makefile->GetCurrentOutputDirectory());
  39. m_Makefile->AddDefinition(srcdir.c_str(),
  40. m_Makefile->GetCurrentDirectory());
  41. m_Makefile->AddDefinition("PROJECT_NAME", args[0].c_str());
  42. if(args.size() > 1)
  43. {
  44. for(size_t i =1; i < args.size(); ++i)
  45. {
  46. m_Makefile->EnableLanguage(args[i].c_str());
  47. }
  48. }
  49. else
  50. {
  51. m_Makefile->EnableLanguage(0);
  52. }
  53. return true;
  54. }