CMakeBuildTargets.cxx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "cmMakefile.h"
  2. #include "cmStandardIncludes.h"
  3. #include "cmMakeDepend.h"
  4. #include "cmUnixMakefileGenerator.h"
  5. // This is the main program used to gentrate makefile fragments
  6. // from CMakeLists.txt input files.
  7. int main(int ac, char** av)
  8. {
  9. if(ac < 2)
  10. {
  11. std::cerr << "Usage: " << av[0] << " Makefile.in -Ipath ..." << std::endl;
  12. return -1;
  13. }
  14. // Create a makefile
  15. cmMakefile mf;
  16. mf.AddDefinition("UNIX", "1");
  17. // Parse the command line
  18. if(ac > 2)
  19. {
  20. for(int i =2; i < ac; i++)
  21. {
  22. std::string arg = av[i];
  23. // Set the current source directory with a -S dir options
  24. if(arg.find("-S",0) == 0)
  25. {
  26. std::string path = arg.substr(2);
  27. mf.SetCurrentDirectory(path.c_str());
  28. }
  29. // Set the output or binary directory with a -B dir option
  30. if(arg.find("-B",0) == 0)
  31. {
  32. std::string path = arg.substr(2);
  33. mf.SetOutputHomeDirectory(path.c_str());
  34. }
  35. // Set the source home directory with a -H dir option
  36. if(arg.find("-H",0) == 0)
  37. {
  38. std::string path = arg.substr(2);
  39. mf.SetHomeDirectory(path.c_str());
  40. }
  41. }
  42. }
  43. mf.SetMakefileGenerator(new cmUnixMakefileGenerator);
  44. // Read and parse the input makefile
  45. if(!mf.ReadMakefile(av[1]))
  46. {
  47. std::cerr << "Usage: " << av[0] << " Makefile.in -Ipath ..." << std::endl;
  48. return -1;
  49. }
  50. mf.GenerateMakefile();
  51. }