cmake/Source/cmLocalCommonGenerator.cxx

94 lines
2.9 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2015-11-17 17:22:37 +01:00
#include "cmLocalCommonGenerator.h"
2018-04-23 21:13:27 +02:00
#include <utility>
2017-04-14 19:02:05 +02:00
#include <vector>
2016-10-30 18:24:19 +01:00
#include "cmGeneratorTarget.h"
2015-11-17 17:22:37 +01:00
#include "cmMakefile.h"
2017-04-14 19:02:05 +02:00
#include "cmOutputConverter.h"
2016-10-30 18:24:19 +01:00
class cmGlobalGenerator;
2015-11-17 17:22:37 +01:00
cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
2016-10-30 18:24:19 +01:00
cmMakefile* mf,
std::string const& wd)
2016-07-09 11:21:54 +02:00
: cmLocalGenerator(gg, mf)
2016-10-30 18:24:19 +01:00
, WorkingDirectory(wd)
2015-11-17 17:22:37 +01:00
{
// Store the configuration name that will be generated.
2016-07-09 11:21:54 +02:00
if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) {
2015-11-17 17:22:37 +01:00
// Use the build type given by the user.
this->ConfigName = config;
2016-07-09 11:21:54 +02:00
} else {
2015-11-17 17:22:37 +01:00
// No configuration type given.
2018-01-26 17:06:56 +01:00
this->ConfigName.clear();
2016-07-09 11:21:54 +02:00
}
2015-11-17 17:22:37 +01:00
}
2016-10-30 18:24:19 +01:00
2017-07-20 19:35:53 +02:00
cmLocalCommonGenerator::~cmLocalCommonGenerator()
{
}
2016-10-30 18:24:19 +01: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.
std::string mod_dir =
target->GetFortranModuleDirectory(this->WorkingDirectory);
if (!mod_dir.empty()) {
mod_dir = this->ConvertToOutputFormat(
this->ConvertToRelativePath(this->WorkingDirectory, mod_dir),
cmOutputConverter::SHELL);
} 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);
2018-01-26 17:06:56 +01:00
for (std::string const& id : includes) {
2016-10-30 18:24:19 +01:00
std::string flg = modpath_flag;
2018-01-26 17:06:56 +01:00
flg += this->ConvertToOutputFormat(id, cmOutputConverter::SHELL);
2016-10-30 18:24:19 +01:00
this->AppendFlags(flags, flg);
}
}
return flags;
}
2018-04-23 21:13:27 +02:00
void cmLocalCommonGenerator::ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping,
cmGeneratorTarget const* gt)
{
// Determine if these object files should use a custom extension
char const* custom_ext = gt->GetCustomObjectExtension();
for (auto& si : mapping) {
cmSourceFile const* sf = si.first;
bool keptSourceExtension;
si.second = this->GetObjectFileNameWithoutTarget(
*sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext);
}
}