Genex: Add a COMPILE_LANGUAGE generator expression.
This commit is contained in:
parent
4a0128f42f
commit
e387ce7d68
|
@ -52,14 +52,16 @@ cmGeneratorExpression::~cmGeneratorExpression()
|
||||||
const char *cmCompiledGeneratorExpression::Evaluate(
|
const char *cmCompiledGeneratorExpression::Evaluate(
|
||||||
cmMakefile* mf, const std::string& config, bool quiet,
|
cmMakefile* mf, const std::string& config, bool quiet,
|
||||||
cmTarget const* headTarget,
|
cmTarget const* headTarget,
|
||||||
cmGeneratorExpressionDAGChecker *dagChecker) const
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||||
|
std::string const& language) const
|
||||||
{
|
{
|
||||||
return this->Evaluate(mf,
|
return this->Evaluate(mf,
|
||||||
config,
|
config,
|
||||||
quiet,
|
quiet,
|
||||||
headTarget,
|
headTarget,
|
||||||
headTarget,
|
headTarget,
|
||||||
dagChecker);
|
dagChecker,
|
||||||
|
language);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -67,7 +69,8 @@ const char *cmCompiledGeneratorExpression::Evaluate(
|
||||||
cmMakefile* mf, const std::string& config, bool quiet,
|
cmMakefile* mf, const std::string& config, bool quiet,
|
||||||
cmTarget const* headTarget,
|
cmTarget const* headTarget,
|
||||||
cmTarget const* currentTarget,
|
cmTarget const* currentTarget,
|
||||||
cmGeneratorExpressionDAGChecker *dagChecker) const
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||||
|
std::string const& language) const
|
||||||
{
|
{
|
||||||
if (!this->NeedsEvaluation)
|
if (!this->NeedsEvaluation)
|
||||||
{
|
{
|
||||||
|
@ -93,6 +96,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
|
||||||
context.EvaluateForBuildsystem = this->EvaluateForBuildsystem;
|
context.EvaluateForBuildsystem = this->EvaluateForBuildsystem;
|
||||||
context.CurrentTarget = currentTarget ? currentTarget : headTarget;
|
context.CurrentTarget = currentTarget ? currentTarget : headTarget;
|
||||||
context.Backtrace = this->Backtrace;
|
context.Backtrace = this->Backtrace;
|
||||||
|
context.Language = language;
|
||||||
|
|
||||||
for ( ; it != end; ++it)
|
for ( ; it != end; ++it)
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,11 +80,13 @@ public:
|
||||||
bool quiet = false,
|
bool quiet = false,
|
||||||
cmTarget const* headTarget = 0,
|
cmTarget const* headTarget = 0,
|
||||||
cmTarget const* currentTarget = 0,
|
cmTarget const* currentTarget = 0,
|
||||||
cmGeneratorExpressionDAGChecker *dagChecker = 0) const;
|
cmGeneratorExpressionDAGChecker *dagChecker = 0,
|
||||||
|
std::string const& language = std::string()) const;
|
||||||
const char* Evaluate(cmMakefile* mf, const std::string& config,
|
const char* Evaluate(cmMakefile* mf, const std::string& config,
|
||||||
bool quiet,
|
bool quiet,
|
||||||
cmTarget const* headTarget,
|
cmTarget const* headTarget,
|
||||||
cmGeneratorExpressionDAGChecker *dagChecker) const;
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||||
|
std::string const& language = std::string()) const;
|
||||||
|
|
||||||
/** Get set of targets found during evaluations. */
|
/** Get set of targets found during evaluations. */
|
||||||
std::set<cmTarget*> const& GetTargets() const
|
std::set<cmTarget*> const& GetTargets() const
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "cmGeneratorExpressionDAGChecker.h"
|
#include "cmGeneratorExpressionDAGChecker.h"
|
||||||
#include "cmGeneratorExpression.h"
|
#include "cmGeneratorExpression.h"
|
||||||
#include "cmLocalGenerator.h"
|
#include "cmLocalGenerator.h"
|
||||||
|
#include "cmGlobalGenerator.h"
|
||||||
#include "cmSourceFile.h"
|
#include "cmSourceFile.h"
|
||||||
|
|
||||||
#include <cmsys/String.h>
|
#include <cmsys/String.h>
|
||||||
|
@ -89,7 +90,8 @@ std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
|
||||||
context->Quiet,
|
context->Quiet,
|
||||||
headTarget,
|
headTarget,
|
||||||
currentTarget,
|
currentTarget,
|
||||||
dagChecker);
|
dagChecker,
|
||||||
|
context->Language);
|
||||||
if (cge->GetHadContextSensitiveCondition())
|
if (cge->GetHadContextSensitiveCondition())
|
||||||
{
|
{
|
||||||
context->HadContextSensitiveCondition = true;
|
context->HadContextSensitiveCondition = true;
|
||||||
|
@ -806,6 +808,33 @@ static const struct JoinNode : public cmGeneratorExpressionNode
|
||||||
}
|
}
|
||||||
} joinNode;
|
} joinNode;
|
||||||
|
|
||||||
|
static const struct CompileLanguageNode : public cmGeneratorExpressionNode
|
||||||
|
{
|
||||||
|
CompileLanguageNode() {}
|
||||||
|
|
||||||
|
virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
|
||||||
|
|
||||||
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
||||||
|
cmGeneratorExpressionContext *context,
|
||||||
|
const GeneratorExpressionContent *content,
|
||||||
|
cmGeneratorExpressionDAGChecker *) const
|
||||||
|
{
|
||||||
|
if(context->Language.empty())
|
||||||
|
{
|
||||||
|
reportError(context, content->GetOriginalExpression(),
|
||||||
|
"$<COMPILE_LANGUAGE:...> may only be used to specify include "
|
||||||
|
"directories compile definitions, compile options and to evaluate "
|
||||||
|
"components of the file(GENERATE) command.");
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
if (parameters.empty())
|
||||||
|
{
|
||||||
|
return context->Language;
|
||||||
|
}
|
||||||
|
return context->Language == parameters.front() ? "1" : "0";
|
||||||
|
}
|
||||||
|
} languageNode;
|
||||||
|
|
||||||
#define TRANSITIVE_PROPERTY_NAME(PROPERTY) \
|
#define TRANSITIVE_PROPERTY_NAME(PROPERTY) \
|
||||||
, "INTERFACE_" #PROPERTY
|
, "INTERFACE_" #PROPERTY
|
||||||
|
|
||||||
|
@ -1829,6 +1858,7 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
|
||||||
nodeMap["INSTALL_PREFIX"] = &installPrefixNode;
|
nodeMap["INSTALL_PREFIX"] = &installPrefixNode;
|
||||||
nodeMap["JOIN"] = &joinNode;
|
nodeMap["JOIN"] = &joinNode;
|
||||||
nodeMap["LINK_ONLY"] = &linkOnlyNode;
|
nodeMap["LINK_ONLY"] = &linkOnlyNode;
|
||||||
|
nodeMap["COMPILE_LANGUAGE"] = &languageNode;
|
||||||
}
|
}
|
||||||
NodeMap::const_iterator i = nodeMap.find(identifier);
|
NodeMap::const_iterator i = nodeMap.find(identifier);
|
||||||
if (i == nodeMap.end())
|
if (i == nodeMap.end())
|
||||||
|
|
|
@ -36,6 +36,7 @@ struct cmGeneratorExpressionContext
|
||||||
MaxLanguageStandard;
|
MaxLanguageStandard;
|
||||||
cmMakefile *Makefile;
|
cmMakefile *Makefile;
|
||||||
std::string Config;
|
std::string Config;
|
||||||
|
std::string Language;
|
||||||
cmTarget const* HeadTarget; // The target whose property is being evaluated.
|
cmTarget const* HeadTarget; // The target whose property is being evaluated.
|
||||||
cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears
|
cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears
|
||||||
// directly or indirectly in the property.
|
// directly or indirectly in the property.
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,10 @@
|
||||||
|
CMake Error at COMPILE_LANGUAGE-add_custom_command.cmake:6 \(add_custom_command\):
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE>
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE:...> may only be used to specify include directories
|
||||||
|
compile definitions, compile options and to evaluate components of the
|
||||||
|
file\(GENERATE\) command.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
add_library(empty empty.c)
|
||||||
|
|
||||||
|
add_custom_command(TARGET empty PRE_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANGUAGE>
|
||||||
|
)
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,10 @@
|
||||||
|
CMake Error at COMPILE_LANGUAGE-add_custom_target.cmake:4 \(add_custom_target\):
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE>
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE:...> may only be used to specify include directories
|
||||||
|
compile definitions, compile options and to evaluate components of the
|
||||||
|
file\(GENERATE\) command.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
add_custom_target(empty
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANGUAGE>
|
||||||
|
)
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,10 @@
|
||||||
|
CMake Error at COMPILE_LANGUAGE-add_executable.cmake:4 \(add_executable\):
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE>
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE:...> may only be used to specify include directories
|
||||||
|
compile definitions, compile options and to evaluate components of the
|
||||||
|
file\(GENERATE\) command.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
add_executable(empty empty.$<COMPILE_LANGUAGE>)
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,10 @@
|
||||||
|
CMake Error at COMPILE_LANGUAGE-add_library.cmake:4 \(add_library\):
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE>
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE:...> may only be used to specify include directories
|
||||||
|
compile definitions, compile options and to evaluate components of the
|
||||||
|
file\(GENERATE\) command.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
add_library(empty empty.$<COMPILE_LANGUAGE>)
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,10 @@
|
||||||
|
CMake Error at COMPILE_LANGUAGE-add_test.cmake:5 \(add_test\):
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE>
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE:...> may only be used to specify include directories
|
||||||
|
compile definitions, compile options and to evaluate components of the
|
||||||
|
file\(GENERATE\) command.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
add_test(NAME dummy COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANGUAGE>)
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,8 @@
|
||||||
|
CMake Error:
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE>
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE:...> may only be used to specify include directories
|
||||||
|
compile definitions, compile options and to evaluate components of the
|
||||||
|
file\(GENERATE\) command.
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
empty.$<COMPILE_LANGUAGE>
|
||||||
|
DESTINATION src
|
||||||
|
)
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,10 @@
|
||||||
|
CMake Error at COMPILE_LANGUAGE-target_sources.cmake:5 \(target_sources\):
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE>
|
||||||
|
|
||||||
|
\$<COMPILE_LANGUAGE:...> may only be used to specify include directories
|
||||||
|
compile definitions, compile options and to evaluate components of the
|
||||||
|
file\(GENERATE\) command.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
enable_language(C)
|
||||||
|
|
||||||
|
add_library(empty empty.c)
|
||||||
|
target_sources(empty PRIVATE empty.$<COMPILE_LANGUAGE>)
|
|
@ -16,6 +16,13 @@ run_cmake(NonValidTarget-C_COMPILER_VERSION)
|
||||||
run_cmake(NonValidTarget-CXX_COMPILER_VERSION)
|
run_cmake(NonValidTarget-CXX_COMPILER_VERSION)
|
||||||
run_cmake(NonValidTarget-TARGET_PROPERTY)
|
run_cmake(NonValidTarget-TARGET_PROPERTY)
|
||||||
run_cmake(NonValidTarget-TARGET_POLICY)
|
run_cmake(NonValidTarget-TARGET_POLICY)
|
||||||
|
run_cmake(COMPILE_LANGUAGE-add_custom_target)
|
||||||
|
run_cmake(COMPILE_LANGUAGE-add_custom_command)
|
||||||
|
run_cmake(COMPILE_LANGUAGE-install)
|
||||||
|
run_cmake(COMPILE_LANGUAGE-target_sources)
|
||||||
|
run_cmake(COMPILE_LANGUAGE-add_executable)
|
||||||
|
run_cmake(COMPILE_LANGUAGE-add_library)
|
||||||
|
run_cmake(COMPILE_LANGUAGE-add_test)
|
||||||
|
|
||||||
if(LINKER_SUPPORTS_PDB)
|
if(LINKER_SUPPORTS_PDB)
|
||||||
run_cmake(NonValidTarget-TARGET_PDB_FILE)
|
run_cmake(NonValidTarget-TARGET_PDB_FILE)
|
||||||
|
|
Loading…
Reference in New Issue