ENH: get rid of special msc configure file

This commit is contained in:
Bill Hoffman 2001-02-12 19:49:52 -05:00
parent 9d431ae48b
commit db267f533b
12 changed files with 204 additions and 108 deletions

View File

@ -47,6 +47,7 @@ int main(int ac, char** av)
{
std::string path = arg.substr(2);
mf.SetOutputHomeDirectory(path.c_str());
mf.SetOutputDirectory(path.c_str());
}
// Set the source home directory with a -H dir option
if(arg.find("-H",0) == 0)
@ -57,6 +58,7 @@ int main(int ac, char** av)
}
}
mf.SetMakefileGenerator(new cmUnixMakefileGenerator);
// Read and parse the input makefile
if(!mf.ReadMakefile(av[1]))
{

View File

@ -252,20 +252,6 @@ void CMakeSetupDialog::OnOK()
m_WhereBuild = m_WhereSource;
}
// configure the system for VC60
cmWindowsConfigure config;
config.SetWhereSource(m_WhereSource);
config.SetWhereBuild(m_WhereBuild);
std::string configSrc;
configSrc = m_WhereSource;
configSrc += "/CMakeSetupConfig.MSC";
if(!config.Configure(configSrc.c_str()))
{
std::string error = "Warning: MSC configure input not found: ";
error += configSrc;
::MessageBox(0, error.c_str(), "config ERROR", MB_OK);
}
cmMakefile mf;
mf.SetMakefileGenerator(new cmMSProjectGenerator);
mf.SetHomeDirectory(m_WhereSource);

View File

@ -6,6 +6,8 @@ VPATH = @srcdir@
# This will cause an infinite loop as it will add the
# command for changing into this directory
# let cmake know that this was done with autoconf
KIT_FLAGS = -DCMAKE_HAS_AUTOCONF
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_CONFIG_DIR@/CMake/CMakeVariables.make@MAKEQUOTE@
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_CONFIG_DIR@/CMake/CMakeSimpleRules.make@MAKEQUOTE@

View File

@ -1,3 +1,8 @@
// This file is used to compile all the commands
// that CMake knows about at compile time.
// This is sort of a boot strapping approach since you would
// like to have CMake to build CMake.
#include "cmCommands.h"
#include "cmAbstractFilesCommand.cxx"
#include "cmAddTargetCommand.cxx"
#include "cmAuxSourceDirectoryCommand.cxx"
@ -18,3 +23,31 @@
#include "cmUnixLibrariesCommand.cxx"
#include "cmWin32DefinesCommand.cxx"
#include "cmWin32LibrariesCommand.cxx"
#include "cmConfigureFileNoAutoconf.cxx"
void GetPredefinedCommands(std::list<cmCommand*>& commands)
{
commands.push_back(new cmAbstractFilesCommand);
commands.push_back(new cmAddTargetCommand);
commands.push_back(new cmAuxSourceDirectoryCommand);
commands.push_back(new cmExecutablesCommand);
commands.push_back(new cmFindIncludeCommand);
commands.push_back(new cmFindLibraryCommand);
commands.push_back(new cmFindProgramCommand);
commands.push_back(new cmIncludeDirectoryCommand);
commands.push_back(new cmLibraryCommand);
commands.push_back(new cmLinkDirectoriesCommand);
commands.push_back(new cmLinkLibrariesCommand);
commands.push_back(new cmProjectCommand);
commands.push_back(new cmSourceFilesCommand);
commands.push_back(new cmSourceFilesRequireCommand);
commands.push_back(new cmSubdirCommand);
commands.push_back(new cmTestsCommand);
commands.push_back(new cmUnixDefinesCommand);
commands.push_back(new cmUnixLibrariesCommand);
commands.push_back(new cmWin32DefinesCommand);
commands.push_back(new cmWin32LibrariesCommand);
commands.push_back(new cmConfigureFileNoAutoconf);
}

30
Source/cmCommands.h Normal file
View File

@ -0,0 +1,30 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2000 National Library of Medicine
All rights reserved.
See COPYRIGHT.txt for copyright details.
=========================================================================*/
#ifndef cmCommands_h
#define cmCommands_h
#include "cmStandardIncludes.h"
class cmCommand;
/**
* Global function to return all compiled in commands.
* To add a new command edit cmCommands.cxx and add your command.
* It is up to the caller to delete the commands created by this
* call.
*/
void GetPredefinedCommands(std::list<cmCommand*>& commands);
#endif

View File

@ -0,0 +1,67 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2000 National Library of Medicine
All rights reserved.
See COPYRIGHT.txt for copyright details.
=========================================================================*/
#include "cmConfigureFileNoAutoconf.h"
// cmConfigureFileNoAutoconf
bool cmConfigureFileNoAutoconf::Invoke(std::vector<std::string>& args)
{
if(args.size() != 2 )
{
this->SetError("called with incorrect number of arguments, expected 2");
return false;
}
m_InputFile = args[0];
m_OuputFile = args[1];
return true;
}
void cmConfigureFileNoAutoconf::FinalPass()
{
#ifdef CMAKE_HAS_AUTOCONF
return;
#else
m_Makefile->ExpandVariblesInString(m_InputFile);
m_Makefile->ExpandVariblesInString(m_OuputFile);
std::ifstream fin(m_InputFile.c_str());
if(!fin)
{
cmSystemTools::Error("Could not open file for read in copy operatation",
m_InputFile.c_str());
return;
}
std::ofstream fout(m_OuputFile.c_str());
if(!fout)
{
cmSystemTools::Error("Could not open file for write in copy operatation",
m_OuputFile.c_str());
return;
}
// now copy input to output and expand varibles in the
// input file at the same time
const int bufSize = 4096;
char buffer[bufSize];
std::string inLine;
while(fin)
{
fin.getline(buffer, bufSize);
inLine = buffer;
m_Makefile->ExpandVariblesInString(inLine);
fout << inLine << "\n";
}
#endif
}

View File

@ -13,18 +13,18 @@
See COPYRIGHT.txt for copyright details.
=========================================================================*/
#ifndef cmConfigureHeaderCommand_h
#define cmConfigureHeaderCommand_h
#ifndef cmConfigureFileNoAutoconf_h
#define cmConfigureFileNoAutoconf_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
class cmConfigureHeaderCommand : public cmCommand
class cmConfigureFileNoAutoconf : public cmCommand
{
public:
virtual cmCommand* Clone()
{
return new cmConfigureHeaderCommand;
return new cmConfigureFileNoAutoconf;
}
/**
@ -36,7 +36,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "CONFIGURE_HEADER";}
virtual const char* GetName() { return "CONFIGURE_FILE_NOAUTOCONF";}
/**
* Succinct documentation.
@ -54,7 +54,8 @@ public:
return
"CONFIGURE_HEADER(InputFile OutputFile)\n"
"The Input and Ouput files have to have full paths.\n"
"They can also use variables like CMAKE_BINARY_DIR, CMAKE_SOURCE_DIR\n";
"They can also use variables like CMAKE_BINARY_DIR,CMAKE_SOURCE_DIR.\n"
"This command is only run if autoconf was not used.\n";
}
/**
@ -62,6 +63,9 @@ public:
* all varibles can be expaned.
*/
virtual void FinalPass();
private:
std::string m_InputFile;
std::string m_OuputFile;
};

View File

@ -1,34 +0,0 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2000 National Library of Medicine
All rights reserved.
See COPYRIGHT.txt for copyright details.
=========================================================================*/
#include "cmConfigureHeaderCommand.h"
// cmConfigureHeaderCommand
bool cmConfigureHeaderCommand::Invoke(std::vector<std::string>& args)
{
if(args.size() != 2 )
{
this->SetError("called with incorrect number of arguments, expected 2");
return false;
}
m_InputFile = args[0];
m_OuputFile = args[1];
return true;
}
void cmConfigureHeaderCommand::FinalPass()
{
}

View File

@ -20,27 +20,7 @@
#include "cmDirectory.h"
#include "cmSystemTools.h"
#include "cmMakefileGenerator.h"
#include "cmAbstractFilesCommand.h"
#include "cmAddTargetCommand.h"
#include "cmAuxSourceDirectoryCommand.h"
#include "cmExecutablesCommand.h"
#include "cmFindIncludeCommand.h"
#include "cmFindLibraryCommand.h"
#include "cmFindProgramCommand.h"
#include "cmIncludeDirectoryCommand.h"
#include "cmLibraryCommand.h"
#include "cmLinkDirectoriesCommand.h"
#include "cmLinkLibrariesCommand.h"
#include "cmProjectCommand.h"
#include "cmSourceFilesCommand.h"
#include "cmSourceFilesRequireCommand.h"
#include "cmSubdirCommand.h"
#include "cmUnixDefinesCommand.h"
#include "cmUnixLibrariesCommand.h"
#include "cmWin32DefinesCommand.h"
#include "cmWin32LibrariesCommand.h"
#include "cmTestsCommand.h"
#include "cmCommands.h"
// default is not to be building executables
cmMakefile::cmMakefile()
@ -53,26 +33,13 @@ cmMakefile::cmMakefile()
void cmMakefile::AddDefaultCommands()
{
this->AddCommand(new cmAbstractFilesCommand);
this->AddCommand(new cmAddTargetCommand);
this->AddCommand(new cmAuxSourceDirectoryCommand);
this->AddCommand(new cmExecutablesCommand);
this->AddCommand(new cmFindIncludeCommand);
this->AddCommand(new cmFindLibraryCommand);
this->AddCommand(new cmFindProgramCommand);
this->AddCommand(new cmIncludeDirectoryCommand);
this->AddCommand(new cmLibraryCommand);
this->AddCommand(new cmLinkDirectoriesCommand);
this->AddCommand(new cmLinkLibrariesCommand);
this->AddCommand(new cmProjectCommand);
this->AddCommand(new cmSourceFilesCommand);
this->AddCommand(new cmSourceFilesRequireCommand);
this->AddCommand(new cmSubdirCommand);
this->AddCommand(new cmUnixLibrariesCommand);
this->AddCommand(new cmUnixDefinesCommand);
this->AddCommand(new cmWin32LibrariesCommand);
this->AddCommand(new cmWin32DefinesCommand);
this->AddCommand(new cmTestsCommand);
std::list<cmCommand*> commands;
GetPredefinedCommands(commands);
for(std::list<cmCommand*>::iterator i = commands.begin();
i != commands.end(); ++i)
{
this->AddCommand(*i);
}
#ifdef _WIN32
this->AddDefinition("WIN32", "1");
#else
@ -147,7 +114,11 @@ bool cmMakefile::ReadMakefile(const char* filename, bool inheriting)
cmSystemTools::ConvertToUnixSlashes(m_cmCurrentDirectory);
m_SourceHomeDirectory = m_cmHomeDirectory;
cmSystemTools::ConvertToUnixSlashes(m_SourceHomeDirectory);
this->ParseDirectory(m_cmCurrentDirectory.c_str());
// if this is already the top level directory then
if(m_SourceHomeDirectory != m_cmCurrentDirectory)
{
this->ParseDirectory(m_cmCurrentDirectory.c_str());
}
}
// Now read the input file
std::ifstream fin(filename);
@ -180,7 +151,7 @@ bool cmMakefile::ReadMakefile(const char* filename, bool inheriting)
cmCommand* usedCommand = rm->Clone();
usedCommand->SetMakefile(this);
usedCommand->LoadCache();
m_UsedCommands.push_back(usedCommand);
bool keepCommand = false;
if(usedCommand->GetEnabled())
{
// if not running in inherit mode or
@ -191,8 +162,20 @@ bool cmMakefile::ReadMakefile(const char* filename, bool inheriting)
{
cmSystemTools::Error(usedCommand->GetError());
}
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
{
@ -203,6 +186,7 @@ bool cmMakefile::ReadMakefile(const char* filename, bool inheriting)
}
return true;
}
void cmMakefile::AddCommand(cmCommand* wg)
@ -326,6 +310,7 @@ void cmMakefile::ParseDirectory(const char* dir)
return;
}
std::string dotdotDir = dir;
std::string::size_type pos = dotdotDir.rfind('/');
if(pos != std::string::npos)
@ -341,25 +326,23 @@ void cmMakefile::ParseDirectory(const char* dir)
void cmMakefile::ExpandVaribles()
{
// Now replace varibles
// make sure binary and source dir are defined
this->AddDefinition("CMAKE_BINARY_DIR", this->GetOutputDirectory());
this->AddDefinition("CMAKE_SOURCE_DIR", this->GetHomeDirectory());
// Now expand varibles in the include and link strings
std::vector<std::string>::iterator j, begin, end;
begin = m_IncludeDirectories.begin();
end = m_IncludeDirectories.end();
for(j = begin; j != end; ++j)
{
cmSystemTools::ReplaceString(*j, "${CMAKE_BINARY_DIR}",
this->GetOutputHomeDirectory() );
cmSystemTools::ReplaceString(*j, "${CMAKE_SOURCE_DIR}",
this->GetHomeDirectory() );
this->ExpandVariblesInString(*j);
}
begin = m_LinkDirectories.begin();
end = m_LinkDirectories.end();
for(j = begin; j != end; ++j)
{
cmSystemTools::ReplaceString(*j, "${CMAKE_BINARY_DIR}",
this->GetOutputHomeDirectory() );
cmSystemTools::ReplaceString(*j, "${CMAKE_SOURCE_DIR}",
this->GetHomeDirectory() );
this->ExpandVariblesInString(*j);
}
}
@ -403,3 +386,17 @@ int cmMakefile::DumpDocumentationToFile(const char *fileName)
return 1;
}
void cmMakefile::ExpandVariblesInString(std::string& source)
{
for(DefinitionMap::iterator i = m_Definitions.begin();
i != m_Definitions.end(); ++i)
{
std::string variable = "${";
variable += (*i).first;
variable += "}";
cmSystemTools::ReplaceString(source, variable.c_str(),
(*i).second.c_str());
}
}

View File

@ -306,6 +306,13 @@ public:
*/
int DumpDocumentationToFile(const char *fileName);
/**
* Expand all defined varibles in the string.
* Defined varibles come from the m_Definitions map.
* They are expanded with ${var} where var is the
* entry in the m_Definitions map.
*/
void ExpandVariblesInString(std::string& source);
protected:
bool m_Executables;
std::string m_Prefix;

View File

@ -39,6 +39,7 @@
#include <algorithm>
#include <functional>
#include <map>
#include <list>
#ifdef CMAKE_NO_STD_NAMESPACE
#define std

View File

@ -264,8 +264,8 @@ bool cmSystemTools::ParseFunction(std::ifstream& fin,
void cmSystemTools::GetArguments(std::string& line,
std::vector<std::string>& arguments)
{
cmRegularExpression argument("[\t ]*([-/\\\\{}\\$A-Za-z_0-9]+)[\t ]*");
cmRegularExpression argumentWithSpaces("[\t ]*\"([- /\\\\{}\\$A-Za-z_0-9]+)\"[\t ]*");
cmRegularExpression argument("[\t ]*([-/\\.\\\\{}\\$A-Za-z_0-9]+)[\t ]*");
cmRegularExpression argumentWithSpaces("[\t ]*\"([-\\. /\\\\{}\\$A-Za-z_0-9]+)\"[\t ]*");
std::string arg(" ");
while(arg.length() )
{
@ -308,3 +308,4 @@ void cmSystemTools::Error(const char* m1, const char* m2)
std::cerr << message.c_str() << std::endl;
#endif
}