cmBuildCommand.cxx 1.7 KB

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