ENH: determine the current system also in cpack, so the search paths are

loaded
Additionally the makefile in cmCPackGenericGenerator is now protected
instead of private, so with these two changes the cpack generators should
now be able to find their tools and how to call these tools from cmake
scripts, instead of hardcoding the search order and command line (as done
e.g. in cmCPackZIPGenerator.cxx)

Alex
This commit is contained in:
Alexander Neundorf 2007-07-24 10:00:26 -04:00
parent 8240cc006f
commit 8a6e2bb81d
4 changed files with 136 additions and 115 deletions

View File

@ -124,6 +124,9 @@ ENDMACRO(ADJUST_CMAKE_SYSTEM_VARIABLES _PREFIX)
ADJUST_CMAKE_SYSTEM_VARIABLES(CMAKE_SYSTEM)
ADJUST_CMAKE_SYSTEM_VARIABLES(CMAKE_HOST_SYSTEM)
# this file is also executed from cpack, then we don't need to generate these files
# in this case there is no CMAKE_BINARY_DIR
IF(CMAKE_BINARY_DIR)
# write entry to the log file
IF(PRESET_CMAKE_SYSTEM_NAME)
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
@ -156,3 +159,5 @@ ELSE (CMAKE_TOOLCHAIN_FILE)
IMMEDIATE @ONLY)
ENDIF (CMAKE_TOOLCHAIN_FILE)
ENDIF(CMAKE_BINARY_DIR)

View File

@ -32,14 +32,14 @@
cmCPackGenericGenerator::cmCPackGenericGenerator()
{
this->GeneratorVerbose = false;
this->MakefileMap = 0;
this->Makefile = 0;
this->Logger = 0;
}
//----------------------------------------------------------------------
cmCPackGenericGenerator::~cmCPackGenericGenerator()
{
this->MakefileMap = 0;
this->Makefile = 0;
}
//----------------------------------------------------------------------
@ -392,7 +392,7 @@ int cmCPackGenericGenerator::InstallProjectViaInstallScript(
tempInstallDirectory);
this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR",
tempInstallDirectory);
int res = this->MakefileMap->ReadListFile(0, installScript.c_str());
int res = this->Makefile->ReadListFile(0, installScript.c_str());
if ( cmSystemTools::GetErrorOccuredFlag() || !res )
{
return 0;
@ -454,7 +454,7 @@ int cmCPackGenericGenerator::InstallProjectViaInstallCMakeProjects(
const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG");
cmGlobalGenerator* globalGenerator
= this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
= this->Makefile->GetCMakeInstance()->CreateGlobalGenerator(
cmakeGenerator);
// set the global flag for unix style paths on cmSystemTools as
// soon as the generator is set. This allows gmake to be used
@ -464,9 +464,9 @@ int cmCPackGenericGenerator::InstallProjectViaInstallCMakeProjects(
// Does this generator require pre-install?
if ( globalGenerator->GetPreinstallTargetName() )
{
globalGenerator->FindMakeProgram(this->MakefileMap);
globalGenerator->FindMakeProgram(this->Makefile);
const char* cmakeMakeProgram
= this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM");
= this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM");
std::string buildCommand
= globalGenerator->GenerateBuildCommand(cmakeMakeProgram,
installProjectName.c_str(), 0,
@ -554,7 +554,7 @@ int cmCPackGenericGenerator::InstallProjectViaInstallCMakeProjects(
void cmCPackGenericGenerator::SetOptionIfNotSet(const char* op,
const char* value)
{
const char* def = this->MakefileMap->GetDefinition(op);
const char* def = this->Makefile->GetDefinition(op);
if ( def && *def )
{
return;
@ -571,12 +571,12 @@ void cmCPackGenericGenerator::SetOption(const char* op, const char* value)
}
if ( !value )
{
this->MakefileMap->RemoveDefinition(op);
this->Makefile->RemoveDefinition(op);
return;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass()
<< "::SetOption(" << op << ", " << value << ")" << std::endl);
this->MakefileMap->AddDefinition(op, value);
this->Makefile->AddDefinition(op, value);
}
//----------------------------------------------------------------------
@ -680,7 +680,7 @@ int cmCPackGenericGenerator::ProcessGenerator()
int cmCPackGenericGenerator::Initialize(const char* name, cmMakefile* mf,
const char* argv0)
{
this->MakefileMap = mf;
this->Makefile = mf;
this->Name = name;
if ( !this->FindRunningCMake(argv0) )
{
@ -700,7 +700,7 @@ int cmCPackGenericGenerator::InitializeInternal()
//----------------------------------------------------------------------
const char* cmCPackGenericGenerator::GetOption(const char* op)
{
return this->MakefileMap->GetDefinition(op);
return this->Makefile->GetDefinition(op);
}
//----------------------------------------------------------------------
@ -913,7 +913,7 @@ std::string cmCPackGenericGenerator::FindTemplate(const char* name)
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: "
<< (name ? name : "(NULL)") << std::endl);
std::string ffile = this->MakefileMap->GetModulesFile(name);
std::string ffile = this->Makefile->GetModulesFile(name);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: "
<< ffile.c_str() << std::endl);
return ffile;
@ -923,7 +923,7 @@ std::string cmCPackGenericGenerator::FindTemplate(const char* name)
bool cmCPackGenericGenerator::ConfigureString(const std::string& inString,
std::string& outString)
{
this->MakefileMap->ConfigureString(inString,
this->Makefile->ConfigureString(inString,
outString, true, false);
return true;
}
@ -932,7 +932,7 @@ bool cmCPackGenericGenerator::ConfigureString(const std::string& inString,
bool cmCPackGenericGenerator::ConfigureFile(const char* inName,
const char* outName, bool copyOnly /* = false */)
{
return this->MakefileMap->ConfigureFile(inName, outName,
return this->Makefile->ConfigureFile(inName, outName,
copyOnly, true, false) == 1;
}

View File

@ -130,8 +130,7 @@ protected:
cmCPackLog* Logger;
private:
cmMakefile* MakefileMap;
cmMakefile* Makefile;
};
#endif

View File

@ -243,6 +243,25 @@ int main (int argc, char *argv[])
if ( parsed && !help )
{
// find out which system cpack is running on, so it can setup the search
// paths, so FIND_XXX() commands can be used in scripts
cminst.AddCMakePaths(argv[0]);
std::string systemFile = globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
if (!globalMF->ReadListFile(0, systemFile.c_str()))
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error reading CMakeDetermineSystem.cmake" << std::endl);
return 1;
}
systemFile = globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
if (!globalMF->ReadListFile(0, systemFile.c_str()))
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error reading CMakeSystemSpecificInformation.cmake" << std::endl);
return 1;
}
if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) )
{
cpackConfigFile =
@ -327,7 +346,6 @@ int main (int argc, char *argv[])
const char* gen = it->c_str();
cmMakefile newMF(*globalMF);
cmMakefile* mf = &newMF;
{
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Specified generator: " << gen << std::endl);
if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
@ -420,7 +438,6 @@ int main (int argc, char *argv[])
}
}
}
}
if ( !parsed || help )
{