diff options
author | Brad King <brad.king@kitware.com> | 2009-08-11 13:54:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-08-11 13:54:56 (GMT) |
commit | d2e1f2b4d6d87c171464b5dc41b00b609c90bf26 (patch) | |
tree | d0108fae5ed9b014939c0f7baee8a6ad4d6daa42 /Source/cmTestGenerator.cxx | |
parent | 463b3f03bd848a345ab535d31be31d395fe66b13 (diff) | |
download | CMake-d2e1f2b4d6d87c171464b5dc41b00b609c90bf26.zip CMake-d2e1f2b4d6d87c171464b5dc41b00b609c90bf26.tar.gz CMake-d2e1f2b4d6d87c171464b5dc41b00b609c90bf26.tar.bz2 |
Introduce "generator expressions" to add_test()
This introduces a new syntax called "generator expressions" to the test
COMMAND option of the add_test(NAME) command mode. These expressions
have a syntax like $<TARGET_FILE:mytarget> and are evaluated during
build system generation. This syntax allows per-configuration target
output files to be referenced in test commands and arguments.
Diffstat (limited to 'Source/cmTestGenerator.cxx')
-rw-r--r-- | Source/cmTestGenerator.cxx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 2c98910..866ffd3 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -16,6 +16,7 @@ =========================================================================*/ #include "cmTestGenerator.h" +#include "cmGeneratorExpression.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSystemTools.h" @@ -94,6 +95,10 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, { this->TestGenerated = true; + // Set up generator expression evaluation context. + cmMakefile* mf = this->Test->GetMakefile(); + cmGeneratorExpression ge(mf, config, this->Test->GetBacktrace()); + // Start the test command. os << indent << "ADD_TEST(" << this->Test->GetName() << " "; @@ -103,7 +108,6 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Check whether the command executable is a target whose name is to // be translated. std::string exe = command[0]; - cmMakefile* mf = this->Test->GetMakefile(); cmTarget* target = mf->FindTargetToUse(exe.c_str()); if(target && target->GetType() == cmTarget::EXECUTABLE) { @@ -113,6 +117,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, else { // Use the command name given. + exe = ge.Process(exe.c_str()); cmSystemTools::ConvertToUnixSlashes(exe); } @@ -122,7 +127,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, for(std::vector<std::string>::const_iterator ci = command.begin()+1; ci != command.end(); ++ci) { - os << " " << lg->EscapeForCMake(ci->c_str()); + os << " " << lg->EscapeForCMake(ge.Process(*ci)); } // Finish the test command. |