summaryrefslogtreecommitdiff
path: root/Source/cmGeneratorExpressionNode.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-01-11 11:23:06 -0500
committerBrad King <brad.king@kitware.com>2018-01-12 14:27:37 -0500
commitc2f79c98677d43fb8686f9e4309acddfae8f3dfd (patch)
tree9c4cd2e7ece8bfd90aa13a23c4caa154ce95a1e4 /Source/cmGeneratorExpressionNode.cxx
parent0795d25b78d5b7682aea091d260eaf1bca7afd0a (diff)
downloadcmake-c2f79c98677d43fb8686f9e4309acddfae8f3dfd.tar.gz
Genex: Enable COMPILE_LANGUAGE for COMPILE_DEFINITIONS 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 `COMPILE_DEFINITIONS` 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 definitions for C and C++ is frequently similar but may be distinct from those for other languages like CUDA. Issue: #17435
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r--Source/cmGeneratorExpressionNode.cxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 3d311d6a8e..597112afcb 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -828,20 +828,20 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
}
std::string genName = gg->GetName();
if (genName.find("Visual Studio") != std::string::npos) {
- if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
- dagChecker->EvaluatingIncludeDirectories())) {
+ if (dagChecker && dagChecker->EvaluatingIncludeDirectories()) {
reportError(
context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS "
+ "$<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->EvaluatingCompileDefinitions() ||
- dagChecker->EvaluatingIncludeDirectories())) {
+ if (dagChecker && dagChecker->EvaluatingIncludeDirectories()) {
reportError(
context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS "
+ "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS, "
+ "COMPILE_DEFINITIONS, "
"and file(GENERATE) with the Xcode generator.");
return std::string();
}