cmProjectCommand.cxx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmProjectCommand.h"
  11. // cmProjectCommand
  12. bool cmProjectCommand
  13. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  14. {
  15. if(args.size() < 1 )
  16. {
  17. this->SetError("PROJECT called with incorrect number of arguments");
  18. return false;
  19. }
  20. this->Makefile->SetProjectName(args[0].c_str());
  21. std::string bindir = args[0];
  22. bindir += "_BINARY_DIR";
  23. std::string srcdir = args[0];
  24. srcdir += "_SOURCE_DIR";
  25. this->Makefile->AddCacheDefinition
  26. (bindir.c_str(),
  27. this->Makefile->GetCurrentOutputDirectory(),
  28. "Value Computed by CMake", cmCacheManager::STATIC);
  29. this->Makefile->AddCacheDefinition
  30. (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. this->Makefile->AddCacheDefinition
  47. ("CMAKE_PROJECT_NAME",
  48. args[0].c_str(),
  49. "Value Computed by CMake", cmCacheManager::STATIC);
  50. }
  51. std::vector<std::string> languages;
  52. if(args.size() > 1)
  53. {
  54. for(size_t i =1; i < args.size(); ++i)
  55. {
  56. languages.push_back(args[i]);
  57. }
  58. }
  59. else
  60. {
  61. // if no language is specified do c and c++
  62. languages.push_back("C");
  63. languages.push_back("CXX");
  64. }
  65. this->Makefile->EnableLanguage(languages, false);
  66. return true;
  67. }