ENH: call configure from cmake
This commit is contained in:
parent
5066defc23
commit
885e37da22
|
@ -3,8 +3,6 @@
|
|||
# in, which need not be the source directory
|
||||
#
|
||||
SET (WORDS_BIGENDIAN @CMAKE_WORDS_BIGENDIAN@)
|
||||
SET (HAVE_LIMITS_H @HAVE_LIMITS_H@)
|
||||
SET (HAVE_UNISTD_H @HAVE_UNISTD_H@)
|
||||
SET (CMAKE_USE_SPROC @CMAKE_USE_SPROC@)
|
||||
SET (CMAKE_USE_PTHREADS @CMAKE_USE_PTHREADS@)
|
||||
SET (CMAKE_HP_PTHREADS @CMAKE_HP_PTHREADS@)
|
||||
|
|
|
@ -104,15 +104,24 @@ int main(int ac, char** av)
|
|||
std::string path = arg.substr(2);
|
||||
mf.SetHomeOutputDirectory(path.c_str());
|
||||
}
|
||||
if(arg.find("-D",0) == 0)
|
||||
{
|
||||
std::string value = arg.substr(2);
|
||||
mf.AddDefinition(value.c_str(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Only generate makefiles if not trying to make the cache
|
||||
if(!makeCache)
|
||||
cmUnixMakefileGenerator* gen = new cmUnixMakefileGenerator;
|
||||
mf.SetMakefileGenerator(gen);
|
||||
if(makeCache)
|
||||
{
|
||||
mf.SetMakefileGenerator(new cmUnixMakefileGenerator);
|
||||
// generate only enough for the cache
|
||||
gen->SetCacheOnlyOn();
|
||||
// generate for this makefile and all below it
|
||||
gen->SetRecurseOn();
|
||||
}
|
||||
|
||||
|
||||
// Read and parse the input makefile
|
||||
mf.MakeStartDirectoriesCurrent();
|
||||
cmCacheManager::GetInstance()->LoadCache(&mf);
|
||||
|
@ -137,14 +146,7 @@ int main(int ac, char** av)
|
|||
Usage(av[0]);
|
||||
return -1;
|
||||
}
|
||||
if(makeCache)
|
||||
{
|
||||
mf.GenerateCacheOnly();
|
||||
}
|
||||
else
|
||||
{
|
||||
mf.GenerateMakefile();
|
||||
}
|
||||
cmCacheManager::GetInstance()->SaveCache(&mf);
|
||||
if(makeCache)
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@ cmSourceFile.o : $(DEPENDS)
|
|||
cmDirectory.o : $(DEPENDS)
|
||||
cmCustomCommand.o : $(DEPENDS)
|
||||
cmUnixMakefileGenerator.o : $(DEPENDS)
|
||||
cmCommands.o : $(DEPENDS) $(srcdir)/*.cxx
|
||||
cmCommands.o : $(DEPENDS) $(srcdir)/*Command*.cxx
|
||||
cmTarget.o : $(DEPENDS)
|
||||
cmCacheManager.o : $(DEPENDS)
|
||||
cmSourceGroup.o : $(DEPENDS)
|
||||
|
|
|
@ -187,12 +187,29 @@ bool cmCacheManager::SaveCache(const char* path) const
|
|||
{
|
||||
const CacheEntry& ce = (*i).second;
|
||||
CacheEntryType t = ce.m_Type;
|
||||
if(t != INTERNAL)
|
||||
{
|
||||
// Format is key:type=value
|
||||
cmCacheManager::OutputHelpString(fout, ce.m_HelpString);
|
||||
fout << (*i).first.c_str() << ":"
|
||||
<< cmCacheManagerTypes[t] << "="
|
||||
<< ce.m_Value << "\n";
|
||||
}
|
||||
}
|
||||
for( std::map<std::string, CacheEntry>::const_iterator i = m_Cache.begin();
|
||||
i != m_Cache.end(); ++i)
|
||||
{
|
||||
const CacheEntry& ce = (*i).second;
|
||||
CacheEntryType t = ce.m_Type;
|
||||
if(t == INTERNAL)
|
||||
{
|
||||
// Format is key:type=value
|
||||
cmCacheManager::OutputHelpString(fout, ce.m_HelpString);
|
||||
fout << (*i).first.c_str() << ":"
|
||||
<< cmCacheManagerTypes[t] << "="
|
||||
<< ce.m_Value << "\n";
|
||||
}
|
||||
}
|
||||
fout << "\n";
|
||||
fout.close();
|
||||
cmSystemTools::CopyFileIfDifferent(tempFile.c_str(),
|
||||
|
@ -279,8 +296,11 @@ void cmCacheManager::PrintCache(std::ostream& out) const
|
|||
for(std::map<std::string, CacheEntry>::const_iterator i = m_Cache.begin();
|
||||
i != m_Cache.end(); ++i)
|
||||
{
|
||||
if((*i).second.m_Type != INTERNAL)
|
||||
{
|
||||
out << (*i).first.c_str() << " = " << (*i).second.m_Value.c_str() << std::endl;
|
||||
}
|
||||
}
|
||||
out << "\n\n";
|
||||
out << "To change values in the CMakeCache, \nedit CMakeCache.txt in your output directory.\n";
|
||||
out << "=================================================" << std::endl;
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
#include "cmCablePackageEntryCommand.cxx"
|
||||
#include "cmCableSourceFilesCommand.cxx"
|
||||
#include "cmCableWrapCommand.cxx"
|
||||
#include "cmConfigureFile.cxx"
|
||||
#include "cmConfigureFileCommand.cxx"
|
||||
#include "cmConfigureFileNoAutoconf.cxx"
|
||||
#include "cmElseCommand.cxx"
|
||||
#include "cmEndIfCommand.cxx"
|
||||
#include "cmExecProgram.cxx"
|
||||
#include "cmExecProgramCommand.cxx"
|
||||
#include "cmFindFileCommand.cxx"
|
||||
#include "cmFindIncludeCommand.cxx"
|
||||
#include "cmFindLibraryCommand.cxx"
|
||||
|
@ -39,6 +39,7 @@
|
|||
#include "cmIncludeRegularExpressionCommand.cxx"
|
||||
#include "cmLinkDirectoriesCommand.cxx"
|
||||
#include "cmLinkLibrariesCommand.cxx"
|
||||
#include "cmMakeDirectoryCommand.cxx"
|
||||
#include "cmOptionCommand.cxx"
|
||||
#include "cmProjectCommand.cxx"
|
||||
#include "cmSetCommand.cxx"
|
||||
|
@ -74,11 +75,11 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
|
|||
commands.push_back(new cmCablePackageCommand);
|
||||
commands.push_back(new cmCableSourceFilesCommand);
|
||||
commands.push_back(new cmCableWrapCommand);
|
||||
commands.push_back(new cmConfigureFile);
|
||||
commands.push_back(new cmConfigureFileCommand);
|
||||
commands.push_back(new cmConfigureFileNoAutoconf);
|
||||
commands.push_back(new cmElseCommand);
|
||||
commands.push_back(new cmEndIfCommand);
|
||||
commands.push_back(new cmExecProgram);
|
||||
commands.push_back(new cmExecProgramCommand);
|
||||
commands.push_back(new cmFindFileCommand);
|
||||
commands.push_back(new cmFindIncludeCommand);
|
||||
commands.push_back(new cmFindLibraryCommand);
|
||||
|
@ -90,6 +91,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
|
|||
commands.push_back(new cmIncludeRegularExpressionCommand);
|
||||
commands.push_back(new cmLinkDirectoriesCommand);
|
||||
commands.push_back(new cmLinkLibrariesCommand);
|
||||
commands.push_back(new cmMakeDirectoryCommand);
|
||||
commands.push_back(new cmOptionCommand);
|
||||
commands.push_back(new cmProjectCommand);
|
||||
commands.push_back(new cmSetCommand);
|
||||
|
|
|
@ -38,22 +38,28 @@ 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 "cmConfigureFile.h"
|
||||
#include "cmConfigureFileCommand.h"
|
||||
|
||||
// cmConfigureFile
|
||||
bool cmConfigureFile::Invoke(std::vector<std::string>& args)
|
||||
// cmConfigureFileCommand
|
||||
bool cmConfigureFileCommand::Invoke(std::vector<std::string>& args)
|
||||
{
|
||||
if(args.size() != 2 )
|
||||
if(args.size() < 2 )
|
||||
{
|
||||
this->SetError("called with incorrect number of arguments, expected 2");
|
||||
return false;
|
||||
}
|
||||
m_InputFile = args[0];
|
||||
m_OuputFile = args[1];
|
||||
m_CopyOnly = false;
|
||||
if(args[2] == "COPYONLY")
|
||||
{
|
||||
m_CopyOnly = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void cmConfigureFile::FinalPass()
|
||||
void cmConfigureFileCommand::FinalPass()
|
||||
{
|
||||
m_Makefile->ExpandVariablesInString(m_InputFile);
|
||||
m_Makefile->ExpandVariablesInString(m_OuputFile);
|
||||
|
@ -92,10 +98,10 @@ void cmConfigureFile::FinalPass()
|
|||
if(fin)
|
||||
{
|
||||
inLine = buffer;
|
||||
if(!m_CopyOnly)
|
||||
{
|
||||
m_Makefile->ExpandVariablesInString(inLine);
|
||||
// This call will remove all tcl variable substitutions of the form ${Foo}
|
||||
// m_Makefile->RemoveVariablesInString(inLine);
|
||||
|
||||
m_Makefile->RemoveVariablesInString(inLine);
|
||||
// look for special cmakedefine symbol and handle it
|
||||
// is the symbol defined
|
||||
if (cmdefine.find(inLine))
|
||||
|
@ -112,6 +118,7 @@ void cmConfigureFile::FinalPass()
|
|||
"#cmakedefine", "#undef");
|
||||
}
|
||||
}
|
||||
}
|
||||
fout << inLine << "\n";
|
||||
}
|
||||
}
|
|
@ -38,18 +38,18 @@ 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 cmConfigureFile_h
|
||||
#define cmConfigureFile_h
|
||||
#ifndef cmConfigureFileCommand_h
|
||||
#define cmConfigureFileCommand_h
|
||||
|
||||
#include "cmStandardIncludes.h"
|
||||
#include "cmCommand.h"
|
||||
|
||||
class cmConfigureFile : public cmCommand
|
||||
class cmConfigureFileCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
virtual cmCommand* Clone()
|
||||
{
|
||||
return new cmConfigureFile;
|
||||
return new cmConfigureFileCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,12 +77,13 @@ public:
|
|||
virtual const char* GetFullDocumentation()
|
||||
{
|
||||
return
|
||||
"CONFIGURE_FILE(InputFile OutputFile)\n"
|
||||
"CONFIGURE_FILE(InputFile OutputFile [COPYONLY])\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"
|
||||
"This command replaces any variables in the input file with their\n"
|
||||
"values as determined by CMake. If a variables in not defined, it\n"
|
||||
"will be replaced with nothing.";
|
||||
"will be replaced with nothing. If COPYONLY is passed in, then\n"
|
||||
"then no varible expansion will take place.\n";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,6 +94,7 @@ public:
|
|||
private:
|
||||
std::string m_InputFile;
|
||||
std::string m_OuputFile;
|
||||
bool m_CopyOnly;
|
||||
};
|
||||
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*=========================================================================
|
||||
|
||||
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 "cmExecProgramCommand.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
// cmExecProgramCommand
|
||||
bool cmExecProgramCommand::Invoke(std::vector<std::string>& args)
|
||||
{
|
||||
if(args.size() < 1 )
|
||||
{
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
std::string output;
|
||||
m_Makefile->ExpandVariablesInString(args[0]);
|
||||
m_Makefile->ExpandVariablesInString(args[1]);
|
||||
if(args.size() == 2)
|
||||
{
|
||||
cmSystemTools::MakeDirectory(args[1].c_str());
|
||||
std::string command;
|
||||
command = "cd ";
|
||||
command += args[1].c_str();
|
||||
command += "; ";
|
||||
command += args[0].c_str();
|
||||
cmSystemTools::RunCommand(command.c_str(), output);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmSystemTools::RunCommand(args[0].c_str(), output);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -38,20 +38,20 @@ 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 cmExecProgram_h
|
||||
#define cmExecProgram_h
|
||||
#ifndef cmExecProgramCommand_h
|
||||
#define cmExecProgramCommand_h
|
||||
|
||||
#include "cmStandardIncludes.h"
|
||||
#include "cmCommand.h"
|
||||
|
||||
/** \class cmExecProgram
|
||||
/** \class cmExecProgramCommand
|
||||
* \brief Command that adds a target to the build system.
|
||||
*
|
||||
* cmExecProgram adds an extra target to the build system.
|
||||
* cmExecProgramCommand 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 cmExecProgram : public cmCommand
|
||||
class cmExecProgramCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
*/
|
||||
virtual cmCommand* Clone()
|
||||
{
|
||||
return new cmExecProgram;
|
||||
return new cmExecProgramCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
"EXEC_PROGRAM(Executble )";
|
||||
}
|
||||
|
||||
cmTypeMacro(cmExecProgram, cmCommand);
|
||||
cmTypeMacro(cmExecProgramCommand, cmCommand);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -38,19 +38,19 @@ 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 "cmExecProgram.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmMakeDirectoryCommand.h"
|
||||
#include "cmDirectory.h"
|
||||
|
||||
// cmExecProgram
|
||||
bool cmExecProgram::Invoke(std::vector<std::string>& args)
|
||||
// cmMakeDirectoryCommand
|
||||
bool cmMakeDirectoryCommand::Invoke(std::vector<std::string>& args)
|
||||
{
|
||||
if(args.size() < 1 )
|
||||
{
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
std::string output;
|
||||
cmSystemTools::RunCommand(args[0].c_str(), output);
|
||||
m_Makefile->ExpandVariablesInString(args[0]);
|
||||
cmSystemTools::MakeDirectory(args[0].c_str());
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
/*=========================================================================
|
||||
|
||||
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 cmMakeDirectoryCommand_h
|
||||
#define cmMakeDirectoryCommand_h
|
||||
|
||||
#include "cmStandardIncludes.h"
|
||||
#include "cmCommand.h"
|
||||
|
||||
/** \class cmMakeDirectoryCommand
|
||||
* \brief Specify auxiliary source code directories.
|
||||
*
|
||||
* cmMakeDirectoryCommand specifies source code directories
|
||||
* that must be built as part of this build process. This directories
|
||||
* are not recursively processed like the SUBDIR command (cmSubdirCommand).
|
||||
* A side effect of this command is to create a subdirectory in the build
|
||||
* directory structure.
|
||||
*/
|
||||
class cmMakeDirectoryCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
*/
|
||||
virtual cmCommand* Clone()
|
||||
{
|
||||
return new cmMakeDirectoryCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 "MAKE_DIRECTORY";}
|
||||
|
||||
/**
|
||||
* Succinct documentation.
|
||||
*/
|
||||
virtual const char* GetTerseDocumentation()
|
||||
{
|
||||
return "Create a directory in the build tree if it does not exist.\n"
|
||||
"Parent directories will be created if the do not exist..";
|
||||
}
|
||||
|
||||
/**
|
||||
* More documentation.
|
||||
*/
|
||||
virtual const char* GetFullDocumentation()
|
||||
{
|
||||
return
|
||||
"MAKE_DIRECTORY(directory)";
|
||||
}
|
||||
|
||||
cmTypeMacro(cmMakeDirectoryCommand, cmCommand);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -75,7 +75,7 @@ void cmMakefile::AddDefaultCommands()
|
|||
{
|
||||
this->AddCommand(*i);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
this->AddDefinition("WIN32", "1");
|
||||
#else
|
||||
this->AddDefinition("UNIX", "1");
|
||||
|
@ -730,66 +730,6 @@ cmMakefile::FindSubDirectoryCMakeListsFiles(std::vector<cmMakefile*>&
|
|||
}
|
||||
|
||||
|
||||
void cmMakefile::GenerateCacheOnly()
|
||||
{
|
||||
std::vector<cmMakefile*> makefiles;
|
||||
this->FindSubDirectoryCMakeListsFiles(makefiles);
|
||||
for(std::vector<cmMakefile*>::iterator i = makefiles.begin();
|
||||
i != makefiles.end(); ++i)
|
||||
{
|
||||
cmMakefile* mf = *i;
|
||||
std::string source = mf->GetHomeDirectory();
|
||||
source += "/CMake/CMakeMakefileTemplate.in";
|
||||
cmSystemTools::MakeDirectory(mf->GetStartOutputDirectory());
|
||||
std::string dest = mf->GetStartOutputDirectory();
|
||||
dest += "/Makefile";
|
||||
std::ofstream fout(dest.c_str());
|
||||
std::cout << "cmake: creating : " << dest.c_str() << "\n";
|
||||
if(!fout)
|
||||
{
|
||||
cmSystemTools::Error("Failed to open file for write " , dest.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if(strcmp(mf->GetHomeDirectory(),
|
||||
mf->GetHomeOutputDirectory()) == 0)
|
||||
{
|
||||
fout << "srcdir = .\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
fout << "srcdir = " << mf->GetStartDirectory() << "\n";
|
||||
fout << "VPATH = " << mf->GetStartDirectory() << "\n";
|
||||
}
|
||||
}
|
||||
fout << "include "
|
||||
<< mf->GetHomeOutputDirectory() << "/CMake/CMakeMaster.make\n";
|
||||
dest = mf->GetStartOutputDirectory();
|
||||
dest += "/CMakeTargets.make";
|
||||
// make sure there is a CMakeTargets.make file as some
|
||||
// makes require it to exist
|
||||
if(!cmSystemTools::FileExists(dest.c_str()))
|
||||
{
|
||||
std::cout << "cmake: creating : " << dest.c_str() << "\n";
|
||||
std::ofstream fout(dest.c_str());
|
||||
if(!fout)
|
||||
{
|
||||
cmSystemTools::Error("Failed to open file for write " , dest.c_str());
|
||||
}
|
||||
fout << "#Initial CMakeTargets.make file created only to keep \n";
|
||||
fout << "#certain makes happy that don't like to include makefiles\n";
|
||||
fout << "#that do not exist\n";
|
||||
}
|
||||
}
|
||||
|
||||
// CLEAN up the makefiles created
|
||||
for(unsigned int i =0; i < makefiles.size(); ++i)
|
||||
{
|
||||
delete makefiles[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add the default definitions to the makefile. These values must not
|
||||
* be dependent on anything that isn't known when this cmMakefile instance
|
||||
|
|
|
@ -466,13 +466,6 @@ public:
|
|||
*/
|
||||
void FindSubDirectoryCMakeListsFiles(std::vector<cmMakefile*>& makefiles);
|
||||
|
||||
/** Generate the cache file only. This is done
|
||||
* by calling FindSubDirectoryCMakeListsFiles which
|
||||
* will cause all the rules to fire, and the cache to
|
||||
* be filled.
|
||||
*/
|
||||
void GenerateCacheOnly();
|
||||
|
||||
/**
|
||||
* find what source group this source is in
|
||||
*/
|
||||
|
|
|
@ -563,6 +563,10 @@ bool cmSystemTools::IsOff(const char* val)
|
|||
bool cmSystemTools::RunCommand(const char* command,
|
||||
std::string& output)
|
||||
{
|
||||
const int BUFFER_SIZE = 4096;
|
||||
char buffer[BUFFER_SIZE];
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
std::string commandToFile = command;
|
||||
commandToFile += " > ";
|
||||
std::string tempFile;
|
||||
|
@ -576,8 +580,6 @@ bool cmSystemTools::RunCommand(const char* command,
|
|||
tempFile.c_str());
|
||||
return false;
|
||||
}
|
||||
const int BUFFER_SIZE = 4096;
|
||||
char buffer[BUFFER_SIZE];
|
||||
while(fin)
|
||||
{
|
||||
fin.getline(buffer, BUFFER_SIZE);
|
||||
|
@ -585,6 +587,22 @@ bool cmSystemTools::RunCommand(const char* command,
|
|||
}
|
||||
cmSystemTools::RemoveFile(tempFile.c_str());
|
||||
return true;
|
||||
#else
|
||||
std::cout << "runing " << command << std::endl;
|
||||
FILE* cpipe = popen(command, "r");
|
||||
if(!cpipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
fgets(buffer, BUFFER_SIZE, cpipe);
|
||||
while(!feof(cpipe))
|
||||
{
|
||||
std::cout << buffer;
|
||||
output += buffer;
|
||||
fgets(buffer, BUFFER_SIZE, cpipe);
|
||||
}
|
||||
fclose(cpipe);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -46,7 +46,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "cmMakeDepend.h"
|
||||
#include "cmCacheManager.h"
|
||||
|
||||
cmUnixMakefileGenerator::cmUnixMakefileGenerator()
|
||||
{
|
||||
m_CacheOnly = false;
|
||||
m_Recurse = false;
|
||||
}
|
||||
|
||||
void cmUnixMakefileGenerator::GenerateMakefile()
|
||||
{
|
||||
if(m_CacheOnly)
|
||||
{
|
||||
// Generate the cache only stuff
|
||||
this->GenerateCacheOnly();
|
||||
// if recurse then generate for all sub- makefiles
|
||||
if(m_Recurse)
|
||||
{
|
||||
this->RecursiveGenerateCacheOnly();
|
||||
}
|
||||
}
|
||||
// normal makefile output
|
||||
else
|
||||
{
|
||||
// Generate depends
|
||||
cmMakeDepend md;
|
||||
|
@ -55,6 +74,7 @@ void cmUnixMakefileGenerator::GenerateMakefile()
|
|||
// output the makefile fragment
|
||||
this->OutputMakefile("CMakeTargets.make");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This is where CMakeTargets.make is generated
|
||||
|
@ -539,3 +559,76 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cmUnixMakefileGenerator::GenerateCacheOnly()
|
||||
{
|
||||
|
||||
std::string source = m_Makefile->GetHomeDirectory();
|
||||
source += "/CMake/CMakeMakefileTemplate.in";
|
||||
cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory());
|
||||
std::string dest = m_Makefile->GetStartOutputDirectory();
|
||||
dest += "/Makefile";
|
||||
std::ofstream fout(dest.c_str());
|
||||
std::cout << "cmake: creating : " << dest.c_str() << "\n";
|
||||
if(!fout)
|
||||
{
|
||||
cmSystemTools::Error("Failed to open file for write " , dest.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if(strcmp(m_Makefile->GetHomeDirectory(),
|
||||
m_Makefile->GetHomeOutputDirectory()) == 0)
|
||||
{
|
||||
fout << "srcdir = .\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
fout << "srcdir = " << m_Makefile->GetStartDirectory() << "\n";
|
||||
fout << "VPATH = " << m_Makefile->GetStartDirectory() << "\n";
|
||||
}
|
||||
}
|
||||
fout << "include "
|
||||
<< m_Makefile->GetHomeOutputDirectory() << "/CMake/CMakeMaster.make\n";
|
||||
dest = m_Makefile->GetStartOutputDirectory();
|
||||
dest += "/CMakeTargets.make";
|
||||
// make sure there is a CMakeTargets.make file as some
|
||||
// makes require it to exist
|
||||
if(!cmSystemTools::FileExists(dest.c_str()))
|
||||
{
|
||||
std::cout << "cmake: creating : " << dest.c_str() << "\n";
|
||||
std::ofstream fout(dest.c_str());
|
||||
if(!fout)
|
||||
{
|
||||
cmSystemTools::Error("Failed to open file for write " , dest.c_str());
|
||||
}
|
||||
fout << "#Initial CMakeTargets.make file created only to keep \n";
|
||||
fout << "#certain makes happy that don't like to include makefiles\n";
|
||||
fout << "#that do not exist\n";
|
||||
}
|
||||
}
|
||||
|
||||
void cmUnixMakefileGenerator::RecursiveGenerateCacheOnly()
|
||||
{
|
||||
std::vector<cmMakefile*> makefiles;
|
||||
m_Makefile->FindSubDirectoryCMakeListsFiles(makefiles);
|
||||
for(std::vector<cmMakefile*>::iterator i = makefiles.begin();
|
||||
i != makefiles.end(); ++i)
|
||||
{
|
||||
cmMakefile* mf = *i;
|
||||
if(m_Makefile->GetDefinition("RUN_CONFIGURE"))
|
||||
{
|
||||
mf->AddDefinition("RUN_CONFIGURE", true);
|
||||
}
|
||||
cmUnixMakefileGenerator* gen = new cmUnixMakefileGenerator;
|
||||
gen->SetCacheOnlyOn();
|
||||
gen->SetRecurseOff();
|
||||
mf->SetMakefileGenerator(gen);
|
||||
mf->GenerateMakefile();
|
||||
}
|
||||
// CLEAN up the makefiles created
|
||||
for(unsigned int i =0; i < makefiles.size(); ++i)
|
||||
{
|
||||
delete makefiles[i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
class cmUnixMakefileGenerator : public cmMakefileGenerator
|
||||
{
|
||||
public:
|
||||
///! Set cache only and recurse to false by default.
|
||||
cmUnixMakefileGenerator();
|
||||
|
||||
/**
|
||||
* If cache only is on.
|
||||
* and only stub makefiles are generated, and no depends, for speed.
|
||||
* The default is OFF.
|
||||
**/
|
||||
void SetCacheOnlyOn() {m_CacheOnly = true;}
|
||||
void SetCacheOnlyOff() {m_CacheOnly = false;}
|
||||
/**
|
||||
* If recurse is on, then all the makefiles below this one are parsed as well.
|
||||
*/
|
||||
void SetRecurseOn() {m_Recurse = true;}
|
||||
void SetRecurseOff() {m_Recurse = false;}
|
||||
|
||||
/**
|
||||
* Produce the makefile (in this case a Unix makefile).
|
||||
*/
|
||||
|
@ -65,7 +81,9 @@ public:
|
|||
*/
|
||||
void OutputObjectDepends(std::ostream&);
|
||||
|
||||
protected:
|
||||
private:
|
||||
void RecursiveGenerateCacheOnly();
|
||||
void GenerateCacheOnly();
|
||||
void OutputMakefile(const char* file);
|
||||
void OutputMakeFlags(std::ostream&);
|
||||
void OutputVerbatim(std::ostream&);
|
||||
|
@ -76,6 +94,9 @@ protected:
|
|||
void OutputDependInformation(std::ostream&);
|
||||
void OutputDependencies(std::ostream&);
|
||||
void OutputCustomRules(std::ostream&);
|
||||
private:
|
||||
bool m_CacheOnly;
|
||||
bool m_Recurse;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue