cmProjectCommand.cxx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 "cmProjectCommand.h"
  14. // cmProjectCommand
  15. bool cmProjectCommand::InitialPass(std::vector<std::string> const& args)
  16. {
  17. if(args.size() < 1 )
  18. {
  19. this->SetError("PROJECT called with incorrect number of arguments");
  20. return false;
  21. }
  22. m_Makefile->SetProjectName(args[0].c_str());
  23. std::string bindir = args[0];
  24. bindir += "_BINARY_DIR";
  25. std::string srcdir = args[0];
  26. srcdir += "_SOURCE_DIR";
  27. m_Makefile->AddCacheDefinition(bindir.c_str(),
  28. m_Makefile->GetCurrentOutputDirectory(),
  29. "Value Computed by CMake", cmCacheManager::STATIC);
  30. m_Makefile->AddCacheDefinition(srcdir.c_str(),
  31. m_Makefile->GetCurrentDirectory(),
  32. "Value Computed by CMake", cmCacheManager::STATIC);
  33. bindir = "PROJECT_BINARY_DIR";
  34. srcdir = "PROJECT_SOURCE_DIR";
  35. m_Makefile->AddDefinition(bindir.c_str(),
  36. m_Makefile->GetCurrentOutputDirectory());
  37. m_Makefile->AddDefinition(srcdir.c_str(),
  38. m_Makefile->GetCurrentDirectory());
  39. m_Makefile->AddDefinition("PROJECT_NAME", args[0].c_str());
  40. if(args.size() > 1)
  41. {
  42. for(size_t i =1; i < args.size(); ++i)
  43. {
  44. m_Makefile->EnableLanguage(args[i].c_str());
  45. }
  46. }
  47. else
  48. {
  49. m_Makefile->EnableLanguage(0);
  50. }
  51. return true;
  52. }