2015-07-07 23:37:56 +03:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2015 Kitware, Inc., Insight Software Consortium
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
#include "cmLocalCommonGenerator.h"
|
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmGeneratorTarget.h"
|
2015-07-08 18:27:22 +03:00
|
|
|
#include "cmMakefile.h"
|
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class cmGlobalGenerator;
|
|
|
|
|
2016-08-27 19:32:49 +03:00
|
|
|
cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
|
|
|
|
cmMakefile* mf,
|
|
|
|
std::string const& wd)
|
2016-05-16 17:34:04 +03:00
|
|
|
: cmLocalGenerator(gg, mf)
|
2016-06-16 17:54:20 +03:00
|
|
|
, WorkingDirectory(wd)
|
2015-07-07 23:37:56 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cmLocalCommonGenerator::~cmLocalCommonGenerator()
|
|
|
|
{
|
|
|
|
}
|
2015-07-08 18:27:22 +03:00
|
|
|
|
|
|
|
void cmLocalCommonGenerator::SetConfigName()
|
|
|
|
{
|
|
|
|
// Store the configuration name that will be generated.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) {
|
2015-07-08 18:27:22 +03:00
|
|
|
// Use the build type given by the user.
|
|
|
|
this->ConfigName = config;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-07-08 18:27:22 +03:00
|
|
|
// No configuration type given.
|
|
|
|
this->ConfigName = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-08 18:27:22 +03:00
|
|
|
}
|
2016-06-16 18:14:18 +03:00
|
|
|
|
|
|
|
std::string cmLocalCommonGenerator::GetTargetFortranFlags(
|
|
|
|
cmGeneratorTarget const* target, std::string const& config)
|
|
|
|
{
|
|
|
|
std::string flags;
|
|
|
|
|
|
|
|
// Enable module output if necessary.
|
|
|
|
if (const char* modout_flag =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG")) {
|
|
|
|
this->AppendFlags(flags, modout_flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add a module output directory flag if necessary.
|
2016-09-19 22:36:00 +03:00
|
|
|
std::string mod_dir =
|
|
|
|
target->GetFortranModuleDirectory(this->WorkingDirectory);
|
2016-06-16 18:14:18 +03:00
|
|
|
if (!mod_dir.empty()) {
|
2016-08-27 19:32:49 +03:00
|
|
|
mod_dir = this->ConvertToOutputFormat(
|
|
|
|
this->ConvertToRelativePath(this->WorkingDirectory, mod_dir),
|
|
|
|
cmOutputConverter::SHELL);
|
2016-06-16 18:14:18 +03:00
|
|
|
} else {
|
|
|
|
mod_dir =
|
|
|
|
this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
|
|
|
|
}
|
|
|
|
if (!mod_dir.empty()) {
|
|
|
|
const char* moddir_flag =
|
|
|
|
this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG");
|
|
|
|
std::string modflag = moddir_flag;
|
|
|
|
modflag += mod_dir;
|
|
|
|
this->AppendFlags(flags, modflag);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there is a separate module path flag then duplicate the
|
|
|
|
// include path with it. This compiler does not search the include
|
|
|
|
// path for modules.
|
|
|
|
if (const char* modpath_flag =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) {
|
|
|
|
std::vector<std::string> includes;
|
|
|
|
this->GetIncludeDirectories(includes, target, "C", config);
|
|
|
|
for (std::vector<std::string>::const_iterator idi = includes.begin();
|
|
|
|
idi != includes.end(); ++idi) {
|
|
|
|
std::string flg = modpath_flag;
|
2016-08-27 14:44:55 +03:00
|
|
|
flg += this->ConvertToOutputFormat(*idi, cmOutputConverter::SHELL);
|
2016-06-16 18:14:18 +03:00
|
|
|
this->AppendFlags(flags, flg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
}
|