diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2019-03-11 16:33:43 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2019-03-11 16:33:43 (GMT) |
commit | b53766b2058160853a29c2bbf8dbfef7345552a4 (patch) | |
tree | f3d7cdfadccdbee4f783cfafa1e16a94455bc41c /Source/cmGeneratorExpressionNode.cxx | |
parent | b544e34af61d2f12a5da62e29de5d635171b2b1d (diff) | |
download | CMake-b53766b2058160853a29c2bbf8dbfef7345552a4.zip CMake-b53766b2058160853a29c2bbf8dbfef7345552a4.tar.gz CMake-b53766b2058160853a29c2bbf8dbfef7345552a4.tar.bz2 |
CUDA: Support compiler id and version generator expressions
Introduce the CUDA_COMPILER_ID and CUDA_COMPILER_VERSION generator
expressions.
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 6ee7fa5..0ba662d 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -690,6 +690,28 @@ static const struct CXXCompilerIdNode : public CompilerIdNode } } cxxCompilerIdNode; +static const struct CUDACompilerIdNode : public CompilerIdNode +{ + CUDACompilerIdNode() {} // NOLINT(modernize-use-equals-default) + + 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(), + "$<CUDA_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, + "CUDA"); + } +} cudaCompilerIdNode; + static const struct FortranCompilerIdNode : public CompilerIdNode { FortranCompilerIdNode() {} // NOLINT(modernize-use-equals-default) @@ -793,6 +815,28 @@ static const struct CXXCompilerVersionNode : public CompilerVersionNode } } cxxCompilerVersionNode; +static const struct CUDACompilerVersionNode : public CompilerVersionNode +{ + CUDACompilerVersionNode() {} // NOLINT(modernize-use-equals-default) + + 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(), + "$<CUDA_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, + "CUDA"); + } +} cudaCompilerVersionNode; + static const struct FortranCompilerVersionNode : public CompilerVersionNode { FortranCompilerVersionNode() {} // NOLINT(modernize-use-equals-default) @@ -2066,6 +2110,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( { "NOT", ¬Node }, { "C_COMPILER_ID", &cCompilerIdNode }, { "CXX_COMPILER_ID", &cxxCompilerIdNode }, + { "CUDA_COMPILER_ID", &cudaCompilerIdNode }, { "Fortran_COMPILER_ID", &fortranCompilerIdNode }, { "VERSION_GREATER", &versionGreaterNode }, { "VERSION_GREATER_EQUAL", &versionGreaterEqNode }, @@ -2074,6 +2119,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( { "VERSION_EQUAL", &versionEqualNode }, { "C_COMPILER_VERSION", &cCompilerVersionNode }, { "CXX_COMPILER_VERSION", &cxxCompilerVersionNode }, + { "CUDA_COMPILER_VERSION", &cudaCompilerVersionNode }, { "Fortran_COMPILER_VERSION", &fortranCompilerVersionNode }, { "PLATFORM_ID", &platformIdNode }, { "COMPILE_FEATURES", &compileFeaturesNode }, |