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

View File

@ -252,20 +252,6 @@ void CMakeSetupDialog::OnOK()
m_WhereBuild = m_WhereSource; 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; cmMakefile mf;
mf.SetMakefileGenerator(new cmMSProjectGenerator); mf.SetMakefileGenerator(new cmMSProjectGenerator);
mf.SetHomeDirectory(m_WhereSource); mf.SetHomeDirectory(m_WhereSource);

View File

@ -6,6 +6,8 @@ VPATH = @srcdir@
# This will cause an infinite loop as it will add the # This will cause an infinite loop as it will add the
# command for changing into this directory # 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/CMakeVariables.make@MAKEQUOTE@
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_CONFIG_DIR@/CMake/CMakeSimpleRules.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 "cmAbstractFilesCommand.cxx"
#include "cmAddTargetCommand.cxx" #include "cmAddTargetCommand.cxx"
#include "cmAuxSourceDirectoryCommand.cxx" #include "cmAuxSourceDirectoryCommand.cxx"
@ -18,3 +23,31 @@
#include "cmUnixLibrariesCommand.cxx" #include "cmUnixLibrariesCommand.cxx"
#include "cmWin32DefinesCommand.cxx" #include "cmWin32DefinesCommand.cxx"
#include "cmWin32LibrariesCommand.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. See COPYRIGHT.txt for copyright details.
=========================================================================*/ =========================================================================*/
#ifndef cmConfigureHeaderCommand_h #ifndef cmConfigureFileNoAutoconf_h
#define cmConfigureHeaderCommand_h #define cmConfigureFileNoAutoconf_h
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmCommand.h" #include "cmCommand.h"
class cmConfigureHeaderCommand : public cmCommand class cmConfigureFileNoAutoconf : public cmCommand
{ {
public: public:
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
return new cmConfigureHeaderCommand; return new cmConfigureFileNoAutoconf;
} }
/** /**
@ -36,7 +36,7 @@ public:
/** /**
* The name of the command as specified in CMakeList.txt. * 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. * Succinct documentation.
@ -54,7 +54,8 @@ public:
return return
"CONFIGURE_HEADER(InputFile OutputFile)\n" "CONFIGURE_HEADER(InputFile OutputFile)\n"
"The Input and Ouput files have to have full paths.\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. * all varibles can be expaned.
*/ */
virtual void FinalPass(); 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 "cmDirectory.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmMakefileGenerator.h" #include "cmMakefileGenerator.h"
#include "cmCommands.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"
// default is not to be building executables // default is not to be building executables
cmMakefile::cmMakefile() cmMakefile::cmMakefile()
@ -53,26 +33,13 @@ cmMakefile::cmMakefile()
void cmMakefile::AddDefaultCommands() void cmMakefile::AddDefaultCommands()
{ {
this->AddCommand(new cmAbstractFilesCommand); std::list<cmCommand*> commands;
this->AddCommand(new cmAddTargetCommand); GetPredefinedCommands(commands);
this->AddCommand(new cmAuxSourceDirectoryCommand); for(std::list<cmCommand*>::iterator i = commands.begin();
this->AddCommand(new cmExecutablesCommand); i != commands.end(); ++i)
this->AddCommand(new cmFindIncludeCommand); {
this->AddCommand(new cmFindLibraryCommand); this->AddCommand(*i);
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);
#ifdef _WIN32 #ifdef _WIN32
this->AddDefinition("WIN32", "1"); this->AddDefinition("WIN32", "1");
#else #else
@ -147,8 +114,12 @@ bool cmMakefile::ReadMakefile(const char* filename, bool inheriting)
cmSystemTools::ConvertToUnixSlashes(m_cmCurrentDirectory); cmSystemTools::ConvertToUnixSlashes(m_cmCurrentDirectory);
m_SourceHomeDirectory = m_cmHomeDirectory; m_SourceHomeDirectory = m_cmHomeDirectory;
cmSystemTools::ConvertToUnixSlashes(m_SourceHomeDirectory); cmSystemTools::ConvertToUnixSlashes(m_SourceHomeDirectory);
// if this is already the top level directory then
if(m_SourceHomeDirectory != m_cmCurrentDirectory)
{
this->ParseDirectory(m_cmCurrentDirectory.c_str()); this->ParseDirectory(m_cmCurrentDirectory.c_str());
} }
}
// Now read the input file // Now read the input file
std::ifstream fin(filename); std::ifstream fin(filename);
if(!fin) if(!fin)
@ -180,7 +151,7 @@ bool cmMakefile::ReadMakefile(const char* filename, bool inheriting)
cmCommand* usedCommand = rm->Clone(); cmCommand* usedCommand = rm->Clone();
usedCommand->SetMakefile(this); usedCommand->SetMakefile(this);
usedCommand->LoadCache(); usedCommand->LoadCache();
m_UsedCommands.push_back(usedCommand); bool keepCommand = false;
if(usedCommand->GetEnabled()) if(usedCommand->GetEnabled())
{ {
// if not running in inherit mode or // if not running in inherit mode or
@ -191,9 +162,21 @@ bool cmMakefile::ReadMakefile(const char* filename, bool inheriting)
{ {
cmSystemTools::Error(usedCommand->GetError()); 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 else
{ {
cmSystemTools::Error("unknown CMake function", name.c_str()); cmSystemTools::Error("unknown CMake function", name.c_str());
@ -205,6 +188,7 @@ bool cmMakefile::ReadMakefile(const char* filename, bool inheriting)
} }
void cmMakefile::AddCommand(cmCommand* wg) void cmMakefile::AddCommand(cmCommand* wg)
{ {
std::string name = wg->GetName(); std::string name = wg->GetName();
@ -326,6 +310,7 @@ void cmMakefile::ParseDirectory(const char* dir)
return; return;
} }
std::string dotdotDir = dir; std::string dotdotDir = dir;
std::string::size_type pos = dotdotDir.rfind('/'); std::string::size_type pos = dotdotDir.rfind('/');
if(pos != std::string::npos) if(pos != std::string::npos)
@ -341,25 +326,23 @@ void cmMakefile::ParseDirectory(const char* dir)
void cmMakefile::ExpandVaribles() 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; std::vector<std::string>::iterator j, begin, end;
begin = m_IncludeDirectories.begin(); begin = m_IncludeDirectories.begin();
end = m_IncludeDirectories.end(); end = m_IncludeDirectories.end();
for(j = begin; j != end; ++j) for(j = begin; j != end; ++j)
{ {
cmSystemTools::ReplaceString(*j, "${CMAKE_BINARY_DIR}", this->ExpandVariblesInString(*j);
this->GetOutputHomeDirectory() );
cmSystemTools::ReplaceString(*j, "${CMAKE_SOURCE_DIR}",
this->GetHomeDirectory() );
} }
begin = m_LinkDirectories.begin(); begin = m_LinkDirectories.begin();
end = m_LinkDirectories.end(); end = m_LinkDirectories.end();
for(j = begin; j != end; ++j) for(j = begin; j != end; ++j)
{ {
cmSystemTools::ReplaceString(*j, "${CMAKE_BINARY_DIR}", this->ExpandVariblesInString(*j);
this->GetOutputHomeDirectory() );
cmSystemTools::ReplaceString(*j, "${CMAKE_SOURCE_DIR}",
this->GetHomeDirectory() );
} }
} }
@ -403,3 +386,17 @@ int cmMakefile::DumpDocumentationToFile(const char *fileName)
return 1; 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); 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: protected:
bool m_Executables; bool m_Executables;
std::string m_Prefix; std::string m_Prefix;

View File

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

View File

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