diff options
author | Jim Miller <millerjv@crd.ge.com> | 2001-06-06 00:34:01 (GMT) |
---|---|---|
committer | Jim Miller <millerjv@crd.ge.com> | 2001-06-06 00:34:01 (GMT) |
commit | 84dc25e9f5cde423b0b5b23542f305ac6837fb31 (patch) | |
tree | 4e40a6c85a5e7915cc512a142e18e7c01d017476 /Source/cmMakefile.cxx | |
parent | 6282d41c2a8ca5129565f17dfb9eacdead83c898 (diff) | |
download | CMake-84dc25e9f5cde423b0b5b23542f305ac6837fb31.zip CMake-84dc25e9f5cde423b0b5b23542f305ac6837fb31.tar.gz CMake-84dc25e9f5cde423b0b5b23542f305ac6837fb31.tar.bz2 |
ENH: Added AddTest, and GenerateTestfile routines
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 446729e..a12ac2b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -383,6 +383,87 @@ 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 += "Testfile"; + + // 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; } void cmMakefile::AddSource(cmSourceFile& cmfile, const char *srclist) @@ -489,6 +570,11 @@ 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; |