summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/cmCommands.cxx4
-rw-r--r--Source/cmGetTestPropertyCommand.cxx47
-rw-r--r--Source/cmGetTestPropertyCommand.h66
-rw-r--r--Source/cmLocalGenerator.cxx4
-rw-r--r--Source/cmMakefile.cxx5
-rw-r--r--Source/cmMakefile.h1
-rw-r--r--Source/cmSetTestsPropertiesCommand.cxx110
-rw-r--r--Source/cmSetTestsPropertiesCommand.h65
-rw-r--r--Source/cmTest.cxx35
-rw-r--r--Source/cmTest.h6
10 files changed, 338 insertions, 5 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 8fe500b8ce..6b1a01f03e 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -24,6 +24,7 @@
#include "cmGetCMakePropertyCommand.cxx"
#include "cmGetDirectoryPropertyCommand.cxx"
#include "cmGetTargetPropertyCommand.cxx"
+#include "cmGetTestPropertyCommand.cxx"
#include "cmITKWrapTclCommand.cxx"
#include "cmIncludeExternalMSProjectCommand.cxx"
#include "cmLinkLibrariesCommand.cxx"
@@ -32,6 +33,7 @@
#include "cmRemoveCommand.cxx"
#include "cmSetDirectoryPropertiesCommand.cxx"
#include "cmSetTargetPropertiesCommand.cxx"
+#include "cmSetTestsPropertiesCommand.cxx"
#include "cmSourceGroupCommand.cxx"
#include "cmVTKMakeInstantiatorCommand.cxx"
#include "cmVTKWrapJavaCommand.cxx"
@@ -64,6 +66,7 @@ void GetPredefinedCommands(std::list<cmCommand*>&
commands.push_back(new cmGetCMakePropertyCommand);
commands.push_back(new cmGetDirectoryPropertyCommand);
commands.push_back(new cmGetTargetPropertyCommand);
+ commands.push_back(new cmGetTestPropertyCommand);
commands.push_back(new cmITKWrapTclCommand);
commands.push_back(new cmIncludeExternalMSProjectCommand);
commands.push_back(new cmLinkLibrariesCommand);
@@ -73,6 +76,7 @@ void GetPredefinedCommands(std::list<cmCommand*>&
commands.push_back(new cmRemoveCommand);
commands.push_back(new cmSetDirectoryPropertiesCommand);
commands.push_back(new cmSetTargetPropertiesCommand);
+ commands.push_back(new cmSetTestsPropertiesCommand);
commands.push_back(new cmSourceGroupCommand);
commands.push_back(new cmVTKMakeInstantiatorCommand);
commands.push_back(new cmVTKWrapJavaCommand);
diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx
new file mode 100644
index 0000000000..3e75f88260
--- /dev/null
+++ b/Source/cmGetTestPropertyCommand.cxx
@@ -0,0 +1,47 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#include "cmGetTestPropertyCommand.h"
+
+#include "cmake.h"
+#include "cmTest.h"
+
+// cmGetTestPropertyCommand
+bool cmGetTestPropertyCommand::InitialPass(
+ std::vector<std::string> const& args)
+{
+ if(args.size() < 3 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+
+ std::string testName = args[0];
+ std::string var = args[1];
+ cmTest *test = m_Makefile->GetTest(testName.c_str());
+ if (test)
+ {
+ const char *prop = test->GetProperty(args[2].c_str());
+ if (prop)
+ {
+ m_Makefile->AddDefinition(var.c_str(), prop);
+ return true;
+ }
+ }
+ m_Makefile->AddDefinition(var.c_str(), "NOTFOUND");
+ return true;
+}
+
diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h
new file mode 100644
index 0000000000..6ce1c8dd5c
--- /dev/null
+++ b/Source/cmGetTestPropertyCommand.h
@@ -0,0 +1,66 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef cmGetTestPropertyCommand_h
+#define cmGetTestPropertyCommand_h
+
+#include "cmCommand.h"
+
+class cmGetTestPropertyCommand : public cmCommand
+{
+public:
+ virtual cmCommand* Clone()
+ {
+ return new cmGetTestPropertyCommand;
+ }
+
+ /**
+ * This is called when the command is first encountered in
+ * the input file.
+ */
+ virtual bool InitialPass(std::vector<std::string> const& args);
+
+ /**
+ * The name of the command as specified in CMakeList.txt.
+ */
+ virtual const char* GetName() { return "GET_TEST_PROPERTY";}
+
+ /**
+ * Succinct documentation.
+ */
+ virtual const char* GetTerseDocumentation()
+ {
+ return "Get a property of the test.";
+ }
+
+ /**
+ * Longer documentation.
+ */
+ virtual const char* GetFullDocumentation()
+ {
+ return
+ " GET_TEST_PROPERTY(test VAR property)\n"
+ "Get a property from the Test. The value of the property is"
+ "stored in the variable VAR. If the property is not found,"
+ "CMake will report an error.";
+ }
+
+ cmTypeMacro(cmGetTestPropertyCommand, cmCommand);
+};
+
+
+
+#endif
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index d927b3b896..55249f25c2 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -156,14 +156,14 @@ void cmLocalGenerator::GenerateTestFiles()
fout << "ADD_TEST(";
fout << test->GetName() << " \"" << test->GetCommand() << "\"";
- std::vector<cmStdString>::iterator argit;
+ std::vector<cmStdString>::const_iterator argit;
for (argit = test->GetArguments().begin();
argit != test->GetArguments().end(); ++argit)
{
// Just double-quote all arguments so they are re-parsed
// correctly by the test system.
fout << " \"";
- for(std::string::iterator c = argit->begin(); c != argit->end(); ++c)
+ for(std::string::const_iterator c = argit->begin(); c != argit->end(); ++c)
{
// Escape quotes within arguments. We should escape
// backslashes too but we cannot because it makes the result
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c1b566f524..beb1ef170b 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2621,3 +2621,8 @@ const std::vector<cmTest*> *cmMakefile::GetTests() const
return &m_Tests;
}
+std::vector<cmTest*> *cmMakefile::GetTests()
+{
+ return &m_Tests;
+}
+
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 000133e792..ab0c89a322 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -637,6 +637,7 @@ public:
*/
cmTest* GetTest(const char* testName) const;
const std::vector<cmTest*> *GetTests() const;
+ std::vector<cmTest*> *GetTests();
/**
* Get a list of macros as a ; separated string
diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx
new file mode 100644
index 0000000000..65d82f0c31
--- /dev/null
+++ b/Source/cmSetTestsPropertiesCommand.cxx
@@ -0,0 +1,110 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#include "cmSetTestsPropertiesCommand.h"
+
+#include "cmake.h"
+#include "cmTest.h"
+
+// cmSetTestsPropertiesCommand
+bool cmSetTestsPropertiesCommand::InitialPass(
+ std::vector<std::string> const& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+
+ // first collect up the list of files
+ std::vector<std::string> propertyPairs;
+ bool doingFiles = true;
+ int numFiles = 0;
+ std::vector<std::string>::const_iterator j;
+ for(j= args.begin(); j != args.end();++j)
+ {
+ if(*j == "PROPERTIES")
+ {
+ doingFiles = false;
+ // now loop through the rest of the arguments, new style
+ ++j;
+ while (j != args.end())
+ {
+ propertyPairs.push_back(*j);
+ ++j;
+ if(j == args.end())
+ {
+ this->SetError("called with incorrect number of arguments.");
+ return false;
+ }
+ propertyPairs.push_back(*j);
+ ++j;
+ }
+ // break out of the loop because j is already == end
+ break;
+ }
+ else if (doingFiles)
+ {
+ numFiles++;
+ }
+ else
+ {
+ this->SetError("called with illegal arguments, maybe missing a PROPERTIES specifier?");
+ return false;
+ }
+ }
+ if(propertyPairs.size() == 0)
+ {
+ this->SetError("called with illegal arguments, maybe missing a PROPERTIES specifier?");
+ return false;
+ }
+
+ std::vector<cmTest*> &tests = *m_Makefile->GetTests();
+ // now loop over all the targets
+ int i;
+ unsigned int k;
+ for(i = 0; i < numFiles; ++i)
+ {
+ bool found = false;
+ // if the file is already in the makefile just set properites on it
+ std::vector<cmTest*>::iterator it;
+ for ( it = tests.begin(); it != tests.end(); ++ it )
+ {
+ cmTest* test = *it;
+ if ( test->GetName() == args[i] )
+ {
+ // now loop through all the props and set them
+ for (k = 0; k < propertyPairs.size(); k = k + 2)
+ {
+ test->SetProperty(propertyPairs[k].c_str(),propertyPairs[k+1].c_str());
+ }
+ found = true;
+ break;
+ }
+ }
+
+ // if file is not already in the makefile, then add it
+ if ( ! found )
+ {
+ std::string message = "Can not find test to add properties to: ";
+ message += args[i];
+ this->SetError(message.c_str());
+ }
+ }
+
+ return true;
+}
+
diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h
new file mode 100644
index 0000000000..354eb3c5d2
--- /dev/null
+++ b/Source/cmSetTestsPropertiesCommand.h
@@ -0,0 +1,65 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef cmSetTestsPropertiesCommand_h
+#define cmSetTestsPropertiesCommand_h
+
+#include "cmCommand.h"
+
+class cmSetTestsPropertiesCommand : public cmCommand
+{
+public:
+ virtual cmCommand* Clone()
+ {
+ return new cmSetTestsPropertiesCommand;
+ }
+
+ /**
+ * This is called when the command is first encountered in
+ * the input file.
+ */
+ virtual bool InitialPass(std::vector<std::string> const& args);
+
+ /**
+ * The name of the command as specified in CMakeList.txt.
+ */
+ virtual const char* GetName() { return "SET_TESTS_PROPERTIES";}
+
+ /**
+ * Succinct documentation.
+ */
+ virtual const char* GetTerseDocumentation()
+ {
+ return "Set a property of the tests.";
+ }
+
+ /**
+ * Longer documentation.
+ */
+ virtual const char* GetFullDocumentation()
+ {
+ return
+ " SET_TESTS_PROPERTIES(test1 [test2...] PROPERTIES prop1 value1 prop2 value2)\n"
+ "Set a property for the tests. If the "
+ "property is not found, CMake will report an error.";
+ }
+
+ cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand);
+};
+
+
+
+#endif
diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx
index bf999fef7d..ccef841377 100644
--- a/Source/cmTest.cxx
+++ b/Source/cmTest.cxx
@@ -49,3 +49,38 @@ void cmTest::SetArguments(const std::vector<cmStdString>& args)
m_Args = args;
}
+const char *cmTest::GetProperty(const char* prop) const
+{
+ std::map<cmStdString,cmStdString>::const_iterator i =
+ m_Properties.find(prop);
+ if (i != m_Properties.end())
+ {
+ return i->second.c_str();
+ }
+ return 0;
+}
+
+bool cmTest::GetPropertyAsBool(const char* prop) const
+{
+ std::map<cmStdString,cmStdString>::const_iterator i =
+ m_Properties.find(prop);
+ if (i != m_Properties.end())
+ {
+ return cmSystemTools::IsOn(i->second.c_str());
+ }
+ return false;
+}
+
+void cmTest::SetProperty(const char* prop, const char* value)
+{
+ if (!prop)
+ {
+ return;
+ }
+ if (!value)
+ {
+ value = "NOTFOUND";
+ }
+ m_Properties[prop] = value;
+}
+
diff --git a/Source/cmTest.h b/Source/cmTest.h
index e5dd1ededf..506b27622e 100644
--- a/Source/cmTest.h
+++ b/Source/cmTest.h
@@ -34,11 +34,11 @@ public:
///! Set the test name
void SetName(const char* name);
- const char* GetName() { return m_Name.c_str(); }
+ const char* GetName() const { return m_Name.c_str(); }
void SetCommand(const char* command);
- const char* GetCommand() { return m_Command.c_str(); }
+ const char* GetCommand() const { return m_Command.c_str(); }
void SetArguments(const std::vector<cmStdString>& args);
- std::vector<cmStdString>& GetArguments()
+ const std::vector<cmStdString>& GetArguments() const
{
return m_Args;
}