summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAddTestCommand.cxx43
-rw-r--r--Source/cmAddTestCommand.h9
-rw-r--r--Source/cmCommands.cxx2
-rw-r--r--Source/cmConfigureFileNoAutoconf.cxx10
-rw-r--r--Source/cmEnableTestingCommand.cxx96
-rw-r--r--Source/cmEnableTestingCommand.h117
-rw-r--r--Source/cmMakefile.cxx86
-rw-r--r--Source/cmMakefile.h17
-rw-r--r--Source/cmTestsCommand.cxx1
9 files changed, 266 insertions, 115 deletions
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx
index 4e76b07..1c12b32 100644
--- a/Source/cmAddTestCommand.cxx
+++ b/Source/cmAddTestCommand.cxx
@@ -48,22 +48,57 @@ bool cmAddTestCommand::InitialPass(std::vector<std::string>& args)
// Second argument is the name of the executable to run (a target or external
// program)
// Remaining arguments are the arguments to pass to the executable
-
if(args.size() < 2 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
+
+ // store the aruments for the final pass
+ std::copy(args.begin(),args.end(),m_Args.begin());
+ return true;
+}
+
+// we append to the file in the final pass because Enable Testing command
+// creates the file in the final pass.
+void cmAddTestCommand::FinalPass()
+{
// Expand any CMake variables
std::vector<std::string>::iterator s;
- for (s = args.begin(); s != args.end(); ++s)
+ for (s = m_Args.begin(); s != m_Args.end(); ++s)
{
m_Makefile->ExpandVariablesInString(*s);
}
- m_Makefile->AddTest(args);
+ // Create a full path filename for output Testfile
+ std::string fname;
+ fname = m_Makefile->GetStartOutputDirectory();
+ fname += "/";
+ fname += "CMakeTestfile.txt";
- return true;
+ // Open the output Testfile
+ std::ofstream fout(fname.c_str());
+ if (!fout)
+ {
+ cmSystemTools::Error("Error Writing ", fname.c_str());
+ return;
+ }
+
+ std::vector<std::string>::iterator it;
+
+ // for each arg in the test
+ fout << "ADD_TEST(";
+ it = m_Args.begin();
+ fout << (*it).c_str();
+ ++it;
+ for (; it != m_Args.end(); ++it)
+ {
+ fout << " " << (*it).c_str();
+ }
+ fout << ")" << std::endl;
+ fout.close();
+
+ return;
}
diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h
index 65e1e9e..6137072 100644
--- a/Source/cmAddTestCommand.h
+++ b/Source/cmAddTestCommand.h
@@ -67,6 +67,12 @@ public:
virtual bool InitialPass(std::vector<std::string>& args);
/**
+ * This is called at the end after all the information
+ * specified by the command is accumulated.
+ */
+ virtual void FinalPass();
+
+ /**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "ADD_TEST";}
@@ -94,6 +100,9 @@ public:
}
cmTypeMacro(cmAddTestCommand, cmCommand);
+
+private:
+ std::vector<std::string> m_Args;
};
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index a3fd06f..bdf753a 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -29,6 +29,7 @@
#include "cmConfigureFileCommand.cxx"
#include "cmConfigureFileNoAutoconf.cxx"
#include "cmElseCommand.cxx"
+#include "cmEnableTestingCommand.cxx"
#include "cmEndIfCommand.cxx"
#include "cmExecProgramCommand.cxx"
#include "cmFindFileCommand.cxx"
@@ -87,6 +88,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
commands.push_back(new cmConfigureFileCommand);
commands.push_back(new cmConfigureFileNoAutoconf);
commands.push_back(new cmElseCommand);
+ commands.push_back(new cmEnableTestingCommand);
commands.push_back(new cmEndIfCommand);
commands.push_back(new cmExecProgramCommand);
commands.push_back(new cmFindFileCommand);
diff --git a/Source/cmConfigureFileNoAutoconf.cxx b/Source/cmConfigureFileNoAutoconf.cxx
index 5a5f89f..412b92f 100644
--- a/Source/cmConfigureFileNoAutoconf.cxx
+++ b/Source/cmConfigureFileNoAutoconf.cxx
@@ -43,14 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// cmConfigureFileNoAutoconf
bool cmConfigureFileNoAutoconf::InitialPass(std::vector<std::string>& args)
{
- if(args.size() != 2 )
- {
- this->SetError("called with incorrect number of arguments, expected 2");
- return false;
- }
- m_InputFile = args[0];
- m_OuputFile = args[1];
- return true;
+ this->SetError("The CONFIGURE_FILE_NO_AUTOCONF method is deprecated, please use CONFIGURE_FILE instead.");
+ return false;
}
void cmConfigureFileNoAutoconf::FinalPass()
diff --git a/Source/cmEnableTestingCommand.cxx b/Source/cmEnableTestingCommand.cxx
new file mode 100644
index 0000000..1f42c5f
--- /dev/null
+++ b/Source/cmEnableTestingCommand.cxx
@@ -0,0 +1,96 @@
+/*=========================================================================
+
+ Program: Insight Segmentation & Registration Toolkit
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+Copyright (c) 2001 Insight Consortium
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * The name of the Insight Consortium, nor the names of any consortium members,
+ nor of any contributors, may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ * Modified source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=========================================================================*/
+#include "cmEnableTestingCommand.h"
+#include "cmCacheManager.h"
+
+// we do this in the final pass so that we now the subdirs have all
+// been defined
+void cmEnableTestingCommand::FinalPass()
+{
+ // Create a full path filename for output Testfile
+ std::string fname;
+ fname = m_Makefile->GetStartOutputDirectory();
+ fname += "/";
+ fname += "CMakeTestfile.txt";
+
+ // Open the output Testfile
+ std::ofstream fout(fname.c_str());
+ if (!fout)
+ {
+ cmSystemTools::Error("Error Writing ", fname.c_str());
+ return;
+ }
+
+ fout << "# CMake generated Testfile for " << std::endl
+ << "#\tSource directory: "
+ << m_Makefile->GetStartDirectory()
+ << std::endl
+ << "#\tBuild directory: " << m_Makefile->GetStartOutputDirectory()
+ << std::endl
+ << "# " << std::endl
+ << "# This file replicates the SUBDIRS() and ADD_TEST() commands from the source"
+ << std::endl
+ << "# tree CMakeLists.txt file, skipping any SUBDIRS() or ADD_TEST() commands"
+ << std::endl
+ << "# that are excluded by CMake control structures, i.e. IF() commands."
+ << std::endl
+ << "#"
+ << std::endl << std::endl;
+
+ // write out the subdirs for the current directory
+ if (!m_Makefile->GetSubDirectories().empty())
+ {
+ fout << "SUBDIRS(";
+ const std::vector<std::string>& subdirs = m_Makefile->GetSubDirectories();
+ std::vector<std::string>::const_iterator i = subdirs.begin();
+ fout << (*i).c_str();
+ ++i;
+ for(; i != subdirs.end(); ++i)
+ {
+ fout << " " << (*i).c_str();
+ }
+ fout << ")" << std::endl << std::endl;;
+ }
+ fout.close();
+
+ return;
+}
+
diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h
new file mode 100644
index 0000000..12688f3
--- /dev/null
+++ b/Source/cmEnableTestingCommand.h
@@ -0,0 +1,117 @@
+/*=========================================================================
+
+ Program: Insight Segmentation & Registration Toolkit
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+Copyright (c) 2001 Insight Consortium
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * The name of the Insight Consortium, nor the names of any consortium members,
+ nor of any contributors, may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ * Modified source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=========================================================================*/
+#ifndef cmEnableTestingCommand_h
+#define cmEnableTestingCommand_h
+
+#include "cmStandardIncludes.h"
+#include "cmCommand.h"
+
+/** \class cmEnableTestingCommand
+ * \brief Enable testing for this directory and below.
+ *
+ * Produce the output testfile. This produces a file in the build directory
+ * called CMakeTestfile with a syntax similar to CMakeLists.txt. It contains
+ * the SUBDIRS() and ADD_TEST() commands from the source CMakeLists.txt
+ * file with CMake variables expanded. Only the subdirs and tests
+ * within the valid control structures are replicated in Testfile
+ * (i.e. SUBDIRS() and ADD_TEST() commands within IF() commands that are
+ * not entered by CMake are not replicated in Testfile).
+ */
+class cmEnableTestingCommand : public cmCommand
+{
+public:
+ /**
+ * This is a virtual constructor for the command.
+ */
+ virtual cmCommand* Clone()
+ {
+ return new cmEnableTestingCommand;
+ }
+
+ /**
+ * This determines if the command gets propagated down
+ * to makefiles located in subdirectories.
+ */
+ virtual bool IsInherited() {return true;}
+
+ /**
+ * This is called when the command is first encountered in
+ * the CMakeLists.txt file.
+ */
+ virtual bool InitialPass(std::vector<std::string>& args) {
+ return true;};
+
+ /**
+ * This is called at the end after all the information
+ * specified by the command is accumulated. Most commands do
+ * not implement this method. At this point, reading and
+ * writing to the cache can be done.
+ */
+ virtual void FinalPass();
+
+ /**
+ * The name of the command as specified in CMakeList.txt.
+ */
+ virtual const char* GetName() { return "ENABLE_TESTING";}
+
+ /**
+ * Succinct documentation.
+ */
+ virtual const char* GetTerseDocumentation()
+ {
+ return "Enable testing for this directory and below.";
+ }
+
+ /**
+ * More documentation.
+ */
+ virtual const char* GetFullDocumentation()
+ {
+ return
+ "ENABLE_TESTING()\n"
+ "Enables testing for this directory and below. See also the ADD_TEST command.";
+ }
+
+ cmTypeMacro(cmEnableTestingCommand, cmCommand);
+};
+
+
+#endif
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 86d881a..8d90229 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -383,89 +383,8 @@ void cmMakefile::GenerateMakefile()
}
// now do the generation
m_MakefileGenerator->GenerateMakefile();
-
- // generate any testing files
- this->GenerateTestfile();
}
-void cmMakefile::GenerateTestfile()
-{
- if (m_Tests.empty() && this->GetSubDirectories().empty())
- {
- return;
- }
-
- // Create a full path filename for output Testfile
- std::string fname;
- fname = this->GetCurrentOutputDirectory();
- fname += "/";
- fname += "CMakeTestfile.txt";
-
- // Open the output Testfile
- std::ofstream fout(fname.c_str());
- if (!fout)
- {
- cmSystemTools::Error("Error Writing ", fname.c_str());
- return;
- }
-
- fout << "# CMake generated Testfile for " << std::endl
- << "#\tSource directory: "
- << this->GetCurrentDirectory()
- << std::endl
- << "#\tBuild directory: " << this->GetCurrentOutputDirectory()
- << std::endl
- << "# " << std::endl
- << "# This file replicates the SUBDIRS() and ADD_TEST() commands from the source"
- << std::endl
- << "# tree CMakeLists.txt file, skipping any SUBDIRS() or ADD_TEST() commands"
- << std::endl
- << "# that are excluded by CMake control structures, i.e. IF() commands."
- << std::endl
- << "#"
- << std::endl << std::endl;
-
- // write out the subdirs for the current directory
- if (!this->GetSubDirectories().empty())
- {
- fout << "SUBDIRS(";
- const std::vector<std::string>& subdirs = this->GetSubDirectories();
- std::vector<std::string>::const_iterator i = subdirs.begin();
- fout << (*i).c_str();
- ++i;
- for(; i != subdirs.end(); ++i)
- {
- fout << " " << (*i).c_str();
- }
- fout << ")" << std::endl << std::endl;;
- }
-
-
- // write out each test
- std::vector<std::vector<std::string> >::iterator testIt;
- std::vector<std::string>::iterator it;
-
- // for each test
- for (testIt = m_Tests.begin(); testIt != m_Tests.end(); ++testIt)
- {
- if (!(*testIt).empty())
- {
- // for each arg in the test
- fout << "ADD_TEST(";
- it = (*testIt).begin();
- fout << (*it).c_str();
- ++it;
- for (; it != (*testIt).end(); ++it)
- {
- fout << " " << (*it).c_str();
- }
- fout << ")" << std::endl;
- }
- }
-
- fout << std::endl;
- fout.close();
-}
void cmMakefile::AddSource(cmSourceFile& cmfile, const char *srclist)
{
@@ -571,11 +490,6 @@ void cmMakefile::AddDefinition(const char* name, bool value)
}
}
-void cmMakefile::AddTest(const std::vector<std::string> &args)
-{
- m_Tests.push_back(args);
-}
-
void cmMakefile::SetProjectName(const char* p)
{
m_ProjectName = p;
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index fccd779..c5f5f36 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -112,17 +112,6 @@ public:
void GenerateMakefile();
/**
- * Produce the output testfile. This produces a file in the build directory
- * called Testfile with a syntax similar to CMakeLists.txt. It contains
- * the SUBDIRS() and ADD_TEST() commands from the source CMakeLists.txt
- * file with CMake variables expanded. Only the subdirs and tests
- * within the valid control structures are replicated in Testfile
- * (i.e. SUBDIRS() and ADD_TEST() commands within IF() commands that are
- * not entered by CMake are not replicated in Testfile).
- */
- void GenerateTestfile();
-
- /**
* Print the object state to std::cout.
*/
void Print() const;
@@ -223,11 +212,6 @@ public:
void AddDefinition(const char* name, bool);
/**
- * Add a test to the build.
- */
- void AddTest(const std::vector<std::string> &args);
-
- /**
* Specify the name of the project for this build.
*/
void SetProjectName(const char*);
@@ -526,7 +510,6 @@ protected:
std::vector<std::string> m_Utilities;
std::vector<std::string> m_UtilityDirectories;
std::vector<std::string> m_ListFiles; // list of command files loaded
- std::vector<std::vector<std::string> > m_Tests; // list of tests and args
cmTarget::LinkLibraries m_LinkLibraries;
diff --git a/Source/cmTestsCommand.cxx b/Source/cmTestsCommand.cxx
index d3d8519..39416ee 100644
--- a/Source/cmTestsCommand.cxx
+++ b/Source/cmTestsCommand.cxx
@@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bool cmTestsCommand::InitialPass(std::vector<std::string>& args)
{
// does nothing in CMake
+ this->SetError("The TEST command is deprecated, please use ADD_TEST instead.");
return true;
}