cmLocalCommonGenerator.cxx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 =
  47. target->GetFortranModuleDirectory(this->WorkingDirectory);
  48. if (!mod_dir.empty()) {
  49. mod_dir = this->ConvertToOutputFormat(
  50. this->ConvertToRelativePath(this->WorkingDirectory, mod_dir),
  51. cmOutputConverter::SHELL);
  52. } else {
  53. mod_dir =
  54. this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
  55. }
  56. if (!mod_dir.empty()) {
  57. const char* moddir_flag =
  58. this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG");
  59. std::string modflag = moddir_flag;
  60. modflag += mod_dir;
  61. this->AppendFlags(flags, modflag);
  62. }
  63. // If there is a separate module path flag then duplicate the
  64. // include path with it. This compiler does not search the include
  65. // path for modules.
  66. if (const char* modpath_flag =
  67. this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) {
  68. std::vector<std::string> includes;
  69. this->GetIncludeDirectories(includes, target, "C", config);
  70. for (std::vector<std::string>::const_iterator idi = includes.begin();
  71. idi != includes.end(); ++idi) {
  72. std::string flg = modpath_flag;
  73. flg += this->ConvertToOutputFormat(*idi, cmOutputConverter::SHELL);
  74. this->AppendFlags(flags, flg);
  75. }
  76. }
  77. return flags;
  78. }