mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-08 14:50:10 -06:00
Genex: Allow COMPILE_LANGUAGE to name a language that is not loaded
Evaluate to false on `$<COMPILE_LANGUAGE:Lang>` if language `Lang` is not loaded. This is helpful in exported targets consumed in other projects that may not enable all the same languages. Fixes: #17952
This commit is contained in:
committed by
Brad King
parent
5e455ac120
commit
4f82199bef
@@ -1013,16 +1013,7 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::vector<std::string> enabledLanguages;
|
||||
cmGlobalGenerator* gg = context->LG->GetGlobalGenerator();
|
||||
gg->GetEnabledLanguages(enabledLanguages);
|
||||
if (!parameters.empty() &&
|
||||
std::find(enabledLanguages.begin(), enabledLanguages.end(),
|
||||
parameters.front()) == enabledLanguages.end()) {
|
||||
reportError(context, content->GetOriginalExpression(),
|
||||
"$<COMPILE_LANGUAGE:...> Unknown language.");
|
||||
return std::string();
|
||||
}
|
||||
std::string genName = gg->GetName();
|
||||
if (genName.find("Makefiles") == std::string::npos &&
|
||||
genName.find("Ninja") == std::string::npos &&
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,8 +0,0 @@
|
||||
CMake Error at COMPILE_LANGUAGE-unknown-lang.cmake:4 \(target_compile_options\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<COMPILE_LANGUAGE:CXX>
|
||||
|
||||
\$<COMPILE_LANGUAGE:...> Unknown language.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
enable_language(C)
|
||||
add_executable(empty empty.c)
|
||||
target_compile_options(empty PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wall>)
|
||||
target_compile_options(empty PRIVATE $<$<COMPILE_LANGUAGE:CXX>:$<TARGET_EXISTS:too,many,parameters>>)
|
||||
|
||||
Reference in New Issue
Block a user