ENH: More ctest changes and move SetupTest to superclass
This commit is contained in:
parent
6cd36d16e5
commit
86cebea79a
|
@ -44,7 +44,7 @@ void cmAddTestCommand::FinalPass()
|
|||
std::string fname;
|
||||
fname = m_Makefile->GetStartOutputDirectory();
|
||||
fname += "/";
|
||||
if ( m_Makefile->IsOn("DART_ROOT") )
|
||||
if ( m_Makefile->IsSet("DART_ROOT") )
|
||||
{
|
||||
fname += "DartTestfile.txt";
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ void cmEnableTestingCommand::CreateDartTestfileForMakefile(cmMakefile *mf)
|
|||
std::string fname;
|
||||
fname = mf->GetStartOutputDirectory();
|
||||
fname += "/";
|
||||
if ( m_Makefile->IsOn("DART_ROOT") )
|
||||
if ( m_Makefile->IsSet("DART_ROOT") )
|
||||
{
|
||||
fname += "DartTestfile.txt";
|
||||
}
|
||||
|
|
|
@ -989,3 +989,77 @@ cmGlobalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
|
|||
return relative;
|
||||
}
|
||||
|
||||
inline std::string removeQuotes(const std::string& s)
|
||||
{
|
||||
if(s[0] == '\"' && s[s.size()-1] == '\"')
|
||||
{
|
||||
return s.substr(1, s.size()-2);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void cmGlobalGenerator::SetupTests()
|
||||
{
|
||||
std::string ctest =
|
||||
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
ctest = removeQuotes(ctest);
|
||||
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
|
||||
ctest += "/";
|
||||
ctest += "ctest";
|
||||
ctest += cmSystemTools::GetExecutableExtension();
|
||||
if(!cmSystemTools::FileExists(ctest.c_str()))
|
||||
{
|
||||
ctest =
|
||||
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
|
||||
ctest += "/Debug/";
|
||||
ctest += "ctest";
|
||||
ctest += cmSystemTools::GetExecutableExtension();
|
||||
}
|
||||
if(!cmSystemTools::FileExists(ctest.c_str()))
|
||||
{
|
||||
ctest =
|
||||
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
|
||||
ctest += "/Release/";
|
||||
ctest += "ctest";
|
||||
ctest += cmSystemTools::GetExecutableExtension();
|
||||
}
|
||||
// if we found ctest
|
||||
if (cmSystemTools::FileExists(ctest.c_str()))
|
||||
{
|
||||
// Create a full path filename for output Testfile
|
||||
std::string fname;
|
||||
fname = m_CMakeInstance->GetStartOutputDirectory();
|
||||
fname += "/";
|
||||
if ( m_LocalGenerators[0]->GetMakefile()->IsSet("DART_ROOT") )
|
||||
{
|
||||
fname += "DartTestfile.txt";
|
||||
}
|
||||
else
|
||||
{
|
||||
fname += "CTestTestfile.txt";
|
||||
}
|
||||
|
||||
// If the file doesn't exist, then ENABLE_TESTING hasn't been run
|
||||
if (cmSystemTools::FileExists(fname.c_str()))
|
||||
{
|
||||
const char* no_output = 0;
|
||||
std::vector<std::string> no_depends;
|
||||
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||
for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
|
||||
{
|
||||
std::vector<cmLocalGenerator*>& gen = it->second;
|
||||
// add the ALL_BUILD to the first local generator of each project
|
||||
if(gen.size())
|
||||
{
|
||||
gen[0]->GetMakefile()->
|
||||
AddUtilityCommand("RUN_TESTS", false, no_output, no_depends,
|
||||
ctest.c_str(), "-C", "$(IntDir)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ protected:
|
|||
void FindMakeProgram(cmMakefile*);
|
||||
|
||||
void ConfigureRelativePaths();
|
||||
void SetupTests();
|
||||
|
||||
bool m_ForceUnixPaths;
|
||||
cmStdString m_FindMakeProgramFile;
|
||||
|
|
|
@ -371,75 +371,6 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
inline std::string removeQuotes(const std::string& s)
|
||||
{
|
||||
if(s[0] == '\"' && s[s.size()-1] == '\"')
|
||||
{
|
||||
return s.substr(1, s.size()-2);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
void cmGlobalVisualStudio6Generator::SetupTests()
|
||||
{
|
||||
std::string ctest =
|
||||
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
ctest = removeQuotes(ctest);
|
||||
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
|
||||
ctest += "/";
|
||||
ctest += "ctest";
|
||||
ctest += cmSystemTools::GetExecutableExtension();
|
||||
if(!cmSystemTools::FileExists(ctest.c_str()))
|
||||
{
|
||||
ctest =
|
||||
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
|
||||
ctest += "/Debug/";
|
||||
ctest += "ctest";
|
||||
ctest += cmSystemTools::GetExecutableExtension();
|
||||
}
|
||||
if(!cmSystemTools::FileExists(ctest.c_str()))
|
||||
{
|
||||
ctest =
|
||||
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
|
||||
ctest += "/Release/";
|
||||
ctest += "ctest";
|
||||
ctest += cmSystemTools::GetExecutableExtension();
|
||||
}
|
||||
// if we found ctest
|
||||
if (cmSystemTools::FileExists(ctest.c_str()))
|
||||
{
|
||||
// Create a full path filename for output Testfile
|
||||
std::string fname;
|
||||
fname = m_CMakeInstance->GetStartOutputDirectory();
|
||||
fname += "/";
|
||||
fname += "DartTestfile.txt";
|
||||
|
||||
// If the file doesn't exist, then ENABLE_TESTING hasn't been run
|
||||
if (cmSystemTools::FileExists(fname.c_str()))
|
||||
{
|
||||
const char* no_output = 0;
|
||||
std::vector<std::string> no_depends;
|
||||
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||
for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
|
||||
{
|
||||
std::vector<cmLocalGenerator*>& gen = it->second;
|
||||
// add the ALL_BUILD to the first local generator of each project
|
||||
if(gen.size())
|
||||
{
|
||||
gen[0]->GetMakefile()->
|
||||
AddUtilityCommand("RUN_TESTS", false, no_output, no_depends,
|
||||
ctest.c_str(), "-C", "$(IntDir)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write a dsp file into the DSW file,
|
||||
// Note, that dependencies from executables to
|
||||
// the libraries it uses are also done here
|
||||
|
|
|
@ -78,7 +78,6 @@ public:
|
|||
std::vector<cmLocalGenerator*>& generators);
|
||||
private:
|
||||
void GenerateConfigurations(cmMakefile* mf);
|
||||
void SetupTests();
|
||||
void WriteDSWFile(std::ostream& fout);
|
||||
void WriteDSWHeader(std::ostream& fout);
|
||||
void WriteProject(std::ostream& fout,
|
||||
|
|
|
@ -128,63 +128,6 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator()
|
|||
return lg;
|
||||
}
|
||||
|
||||
|
||||
void cmGlobalVisualStudio7Generator::SetupTests()
|
||||
{
|
||||
std::string ctest =
|
||||
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
|
||||
ctest += "/";
|
||||
ctest += "ctest";
|
||||
ctest += cmSystemTools::GetExecutableExtension();
|
||||
if(!cmSystemTools::FileExists(ctest.c_str()))
|
||||
{
|
||||
ctest =
|
||||
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
|
||||
ctest += "/Debug/";
|
||||
ctest += "ctest";
|
||||
ctest += cmSystemTools::GetExecutableExtension();
|
||||
}
|
||||
if(!cmSystemTools::FileExists(ctest.c_str()))
|
||||
{
|
||||
ctest =
|
||||
m_LocalGenerators[0]->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
|
||||
ctest += "/Release/";
|
||||
ctest += "ctest";
|
||||
ctest += cmSystemTools::GetExecutableExtension();
|
||||
}
|
||||
// if we found ctest
|
||||
if (cmSystemTools::FileExists(ctest.c_str()))
|
||||
{
|
||||
// Create a full path filename for output Testfile
|
||||
std::string fname;
|
||||
fname = m_CMakeInstance->GetStartOutputDirectory();
|
||||
fname += "/";
|
||||
fname += "DartTestfile.txt";
|
||||
|
||||
// If the file doesn't exist, then ENABLE_TESTING hasn't been run
|
||||
if (cmSystemTools::FileExists(fname.c_str()))
|
||||
{
|
||||
const char* no_output = 0;
|
||||
std::vector<std::string> no_depends;
|
||||
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||
for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
|
||||
{
|
||||
std::vector<cmLocalGenerator*>& gen = it->second;
|
||||
// add the ALL_BUILD to the first local generator of each project
|
||||
if(gen.size())
|
||||
{
|
||||
gen[0]->GetMakefile()->
|
||||
AddUtilityCommand("RUN_TESTS", false, no_output, no_depends,
|
||||
ctest.c_str(), "-C", "$(IntDir)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf)
|
||||
{
|
||||
// process the configurations
|
||||
|
|
|
@ -97,7 +97,6 @@ protected:
|
|||
virtual void WriteSLNFooter(std::ostream& fout);
|
||||
virtual void WriteSLNHeader(std::ostream& fout);
|
||||
|
||||
void SetupTests();
|
||||
void GenerateConfigurations(cmMakefile* mf);
|
||||
|
||||
void WriteExternalProject(std::ostream& fout,
|
||||
|
|
|
@ -1232,6 +1232,27 @@ bool cmMakefile::IsOn(const char* name) const
|
|||
return cmSystemTools::IsOn(value);
|
||||
}
|
||||
|
||||
bool cmMakefile::IsSet(const char* name) const
|
||||
{
|
||||
const char* value = this->GetDefinition(name);
|
||||
if ( !value )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! *value )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( cmSystemTools::IsNOTFOUND(value) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* cmMakefile::GetRequiredDefinition(const char* name) const
|
||||
{
|
||||
const char* ret = this->GetDefinition(name);
|
||||
|
|
|
@ -496,6 +496,7 @@ public:
|
|||
* returns false if no entry defined.
|
||||
*/
|
||||
bool IsOn(const char* name) const;
|
||||
bool IsSet(const char* name) const;
|
||||
|
||||
/**
|
||||
* Get a list of preprocessor define flags.
|
||||
|
|
Loading…
Reference in New Issue