summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAndrew Paprocki <andrew@ishiboo.com>2019-01-14 14:12:38 (GMT)
committerBrad King <brad.king@kitware.com>2019-01-18 13:56:13 (GMT)
commita080914274b32ac53f2449602811aebca7cc7d29 (patch)
treef0b8f3fc84fcbedb23bb3e8afa5657effa773495 /Source
parenta61c061b6143cb6d8920b1b5796a867c0f104556 (diff)
downloadCMake-a080914274b32ac53f2449602811aebca7cc7d29.zip
CMake-a080914274b32ac53f2449602811aebca7cc7d29.tar.gz
CMake-a080914274b32ac53f2449602811aebca7cc7d29.tar.bz2
Fortran: Add compiler ID/Version generator expressions
Adds `Fortran_COMPILER_ID` and `Fortran_COMPILER_VERSION` generator expression support to match equivalent `C_COMPILER_ID`, `CXX_COMPILER_ID`, `C_COMPILER_VERSION`, and `CXX_COMPILER_VERSION` support. This is very helpful in the case where the C/C++ compiler suite is a different type of compiler from the platform Fortran compiler and projects use generator expressions to assign compiler flags and definitions. (e.g. `GNU` C/C++ and `SunPro` Fortran on Linux)
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpressionNode.cxx46
1 files changed, 46 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index fe1b055..6a3f73d 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -692,6 +692,28 @@ static const struct CXXCompilerIdNode : public CompilerIdNode
}
} cxxCompilerIdNode;
+static const struct FortranCompilerIdNode : public CompilerIdNode
+{
+ FortranCompilerIdNode() {}
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
+ {
+ if (!context->HeadTarget) {
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<Fortran_COMPILER_ID> may only be used with binary targets. It may "
+ "not be used with add_custom_command or add_custom_target.");
+ return std::string();
+ }
+ return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
+ "Fortran");
+ }
+} fortranCompilerIdNode;
+
struct CompilerVersionNode : public cmGeneratorExpressionNode
{
CompilerVersionNode() {}
@@ -773,6 +795,28 @@ static const struct CxxCompilerVersionNode : public CompilerVersionNode
}
} cxxCompilerVersionNode;
+static const struct FortranCompilerVersionNode : public CompilerVersionNode
+{
+ FortranCompilerVersionNode() {}
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
+ {
+ if (!context->HeadTarget) {
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<Fortran_COMPILER_VERSION> may only be used with binary targets. "
+ "It may not be used with add_custom_command or add_custom_target.");
+ return std::string();
+ }
+ return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
+ "Fortran");
+ }
+} fortranCompilerVersionNode;
+
struct PlatformIdNode : public cmGeneratorExpressionNode
{
PlatformIdNode() {}
@@ -2024,6 +2068,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
nodeMap["NOT"] = &notNode;
nodeMap["C_COMPILER_ID"] = &cCompilerIdNode;
nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode;
+ nodeMap["Fortran_COMPILER_ID"] = &fortranCompilerIdNode;
nodeMap["VERSION_GREATER"] = &versionGreaterNode;
nodeMap["VERSION_GREATER_EQUAL"] = &versionGreaterEqNode;
nodeMap["VERSION_LESS"] = &versionLessNode;
@@ -2031,6 +2076,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
nodeMap["VERSION_EQUAL"] = &versionEqualNode;
nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode;
nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode;
+ nodeMap["Fortran_COMPILER_VERSION"] = &fortranCompilerVersionNode;
nodeMap["PLATFORM_ID"] = &platformIdNode;
nodeMap["COMPILE_FEATURES"] = &compileFeaturesNode;
nodeMap["CONFIGURATION"] = &configurationNode;