CMakeBuildTargets.cxx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "cmUnixMakefile.h"
  2. #include "cmMakeDepend.h"
  3. #include <iostream>
  4. // This is the main program used to gentrate makefile fragments
  5. // from CMakeLists.txt input files.
  6. main(int ac, char** av)
  7. {
  8. if(ac < 2)
  9. {
  10. std::cerr << "Usage: " << av[0] << " Makefile.in -Ipath ..." << std::endl;
  11. return -1;
  12. }
  13. // Create a unix makefile
  14. cmUnixMakefile mf;
  15. // Create a depends object
  16. cmMakeDepend md;
  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. // Read and parse the input makefile
  44. if(!mf.ReadMakefile(av[1]))
  45. {
  46. std::cerr << "Usage: " << av[0] << " Makefile.in -Ipath ..." << std::endl;
  47. return -1;
  48. }
  49. // Set the makefile object on the depend object
  50. md.SetMakefile(&mf);
  51. // compute the depend information
  52. md.DoDepends();
  53. // Ouput the result
  54. mf.OutputMakefile("CMakeTargets.make");
  55. }