diff options
author | Brad King <brad.king@kitware.com> | 2018-01-11 19:32:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-01-12 19:27:37 (GMT) |
commit | 506fda1cf026a88378589009b62ca8bf633c5197 (patch) | |
tree | 2095056002a42332f5e8f2741daa29eb8880db10 /Source/cmGeneratorExpressionNode.cxx | |
parent | c2f79c98677d43fb8686f9e4309acddfae8f3dfd (diff) | |
download | CMake-506fda1cf026a88378589009b62ca8bf633c5197.zip CMake-506fda1cf026a88378589009b62ca8bf633c5197.tar.gz CMake-506fda1cf026a88378589009b62ca8bf633c5197.tar.bz2 |
Genex: Enable COMPILE_LANGUAGE for INCLUDE_DIRECTORIES with VS and Xcode
The set of compile flags used for a target's C and C++ sources is based
on the linker language. By default this is always the C++ flags if any
C++ sources appear in the target, and otherwise the C flags. Therefore
we can define the `COMPILE_LANGUAGE` generator expression in
`INCLUDE_DIRECTORIES` to match the selected language.
This is not exactly the same as for other generators, but is the best VS
and Xcode can do. It is also sufficient for many use cases since the
set of include directories for C and C++ is frequently similar but may
be distinct from those for other languages like CUDA.
Fixes: #17435
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 597112a..34ef45f 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -805,7 +805,7 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode const std::vector<std::string>& parameters, cmGeneratorExpressionContext* context, const GeneratorExpressionContent* content, - cmGeneratorExpressionDAGChecker* dagChecker) const override + cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override { if (context->Language.empty()) { reportError( @@ -827,33 +827,14 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode return std::string(); } std::string genName = gg->GetName(); - if (genName.find("Visual Studio") != std::string::npos) { - if (dagChecker && dagChecker->EvaluatingIncludeDirectories()) { - reportError( - context, content->GetOriginalExpression(), - "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS, " - "COMPILE_DEFINITIONS, " - "and file(GENERATE) with the Visual Studio generator."); - return std::string(); - } - } else if (genName.find("Xcode") != std::string::npos) { - if (dagChecker && dagChecker->EvaluatingIncludeDirectories()) { - reportError( - context, content->GetOriginalExpression(), - "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS, " - "COMPILE_DEFINITIONS, " - "and file(GENERATE) with the Xcode generator."); - return std::string(); - } - } else { - if (genName.find("Makefiles") == std::string::npos && - genName.find("Ninja") == std::string::npos && - genName.find("Watcom WMake") == std::string::npos) { - reportError( - context, content->GetOriginalExpression(), - "$<COMPILE_LANGUAGE:...> not supported for this generator."); - return std::string(); - } + if (genName.find("Makefiles") == std::string::npos && + genName.find("Ninja") == std::string::npos && + genName.find("Visual Studio") == std::string::npos && + genName.find("Xcode") == std::string::npos && + genName.find("Watcom WMake") == std::string::npos) { + reportError(context, content->GetOriginalExpression(), + "$<COMPILE_LANGUAGE:...> not supported for this generator."); + return std::string(); } if (parameters.empty()) { return context->Language; |