cmProjectCommand.cxx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. this->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. this->Makefile->AddCacheDefinition(bindir.c_str(),
  28. this->Makefile->GetCurrentOutputDirectory(),
  29. "Value Computed by CMake", cmCacheManager::STATIC);
  30. this->Makefile->AddCacheDefinition(srcdir.c_str(),
  31. this->Makefile->GetCurrentDirectory(),
  32. "Value Computed by CMake", cmCacheManager::STATIC);
  33. bindir = "PROJECT_BINARY_DIR";
  34. srcdir = "PROJECT_SOURCE_DIR";
  35. this->Makefile->AddDefinition(bindir.c_str(),
  36. this->Makefile->GetCurrentOutputDirectory());
  37. this->Makefile->AddDefinition(srcdir.c_str(),
  38. this->Makefile->GetCurrentDirectory());
  39. this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str());
  40. // Set the CMAKE_PROJECT_NAME variable to be the highest-level
  41. // project name in the tree. This is always the first PROJECT
  42. // command encountered.
  43. if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME"))
  44. {
  45. this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str());
  46. }
  47. std::vector<std::string> languages;
  48. if(args.size() > 1)
  49. {
  50. for(size_t i =1; i < args.size(); ++i)
  51. {
  52. languages.push_back(args[i]);
  53. }
  54. }
  55. else
  56. {
  57. // if no language is specified do c and c++
  58. languages.push_back("C");
  59. languages.push_back("CXX");
  60. }
  61. this->Makefile->EnableLanguage(languages);
  62. return true;
  63. }