diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmDocumentVariables.cxx | 9 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 22 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 25 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 8 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 38 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 35 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmSourceFile.cxx | 9 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 12 |
9 files changed, 158 insertions, 2 deletions
diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 26125d9..f2b01f1 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1049,6 +1049,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables that Control the Build"); cm->DefineProperty + ("CMAKE_Fortran_FORMAT", cmProperty::VARIABLE, + "Set to FIXED or FREE to indicate the Fortran source layout.", + "This variable is used to initialize the Fortran_FORMAT " + "property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + + cm->DefineProperty ("CMAKE_Fortran_MODULE_DIRECTORY", cmProperty::VARIABLE, "Fortran module output directory.", "This variable is used to initialize the " diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index e3bae76..690dabb 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -582,6 +582,13 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, { lg->AppendFlags(flags, cmtarget.GetProperty("COMPILE_FLAGS")); } + const char* srcfmt = sf->GetProperty("Fortran_FORMAT"); + switch(this->CurrentLocalGenerator->GetFortranFormat(srcfmt)) + { + case cmLocalGenerator::FortranFormatFixed: flags="-fixed "+flags; break; + case cmLocalGenerator::FortranFormatFree: flags="-free "+flags; break; + default: break; + } lg->AppendFlags(flags, sf->GetProperty("COMPILE_FLAGS")); // Add per-source definitions. @@ -1904,6 +1911,21 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(flags.c_str())); } + // Add Fortran source format attribute if property is set. + const char* format = 0; + const char* tgtfmt = target.GetProperty("Fortran_FORMAT"); + switch(this->CurrentLocalGenerator->GetFortranFormat(tgtfmt)) + { + case cmLocalGenerator::FortranFormatFixed: format = "fixed"; break; + case cmLocalGenerator::FortranFormatFree: format = "free"; break; + default: break; + } + if(format) + { + buildSettings->AddAttribute("IFORT_LANG_SRCFMT", + this->CreateString(format)); + } + // Create the INSTALL_PATH attribute. std::string install_name_dir; if(target.GetType() == cmTarget::SHARED_LIBRARY) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7da35eb..1d1e8da 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2917,6 +2917,31 @@ std::string cmLocalGenerator::EscapeForCMake(const char* str) } //---------------------------------------------------------------------------- +cmLocalGenerator::FortranFormat +cmLocalGenerator::GetFortranFormat(const char* value) +{ + FortranFormat format = FortranFormatNone; + if(value && *value) + { + std::vector<std::string> fmt; + cmSystemTools::ExpandListArgument(value, fmt); + for(std::vector<std::string>::iterator fi = fmt.begin(); + fi != fmt.end(); ++fi) + { + if(*fi == "FIXED") + { + format = FortranFormatFixed; + } + if(*fi == "FREE") + { + format = FortranFormatFree; + } + } + } + return format; +} + +//---------------------------------------------------------------------------- std::string cmLocalGenerator::GetTargetDirectory(cmTarget const&) const { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index a204a73..cfc09dc 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -244,6 +244,14 @@ public: /** Escape the given string as an argument in a CMake script. */ std::string EscapeForCMake(const char* str); + enum FortranFormat + { + FortranFormatNone, + FortranFormatFixed, + FortranFormatFree + }; + FortranFormat GetFortranFormat(const char* value); + /** Return the directories into which object files will be put. * There maybe more than one for fat binary systems like OSX. */ diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 1f99cba..5417584 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -330,6 +330,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranFlagTable[] = { {"Preprocess", "fpp", "Run Preprocessor on files", "preprocessYes", 0}, {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "true", 0}, + {"SourceFileFormat", "fixed", "Use Fixed Format", "fileFormatFixed", 0}, + {"SourceFileFormat", "free", "Use Free Format", "fileFormatFree", 0}, {"DebugInformationFormat", "Zi", "full debug", "debugEnabled", 0}, {"DebugInformationFormat", "debug:full", "full debug", "debugEnabled", 0}, {"DebugInformationFormat", "Z7", "c7 compat", "debugOldStyleInfo", 0}, @@ -687,6 +689,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } } + if(this->FortranProject) + { + switch(this->GetFortranFormat(target.GetProperty("Fortran_FORMAT"))) + { + case FortranFormatFixed: flags += " -fixed"; break; + case FortranFormatFree: flags += " -free"; break; + default: break; + } + } + // Add the target-specific flags. if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS")) { @@ -1361,6 +1373,21 @@ cmLocalVisualStudio7GeneratorFCInfo fc.CompileFlags = cflags; needfc = true; } + if(lg->FortranProject) + { + switch(lg->GetFortranFormat(sf.GetProperty("Fortran_FORMAT"))) + { + case cmLocalGenerator::FortranFormatFixed: + fc.CompileFlags = "-fixed " + fc.CompileFlags; + needfc = true; + break; + case cmLocalGenerator::FortranFormatFree: + fc.CompileFlags = "-free " + fc.CompileFlags; + needfc = true; + break; + default: break; + } + } if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) { fc.CompileDefs = cdefs; @@ -1569,8 +1596,15 @@ void cmLocalVisualStudio7Generator !fc.CompileDefs.empty() || !fc.CompileDefsConfig.empty()) { - Options fileOptions(this, this->Version, Options::Compiler, - cmLocalVisualStudio7GeneratorFlagTable, + Options::Tool tool = Options::Compiler; + cmVS7FlagTable const* table = + cmLocalVisualStudio7GeneratorFlagTable; + if(this->FortranProject) + { + tool = Options::FortranCompiler; + table = cmLocalVisualStudio7GeneratorFortranFlagTable; + } + Options fileOptions(this, this->Version, tool, table, this->ExtraFlagTable); fileOptions.Parse(fc.CompileFlags.c_str()); fileOptions.AddDefines(fc.CompileDefs.c_str()); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d0df8f0..8b91194 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -504,6 +504,35 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) //---------------------------------------------------------------------------- void cmMakefileTargetGenerator +::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source) +{ + const char* srcfmt = source.GetProperty("Fortran_FORMAT"); + cmLocalGenerator::FortranFormat format = + this->LocalGenerator->GetFortranFormat(srcfmt); + if(format == cmLocalGenerator::FortranFormatNone) + { + const char* tgtfmt = this->Target->GetProperty("Fortran_FORMAT"); + format = this->LocalGenerator->GetFortranFormat(tgtfmt); + } + const char* var = 0; + switch (format) + { + case cmLocalGenerator::FortranFormatFixed: + var = "CMAKE_Fortran_FORMAT_FIXED_FLAG"; break; + case cmLocalGenerator::FortranFormatFree: + var = "CMAKE_Fortran_FORMAT_FREE_FLAG"; break; + default: break; + } + if(var) + { + this->LocalGenerator->AppendFlags( + flags, this->Makefile->GetDefinition(var)); + } +} + +//---------------------------------------------------------------------------- +void +cmMakefileTargetGenerator ::WriteObjectBuildFile(std::string &obj, const char *lang, cmSourceFile& source, @@ -562,6 +591,12 @@ cmMakefileTargetGenerator } } + // Add Fortran format flags. + if(strcmp(lang, "Fortran") == 0) + { + this->AppendFortranFormatFlags(flags, source); + } + // Add flags from source file properties. if (source.GetProperty("COMPILE_FLAGS")) { diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b68f8bf..674cd13 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -112,6 +112,8 @@ protected: // Return the a string with -F flags on apple std::string GetFrameworkFlags(); + void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source); + // append intertarget dependencies void AppendTargetDepends(std::vector<std::string>& depends); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index dfa2c0b..cd94753 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -437,6 +437,15 @@ void cmSourceFile::DefineProperties(cmake *cm) "It will still be linked into the target though."); cm->DefineProperty + ("Fortran_FORMAT", cmProperty::SOURCE_FILE, + "Set to FIXED or FREE to indicate the Fortran source layout.", + "This property tells CMake whether a given Fortran source file " + "uses fixed-format or free-format. " + "CMake will pass the corresponding format flag to the compiler. " + "Consider using the target-wide Fortran_FORMAT property if all " + "source files in a target share the same format."); + + cm->DefineProperty ("GENERATED", cmProperty::SOURCE_FILE, "Is this source file generated as part of the build process.", "If a source file is generated by the build process CMake will " diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4969b65..a7f50f6 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -919,6 +919,17 @@ void cmTarget::DefineProperties(cmake *cm) ); cm->DefineProperty + ("Fortran_FORMAT", cmProperty::TARGET, + "Set to FIXED or FREE to indicate the Fortran source layout.", + "This property tells CMake whether the Fortran source files " + "in a target use fixed-format or free-format. " + "CMake will pass the corresponding format flag to the compiler. " + "Use the source-specific Fortran_FORMAT property to change the " + "format of a specific source file. " + "If the variable CMAKE_Fortran_FORMAT is set when a target " + "is created its value is used to initialize this property."); + + cm->DefineProperty ("Fortran_MODULE_DIRECTORY", cmProperty::TARGET, "Specify output directory for Fortran modules provided by the target.", "If the target contains Fortran source files that provide modules " @@ -1138,6 +1149,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("Fortran_FORMAT", 0); this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); this->SetPropertyDefault("OSX_ARCHITECTURES", 0); this->SetPropertyDefault("AUTOMOC", 0); |