cmLocalCommonGenerator.cxx 2.7 KB

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