cmLocalCommonGenerator.cxx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2015 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 "cmLocalCommonGenerator.h"
  11. #include "cmGeneratorTarget.h"
  12. #include "cmMakefile.h"
  13. #include <vector>
  14. class cmGlobalGenerator;
  15. cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
  16. cmMakefile* mf,
  17. std::string const& wd)
  18. : cmLocalGenerator(gg, mf)
  19. , WorkingDirectory(wd)
  20. {
  21. }
  22. cmLocalCommonGenerator::~cmLocalCommonGenerator()
  23. {
  24. }
  25. void cmLocalCommonGenerator::SetConfigName()
  26. {
  27. // Store the configuration name that will be generated.
  28. if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) {
  29. // Use the build type given by the user.
  30. this->ConfigName = config;
  31. } else {
  32. // No configuration type given.
  33. this->ConfigName = "";
  34. }
  35. }
  36. std::string cmLocalCommonGenerator::GetTargetFortranFlags(
  37. cmGeneratorTarget const* target, std::string const& config)
  38. {
  39. std::string flags;
  40. // Enable module output if necessary.
  41. if (const char* modout_flag =
  42. this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG")) {
  43. this->AppendFlags(flags, modout_flag);
  44. }
  45. // Add a module output directory flag if necessary.
  46. std::string mod_dir = target->GetFortranModuleDirectory();
  47. if (!mod_dir.empty()) {
  48. mod_dir = this->ConvertToOutputFormat(
  49. this->ConvertToRelativePath(this->WorkingDirectory, mod_dir),
  50. cmOutputConverter::SHELL);
  51. } else {
  52. mod_dir =
  53. this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
  54. }
  55. if (!mod_dir.empty()) {
  56. const char* moddir_flag =
  57. this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG");
  58. std::string modflag = moddir_flag;
  59. modflag += mod_dir;
  60. this->AppendFlags(flags, modflag);
  61. }
  62. // If there is a separate module path flag then duplicate the
  63. // include path with it. This compiler does not search the include
  64. // path for modules.
  65. if (const char* modpath_flag =
  66. this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) {
  67. std::vector<std::string> includes;
  68. this->GetIncludeDirectories(includes, target, "C", config);
  69. for (std::vector<std::string>::const_iterator idi = includes.begin();
  70. idi != includes.end(); ++idi) {
  71. std::string flg = modpath_flag;
  72. flg += this->ConvertToOutputFormat(*idi, cmOutputConverter::SHELL);
  73. this->AppendFlags(flags, flg);
  74. }
  75. }
  76. return flags;
  77. }