ENH: move testing stuff to cmake from configure, good bye dashboard... :)

This commit is contained in:
Bill Hoffman 2001-05-04 11:30:46 -04:00
parent 33e1a4a09a
commit de10cfc72e
19 changed files with 177 additions and 265 deletions

View File

@ -24,7 +24,6 @@ CMakeTargets.make: ${CMAKE} ${srcdir}/CMakeLists.txt ${CMAKE_CONFIG_DIR}/CMakeCa
${CMAKE} ${currentdir}/CMakeLists.txt -S${currentdir} -O${currentbindir} -H${topdir} -B${CMAKE_CONFIG_DIR}
rebuild_cache: ${CMAKE_CONFIG_DIR}/CMakeCache.txt
rm -f ${CMAKE_CONFIG_DIR}/CMakeCache.txt
${CMAKE} ${topdir}/CMakeLists.txt -MakeCache -S${topdir} -O${CMAKE_CONFIG_DIR} -H${topdir} -B${CMAKE_CONFIG_DIR}
${CMAKE_CONFIG_DIR}/CMakeCache.txt:

11
CMakeSystemConfig.txt.in Normal file
View File

@ -0,0 +1,11 @@
#
# CMakeLocal.make.in should be in the directory where you run configure
# in, which need not be the source directory
#
SET (CXXCOMPILER @CXX@)
SET (WORDS_BIGENDIAN @WORDS_BIGENDIAN@)
SET (HAVE_LIMITS_H @HAVE_LIMITS_H@)
SET (HAVE_UNISTD_H @HAVE_UNISTD_H@)

View File

@ -0,0 +1,10 @@
#
# CMakeLocal.make.in should be in the directory where you run configure
# in, which need not be the source directory
#
SET (WORDS_BIGENDIAN )
SET (HAVE_LIMITS_H 1)
SET (HAVE_UNISTD_H 1)
SET (CXXCOMPILER VC-60)

View File

@ -103,7 +103,7 @@ BEGIN
GROUPBOX "Cache Values",IDC_STATIC,9,43,356,141
LISTBOX IDC_LIST2,15,55,344,122,LBS_OWNERDRAWVARIABLE |
LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
WS_TABSTOP
WS_HSCROLL | WS_TABSTOP
CTEXT "Right click on cache entries for additional options",
IDC_STATIC,19,190,333,11
END

View File

@ -1,56 +0,0 @@
/*=========================================================================
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 "cmAddTargetCommand.h"
// cmAddTargetCommand
bool cmAddTargetCommand::Invoke(std::vector<std::string>& args)
{
if(args.size() < 2 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string> dep;
m_Makefile->AddUtilityCommand(args[0].c_str(),
args[1].c_str());
return true;
}

View File

@ -1,97 +0,0 @@
/*=========================================================================
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 cmAddTargetCommand_h
#define cmAddTargetCommand_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
/** \class cmAddTargetCommand
* \brief Command that adds a target to the build system.
*
* cmAddTargetCommand adds an extra target to the build system.
* This is useful when you would like to add special
* targets like "install,", "clean," and so on.
*/
class cmAddTargetCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmAddTargetCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool Invoke(std::vector<std::string>& args);
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName()
{return "ADD_TARGET";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Add an extra target to the build system.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"ADD_TARGET(Name \"command to run\")";
}
cmTypeMacro(cmAddTargetCommand, cmCommand);
};
#endif

View File

@ -295,6 +295,11 @@ void cmCacheManager::AddCacheEntry(const char* key,
CacheEntry e;
e.m_Value = value;
e.m_Type = type;
// make sure we only use unix style paths
if(type == FILEPATH || type == PATH)
{
cmSystemTools::ConvertToUnixSlashes(e.m_Value);
}
e.m_HelpString = helpString;
m_Cache[key] = e;
}

View File

@ -6,7 +6,7 @@
#include "cmAbstractFilesCommand.cxx"
#include "cmAddExecutableCommand.cxx"
#include "cmAddLibraryCommand.cxx"
#include "cmAddTargetCommand.cxx"
#include "cmAddCustomTargetCommand.cxx"
#include "cmAuxSourceDirectoryCommand.cxx"
#include "cmFindLibraryCommand.cxx"
#include "cmFindProgramCommand.cxx"
@ -48,13 +48,21 @@
#include "cmAddDefinitionsCommand.cxx"
#include "cmOptionCommand.cxx"
#include "cmIncludeCommand.cxx"
#include "cmSiteNameCommand.cxx"
#include "cmBuildNameCommand.cxx"
#include "cmExecProgram.cxx"
#include "cmBuildCommand.cxx"
void GetPredefinedCommands(std::list<cmCommand*>& commands)
{
commands.push_back(new cmBuildCommand);
commands.push_back(new cmExecProgram);
commands.push_back(new cmBuildNameCommand);
commands.push_back(new cmSiteNameCommand);
commands.push_back(new cmAbstractFilesCommand);
commands.push_back(new cmAddExecutableCommand);
commands.push_back(new cmAddLibraryCommand);
commands.push_back(new cmAddTargetCommand);
commands.push_back(new cmAddCustomTargetCommand);
commands.push_back(new cmAuxSourceDirectoryCommand);
commands.push_back(new cmFindLibraryCommand);
commands.push_back(new cmFindProgramCommand);

View File

@ -122,10 +122,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// than one dsp could have been created per input CMakeLists.txt file
// for each target
std::vector<std::string> dspnames = pg->GetDSPMakefile()->GetCreatedProjectNames();
const cmTargets &tgts = pg->GetDSPMakefile()->GetMakefile()->GetTargets();
cmTargets::const_iterator l = tgts.begin();
std::vector<std::string> originalUtilities;
bool addedUtilities = false;
cmTargets &tgts = pg->GetDSPMakefile()->GetMakefile()->GetTargets();
cmTargets::iterator l = tgts.begin();
for(std::vector<std::string>::iterator si = dspnames.begin();
l != tgts.end(); ++l, ++si)
{
@ -139,8 +137,6 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// vector on the makefile
if(l->first == "ALL_BUILD")
{
addedUtilities = true;
originalUtilities = m_Makefile->GetUtilities();
for(std::vector<cmMakefile*>::iterator a = allListFiles.begin();
a != allListFiles.end(); ++a)
{
@ -150,7 +146,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
{
if(al->second.GetType() != cmTarget::UTILITY)
{
m_Makefile->GetUtilities().push_back(al->first);
l->second.GetLinkLibraries().push_back(
cmTarget::LinkLibraries::value_type(al->first, cmTarget::GENERAL));
}
}
}
@ -159,11 +156,6 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// Write the project into the DSW file
this->WriteProject(fout, si->c_str(), dir.c_str(),
pg->GetDSPMakefile(),l->second);
if(addedUtilities)
{
m_Makefile->GetUtilities() = originalUtilities;
}
}
// delete the cmMakefile which also deletes the cmMSProjectGenerator
if(mf != m_Makefile)

View File

@ -122,10 +122,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// than one dsp could have been created per input CMakeLists.txt file
// for each target
std::vector<std::string> dspnames = pg->GetDSPMakefile()->GetCreatedProjectNames();
const cmTargets &tgts = pg->GetDSPMakefile()->GetMakefile()->GetTargets();
cmTargets::const_iterator l = tgts.begin();
std::vector<std::string> originalUtilities;
bool addedUtilities = false;
cmTargets &tgts = pg->GetDSPMakefile()->GetMakefile()->GetTargets();
cmTargets::iterator l = tgts.begin();
for(std::vector<std::string>::iterator si = dspnames.begin();
l != tgts.end(); ++l, ++si)
{
@ -139,8 +137,6 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// vector on the makefile
if(l->first == "ALL_BUILD")
{
addedUtilities = true;
originalUtilities = m_Makefile->GetUtilities();
for(std::vector<cmMakefile*>::iterator a = allListFiles.begin();
a != allListFiles.end(); ++a)
{
@ -150,7 +146,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
{
if(al->second.GetType() != cmTarget::UTILITY)
{
m_Makefile->GetUtilities().push_back(al->first);
l->second.GetLinkLibraries().push_back(
cmTarget::LinkLibraries::value_type(al->first, cmTarget::GENERAL));
}
}
}
@ -159,11 +156,6 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// Write the project into the DSW file
this->WriteProject(fout, si->c_str(), dir.c_str(),
pg->GetDSPMakefile(),l->second);
if(addedUtilities)
{
m_Makefile->GetUtilities() = originalUtilities;
}
}
// delete the cmMakefile which also deletes the cmMSProjectGenerator
if(mf != m_Makefile)

View File

@ -90,7 +90,10 @@ bool cmFindProgramCommand::Invoke(std::vector<std::string>& args)
m_Makefile->AddDefinition(define, result.c_str());
return true;
}
return false;
std::string error = "Faild to find program: \"";
error += *i;
error += "\" ";
this->SetError(error.c_str());
return true;
}

View File

@ -155,6 +155,11 @@ void cmMakefile::Print() const
this->PrintStringVector("m_LinkDirectories", m_LinkDirectories);
this->PrintStringVector("m_Utilities", m_Utilities);
this->PrintStringVector("m_UtilityDirectories", m_UtilityDirectories);
for( std::vector<cmSourceGroup>::const_iterator i = m_SourceGroups.begin();
i != m_SourceGroups.end(); ++i)
{
i->Print();
}
}
// Parse the given CMakeLists.txt file into a list of classes.
@ -231,62 +236,50 @@ bool cmMakefile::ReadListFile(const char* filename, const char* external)
std::vector<std::string> arguments;
while ( fin )
{
// add this list file to the list of dependencies
m_ListFiles.push_back( filenametoread);
// add this list file to the list of dependencies
m_ListFiles.push_back( filenametoread);
if(cmSystemTools::ParseFunction(fin, name, arguments) &&
!this->IsFunctionBlocked(name.c_str(),arguments))
{
// Special command that needs to be removed when
// ADD_COMMAND is implemented
if(name == "VERBATIM")
RegisteredCommandsMap::iterator pos = m_Commands.find(name);
if(pos != m_Commands.end())
{
if (!inheriting)
cmCommand* rm = (*pos).second;
cmCommand* usedCommand = rm->Clone();
usedCommand->SetMakefile(this);
bool keepCommand = false;
if(usedCommand->GetEnabled())
{
m_MakeVerbatim = arguments;
// if not running in inherit mode or
// if the command is inherited then Invoke it.
if(!inheriting || usedCommand->IsInherited())
{
if(!usedCommand->Invoke(arguments))
{
cmSystemTools::Error(usedCommand->GetName(),
": Error : \n",
usedCommand->GetError(),
m_cmCurrentDirectory.c_str());
}
else
{
// use the command
keepCommand = true;
m_UsedCommands.push_back(usedCommand);
}
}
}
// if the Cloned command was not used
// then delete it
if(!keepCommand)
{
delete usedCommand;
}
}
else
{
RegisteredCommandsMap::iterator pos = m_Commands.find(name);
if(pos != m_Commands.end())
{
cmCommand* rm = (*pos).second;
cmCommand* usedCommand = rm->Clone();
usedCommand->SetMakefile(this);
bool keepCommand = false;
if(usedCommand->GetEnabled())
{
// if not running in inherit mode or
// if the command is inherited then Invoke it.
if(!inheriting || usedCommand->IsInherited())
{
if(!usedCommand->Invoke(arguments))
{
cmSystemTools::Error(usedCommand->GetName(),
": Error : \n",
usedCommand->GetError(),
m_cmCurrentDirectory.c_str());
}
else
{
// use the command
keepCommand = true;
m_UsedCommands.push_back(usedCommand);
}
}
}
// if the Cloned command was not used
// then delete it
if(!keepCommand)
{
delete usedCommand;
}
}
else
{
cmSystemTools::Error("unknown CMake command ", name.c_str());
}
cmSystemTools::Error("unknown CMake command ", name.c_str(), filename);
}
}
}
@ -663,11 +656,11 @@ void cmMakefile::RemoveVariablesInString(std::string& source) const
cmRegularExpression var2("(@[A-Za-z_0-9]*@)");
while (var.find(source))
{
source.erase(var.start(),var.end());
source.erase(var.start(),var.end() - var.start());
}
while (var2.find(source))
{
source.erase(var2.start(),var2.end());
source.erase(var2.start(),var2.end() - var2.start());
}
}

View File

@ -55,10 +55,15 @@ bool cmOptionCommand::Invoke(std::vector<std::string>& args)
= cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
if(!cacheValue)
{
const char* initialValue = "Off";
if(args.size() == 3)
{
initialValue = args[2].c_str();
}
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
false,
cmSystemTools::IsOn(initialValue),
args[1].c_str());
m_Makefile->AddDefinition(args[0].c_str(), "Off");
m_Makefile->AddDefinition(args[0].c_str(), initialValue);
}
else
{

View File

@ -91,7 +91,7 @@ public:
virtual const char* GetFullDocumentation()
{
return
"OPTION(USE_MPI \"help string decribing the option\")\n"
"OPTION(USE_MPI \"help string decribing the option\" [initial value])\n"
"Provide an option for the user to select";
}

View File

@ -122,6 +122,24 @@ void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd)
commandFiles.m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().end());
}
void cmSourceGroup::Print() const
{
std::cout << "cmSourceGroup: " << m_Name.c_str() << "\n";
for(BuildRules::const_iterator i = m_BuildRules.begin();
i != m_BuildRules.end(); ++i)
{
std::cout << "BuildRule: " << i->first.c_str() << "\n";
for(Commands::const_iterator j = i->second.begin();
j != i->second.end(); ++j)
{
std::cout << "Command: " << j->first.c_str() << "\n";
std::cout << "Command Outputs " << j->second.m_Outputs.size() << "\n";
std::cout << "Command Depends " << j->second.m_Depends.size() << "\n";
}
}
}
void cmSourceGroup::CommandFiles::Merge(const CommandFiles &r)
{
std::set<std::string>::const_iterator dep = r.m_Depends.begin();
@ -137,3 +155,4 @@ void cmSourceGroup::CommandFiles::Merge(const CommandFiles &r)
}

View File

@ -90,7 +90,7 @@ public:
{ return m_Name.c_str(); }
const BuildRules& GetBuildRules() const
{ return m_BuildRules; }
void Print() const;
private:
/**
* The name of the source group.

View File

@ -105,6 +105,11 @@ void cmSystemTools::GetPath(std::vector<std::string>& path)
done = true;
}
}
for(std::vector<std::string>::iterator i = path.begin();
i != path.end(); ++i)
{
cmSystemTools::ConvertToUnixSlashes(*i);
}
}
@ -277,35 +282,6 @@ bool cmSystemTools::ParseFunction(std::ifstream& fin,
cmRegularExpression multiLine("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)$");
cmRegularExpression lastLine("^(.*)\\)[ \t]*$");
// BEGIN VERBATIM JUNK SHOULD BE REMOVED
cmRegularExpression verbatim("BEGIN MAKE VERBATIM");
if(verbatim.find(inbuffer))
{
cmRegularExpression endVerbatim("END MAKE VERBATIM");
name = "VERBATIM";
bool done = false;
while(!done)
{
if(fin.getline(inbuffer, BUFFER_SIZE))
{
if(endVerbatim.find(inbuffer))
{
done = true;
}
else
{
arguments.push_back(inbuffer);
}
}
else
{
done = true;
}
}
return true;
}
// END VERBATIM JUNK SHOULD BE REMOVED
// check for black line or comment
if(blankLine.find(inbuffer) || comment.find(inbuffer))
{
@ -584,6 +560,46 @@ bool cmSystemTools::IsOff(const char* val)
}
bool cmSystemTools::RunCommand(const char* command,
std::string& output)
{
std::string commandToFile = command;
commandToFile += " > ";
std::string tempFile;
tempFile += cmSystemTools::TemporaryFileName();
commandToFile += tempFile;
system(commandToFile.c_str());
std::ifstream fin(tempFile.c_str());
if(!fin)
{
cmSystemTools::Error(command, " from RunCommand Faild to create output file",
tempFile.c_str());
return false;
}
const int BUFFER_SIZE = 4096;
char buffer[BUFFER_SIZE];
while(fin)
{
fin.getline(buffer, BUFFER_SIZE);
output += buffer;
}
cmSystemTools::RemoveFile(tempFile.c_str());
return true;
}
#ifdef _MSC_VER
#define tempnam _tempnam
#endif
std::string cmSystemTools::TemporaryFileName()
{
return tempnam(0, "cmake");
}
/**
* Find the executable with the given name. Searches the given path and then
* the system search path. Returns the full path to the executable if it is
@ -718,3 +734,4 @@ std::string cmSystemTools::CollapseFullPath(const char* in_name)
return newPath;
}

View File

@ -177,6 +177,17 @@ public:
static long int ModifiedTime(const char* filename);
/**
* Run an executable command and put the stdout in output.
* A temporary file is created in the binaryDir for storing the
* output because windows does not have popen.
*/
static bool RunCommand(const char* command,
std::string& output);
///! Generate a temporary file name
static std::string TemporaryFileName();
private:
static bool s_ErrorOccured;
};

View File

@ -460,7 +460,7 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
sourceGroup.AddCustomCommand(cc);
}
}
// Loop through every source group.
for(std::vector<cmSourceGroup>::const_iterator sg =
sourceGroups.begin(); sg != sourceGroups.end(); ++sg)