cmProjectCommand.cxx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. std::vector<std::string> languages;
  41. if(args.size() > 1)
  42. {
  43. for(size_t i =1; i < args.size(); ++i)
  44. {
  45. languages.push_back(args[i]);
  46. }
  47. }
  48. else
  49. {
  50. // if no language is specified do c and c++
  51. languages.push_back("C");
  52. languages.push_back("CXX");
  53. }
  54. m_Makefile->EnableLanguage(languages);
  55. return true;
  56. }