summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2002-07-30 20:19:14 (GMT)
committerKen Martin <ken.martin@kitware.com>2002-07-30 20:19:14 (GMT)
commit0f6e022dcab5ab5ede08153da11fc4330c223cea (patch)
tree0a6b839ed3519dc6b150cd217d5cd2957b5a4109
parentc05e3613ce61c0a330df7102b9660ec9da37bf3d (diff)
downloadCMake-0f6e022dcab5ab5ede08153da11fc4330c223cea.zip
CMake-0f6e022dcab5ab5ede08153da11fc4330c223cea.tar.gz
CMake-0f6e022dcab5ab5ede08153da11fc4330c223cea.tar.bz2
updated to handle extensions
-rw-r--r--Source/cmCreateTestSourceList.cxx41
-rw-r--r--Source/cmCreateTestSourceList.h4
2 files changed, 34 insertions, 11 deletions
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index 9df7a25..464400a 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -69,11 +69,15 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
++i;
// Name of the test driver
-
+ // make sure they specified an extension
+ if (cmSystemTools::GetFilenameExtension(*i).size() < 1)
+ {
+ this->SetError("You must specify a file extenion for the test driver file.");
+ return false;
+ }
std::string driver = m_Makefile->GetCurrentOutputDirectory();
driver += "/";
driver += *i;
- driver += ".cxx";
++i;
std::ofstream fout(driver.c_str());
@@ -119,20 +123,29 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
{
break;
}
- std::string func_name = *i;
+ std::string func_name;
+ if (cmSystemTools::GetFilenamePath(*i).size() > 0)
+ {
+ func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
+ cmSystemTools::GetFilenameWithoutLastExtension(*i);
+ }
+ else
+ {
+ func_name = cmSystemTools::GetFilenameWithoutLastExtension(*i);
+ }
cmSystemTools::ConvertToUnixSlashes(func_name);
cmSystemTools::ReplaceString(func_name, " ", "_");
cmSystemTools::ReplaceString(func_name, "/", "_");
cmSystemTools::ReplaceString(func_name, ":", "_");
tests_func_name.push_back(func_name);
- fout << "int " << func_name << "(int, char**);\n";
+ fout << "int " << func_name << "(int, char*[]);\n";
}
fout <<
"\n"
"// Create map\n"
"\n"
- "typedef int (*MainFuncPointer)(int , char**);\n"
+ "typedef int (*MainFuncPointer)(int , char*[]);\n"
"struct functionMapEntry\n"
"{\n"
" const char* name;\n"
@@ -145,9 +158,19 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
std::vector<std::string>::iterator j;
for(i = testsBegin, j = tests_func_name.begin(); i != tests.end(); ++i, ++j)
{
+ std::string func_name;
+ if (cmSystemTools::GetFilenamePath(*i).size() > 0)
+ {
+ func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
+ cmSystemTools::GetFilenameWithoutLastExtension(*i);
+ }
+ else
+ {
+ func_name = cmSystemTools::GetFilenameWithoutLastExtension(*i);
+ }
fout <<
" {\n"
- " \"" << *i << "\",\n"
+ " \"" << func_name << "\",\n"
" " << *j << "\n"
" },\n";
numTests++;
@@ -177,7 +200,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
" return new_string;\n"
"}\n"
"\n"
- "int main(int ac, char** av)\n"
+ "int main(int ac, char *av[])\n"
"{\n"
" int NumTests, i, testNum, partial_match;\n"
" char *arg, *test_name;\n"
@@ -266,12 +289,12 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
std::string sourceListValue;
cfile.SetIsAnAbstractClass(false);
- cfile.SetName(args[1].c_str(),
+ cfile.SetName(cmSystemTools::GetFilenameWithoutExtension(args[1]).c_str(),
m_Makefile->GetCurrentOutputDirectory(),
"cxx",
false);
m_Makefile->AddSource(cfile);
- sourceListValue = args[1] + ".cxx";
+ sourceListValue = args[1];
for(i = testsBegin; i != tests.end(); ++i)
{
diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h
index 8db0814..4b1f3dc 100644
--- a/Source/cmCreateTestSourceList.h
+++ b/Source/cmCreateTestSourceList.h
@@ -70,11 +70,11 @@ public:
"CREATE_TEST_SOURCELIST(SourceListName DriverName test1 test2 test3 "
"EXTRA_INCLUDE include.h FUNCTION function) The list of source files "
"needed to build the testdriver will be in SourceListName. "
- "DriverName.cxx is the name of the test driver program. The rest of "
+ "DriverName is the name of the test driver program. The rest of "
"the arguments consist of a list of test source files, can be "
"; separated. Each test source file should have a function in it that "
"is the same name as the file with no extension (foo.cxx should have "
- "int foo();) DriverName.cxx will be able to call each of the tests by "
+ "int foo();) DriverName will be able to call each of the tests by "
"name on the command line. If EXTRA_INCLUDE is specified, then the "
"next argument is included into the generated file. If FUNCTION is "
"specified, then the next argument is taken as a function name that "