cmProjectCommand.cxx 2.4 KB

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