From 38145ad5a4cceebc17f434e3c1068c8cc5bb5461 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Wed, 19 Jun 2002 12:52:16 -0400 Subject: [PATCH] modified create test source to create a vector --- Source/cmCreateTestSourceList.cxx | 13 +++++++++---- Source/cmCreateTestSourceList.h | 21 ++++++++++++--------- Source/cmSourceFile.cxx | 1 + Source/cmTarget.cxx | 21 +++++++++++++++------ Tests/TestDriver/CMakeLists.txt | 2 +- 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx index 5fc64b7cd..d320f5223 100644 --- a/Source/cmCreateTestSourceList.cxx +++ b/Source/cmCreateTestSourceList.cxx @@ -257,15 +257,17 @@ bool cmCreateTestSourceList::InitialPass(std::vector const& argsIn) fout.close(); // Create the source list - cmSourceFile cfile; + std::string sourceListValue; + cfile.SetIsAnAbstractClass(false); cfile.SetName(args[1].c_str(), m_Makefile->GetCurrentOutputDirectory(), "cxx", false); - m_Makefile->AddSource(cfile, sourceList); - + m_Makefile->AddSource(cfile); + sourceListValue = args[1].c_str(); + for(i = testsBegin; i != tests.end(); ++i) { cmSourceFile cfile; @@ -274,9 +276,12 @@ bool cmCreateTestSourceList::InitialPass(std::vector const& argsIn) m_Makefile->GetCurrentDirectory(), m_Makefile->GetSourceExtensions(), m_Makefile->GetHeaderExtensions()); - m_Makefile->AddSource(cfile, sourceList); + m_Makefile->AddSource(cfile); + sourceListValue += ";"; + sourceListValue += *i; } + m_Makefile->AddDefinition(sourceList, sourceListValue.c_str()); return true; } diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h index 102226ec7..8db0814f4 100644 --- a/Source/cmCreateTestSourceList.h +++ b/Source/cmCreateTestSourceList.h @@ -67,16 +67,19 @@ public: virtual const char* GetFullDocumentation() { return - "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.\n" - "DriverName.cxx is the name of the test driver program.\n" - "The rest of the arguments consist of a list of test source files, can be " + "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 " + "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 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 is passed " - "a pointer to ac and av. This can be used to add extra command line processing to each test. "; + "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 " + "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 " + "is passed a pointer to ac and av. This can be used to add extra " + "command line processing to each test. "; } cmTypeMacro(cmCreateTestSourceList, cmCommand); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 43ebf52cf..0f6e270dc 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -122,6 +122,7 @@ void cmSourceFile::SetName(const char* name, const char* dir, } cmSystemTools::Error("can not find file ", pathname.c_str(), errorMsg.c_str()); + int a = *(int *)0x00; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index bbb861c83..f24da58f0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -50,12 +50,21 @@ void cmTarget::GenerateSourceFilesFromSourceLists( cmMakefile &mf) // if one wasn't found then assume it is a single class else { - cmSourceFile file; - file.SetIsAnAbstractClass(false); - file.SetName(temps.c_str(), mf.GetCurrentDirectory(), - mf.GetSourceExtensions(), - mf.GetHeaderExtensions()); - m_SourceFiles.push_back(mf.AddSource(file)); + // if the source file is already in the makefile, use it + if (mf.GetSource(temps.c_str())) + { + m_SourceFiles.push_back(mf.GetSource(temps.c_str())); + } + // otherwise try to create it + else + { + cmSourceFile file; + file.SetIsAnAbstractClass(false); + file.SetName(temps.c_str(), mf.GetCurrentDirectory(), + mf.GetSourceExtensions(), + mf.GetHeaderExtensions()); + m_SourceFiles.push_back(mf.AddSource(file)); + } } } diff --git a/Tests/TestDriver/CMakeLists.txt b/Tests/TestDriver/CMakeLists.txt index 2e0a1fa5d..90f37e169 100644 --- a/Tests/TestDriver/CMakeLists.txt +++ b/Tests/TestDriver/CMakeLists.txt @@ -10,5 +10,5 @@ CREATE_TEST_SOURCELIST(testSrcs subdir/test3 EXTRA_INCLUDE testArgs.h FUNCTION testProccessArgs) -ADD_EXECUTABLE(TestDriverTest testSrcs ${Extra_SRCS}) +ADD_EXECUTABLE(TestDriverTest ${testSrcs} ${Extra_SRCS})