ENH: Handle large object file lists on some platforms

- Use a response file when enabled by
    CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_OBJECTS
  - Enable for C and CXX with cl (MSVC)
  - Enable for Fortran with ifort (Intel Fortran)
This commit is contained in:
Brad King
2008-02-27 17:10:45 -05:00
parent 4c137bad6b
commit dfe2ea6406
7 changed files with 93 additions and 8 deletions
+27 -1
View File
@@ -567,6 +567,18 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Determine whether a link script will be used.
bool useLinkScript = this->GlobalGenerator->GetUseLinkScript();
// Select whether to use a response file for objects.
bool useResponseFile = false;
{
std::string responseVar = "CMAKE_";
responseVar += linkLanguage;
responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
if(this->Makefile->IsOn(responseVar.c_str()))
{
useResponseFile = true;
}
}
// For static libraries there might be archiving rules.
std::vector<std::string> archiveCreateCommands;
std::vector<std::string> archiveAppendCommands;
@@ -605,6 +617,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Archiving rules are always run with a link script.
useLinkScript = true;
// Archiving rules never use a response file.
useResponseFile = false;
// Limit the length of individual object lists to less than the
// 32K command line length limit on Windows. We could make this a
// platform file variable but this should work everywhere.
@@ -631,7 +646,18 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string variableNameExternal;
this->WriteObjectsVariable(variableName, variableNameExternal);
std::string buildObjs;
if(useLinkScript)
if(useResponseFile)
{
std::string objects;
this->WriteObjectsString(objects);
std::string objects_rsp =
this->CreateResponseFile("objects.rsp", objects, depends);
buildObjs = "@";
buildObjs += this->Convert(objects_rsp.c_str(),
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
}
else if(useLinkScript)
{
if(!useArchiveRules)
{