cmBuildCommand.cxx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 "cmBuildCommand.h"
  14. #include "cmLocalGenerator.h"
  15. #include "cmGlobalGenerator.h"
  16. // cmBuildCommand
  17. bool cmBuildCommand
  18. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  19. {
  20. if(args.size() < 2 )
  21. {
  22. this->SetError("called with incorrect number of arguments");
  23. return false;
  24. }
  25. const char* define = args[0].c_str();
  26. const char* cacheValue
  27. = this->Makefile->GetDefinition(define);
  28. std::string makeprogram = args[1];
  29. std::string configType = "Release";
  30. const char* cfg = getenv("CMAKE_CONFIG_TYPE");
  31. if ( cfg )
  32. {
  33. configType = cfg;
  34. }
  35. std::string makecommand = this->Makefile->GetLocalGenerator()
  36. ->GetGlobalGenerator()->GenerateBuildCommand
  37. (makeprogram.c_str(), this->Makefile->GetProjectName(), 0,
  38. 0, configType.c_str(), true, false);
  39. if(cacheValue)
  40. {
  41. return true;
  42. }
  43. this->Makefile->AddCacheDefinition(define,
  44. makecommand.c_str(),
  45. "Command used to build entire project "
  46. "from the command line.",
  47. cmCacheManager::STRING);
  48. return true;
  49. }