blob: f86955dd0caa3cd197905927d03d85e6883b3ded [file] [log] [blame]
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or for details. */
#include "cmLocalCommonGenerator.h"
#include <utility>
#include <vector>
#include "cmGeneratorTarget.h"
#include "cmMakefile.h"
#include "cmOutputConverter.h"
#include "cmStringAlgorithms.h"
class cmGlobalGenerator;
cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
cmMakefile* mf, std::string wd)
: cmLocalGenerator(gg, mf)
, WorkingDirectory(std::move(wd))
// Store the configuration name that will be generated.
if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) {
// Use the build type given by the user.
this->ConfigName = config;
} else {
// No configuration type given.
cmLocalCommonGenerator::~cmLocalCommonGenerator() = default;
std::string cmLocalCommonGenerator::GetTargetFortranFlags(
cmGeneratorTarget const* target, std::string const& config)
std::string flags;
// Enable module output if necessary.
flags, this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODOUT_FLAG"));
// Add a module output directory flag if necessary.
std::string mod_dir =
if (!mod_dir.empty()) {
mod_dir = this->ConvertToOutputFormat(
this->MaybeConvertToRelativePath(this->WorkingDirectory, mod_dir),
} else {
mod_dir =
if (!mod_dir.empty()) {
std::string modflag = cmStrCat(
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::string const& id : includes) {
std::string flg =
this->ConvertToOutputFormat(id, cmOutputConverter::SHELL));
this->AppendFlags(flags, flg);
return flags;
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);