ENH: Added implib option to cmTarget::GetDirectory to support a separate directory containing the import library. This is an incremental step for bug#4210.
This commit is contained in:
parent
3ec0ff05de
commit
528f60f4a6
|
@ -54,7 +54,7 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
|
|||
}
|
||||
else
|
||||
{
|
||||
fromDir = this->Target->GetDirectory();
|
||||
fromDir = this->Target->GetDirectory(0, this->ImportLibrary);
|
||||
fromDir += "/";
|
||||
}
|
||||
|
||||
|
|
|
@ -1619,6 +1619,10 @@ void cmLocalGenerator
|
|||
linkType = cmTarget::DEBUG;
|
||||
}
|
||||
|
||||
// Check whether we should use an import library for linking a target.
|
||||
bool implib =
|
||||
this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")?true:false;
|
||||
|
||||
// Get the list of libraries against which this target wants to link.
|
||||
std::vector<std::string> linkLibraries;
|
||||
const cmTarget::LinkLibraryVectorType& inLibs = target.GetLinkLibraries();
|
||||
|
@ -1658,9 +1662,9 @@ void cmLocalGenerator
|
|||
// Pass the full path to the target file but purposely leave
|
||||
// off the per-configuration subdirectory. The link directory
|
||||
// ordering knows how to deal with this.
|
||||
std::string linkItem = tgt->GetDirectory(0);
|
||||
std::string linkItem = tgt->GetDirectory(0, implib);
|
||||
linkItem += "/";
|
||||
linkItem += tgt->GetFullName(config);
|
||||
linkItem += tgt->GetFullName(config, implib);
|
||||
linkLibraries.push_back(linkItem);
|
||||
// For full path, use the true location.
|
||||
if(fullPathLibs)
|
||||
|
|
|
@ -605,7 +605,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
|||
target.GetType() == cmTarget::MODULE_LIBRARY))
|
||||
{
|
||||
fout << "\t\t\t\tProgramDataBaseFileName=\""
|
||||
<< target.GetDirectory() << "/$(OutDir)/"
|
||||
<< target.GetDirectory(configName) << "/"
|
||||
<< target.GetPDBName(configName) << "\"\n";
|
||||
}
|
||||
fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
|
||||
|
@ -728,8 +728,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
case cmTarget::STATIC_LIBRARY:
|
||||
{
|
||||
std::string targetNameFull = target.GetFullName(configName);
|
||||
std::string libpath = target.GetDirectory();
|
||||
libpath += "/$(OutDir)/";
|
||||
std::string libpath = target.GetDirectory(configName);
|
||||
libpath += "/";
|
||||
libpath += targetNameFull;
|
||||
fout << "\t\t\t<Tool\n"
|
||||
<< "\t\t\t\tName=\"VCLibrarianTool\"\n";
|
||||
|
@ -795,9 +795,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
<< " ";
|
||||
this->OutputLibraries(fout, linkLibs);
|
||||
fout << "\"\n";
|
||||
temp = target.GetDirectory();
|
||||
temp += "/";
|
||||
temp += configName;
|
||||
temp = target.GetDirectory(configName);
|
||||
temp += "/";
|
||||
temp += targetNameFull;
|
||||
fout << "\t\t\t\tOutputFile=\""
|
||||
|
@ -808,8 +806,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
this->OutputLibraryDirectories(fout, linkDirs);
|
||||
fout << "\"\n";
|
||||
this->OutputModuleDefinitionFile(fout, target);
|
||||
temp = target.GetDirectory();
|
||||
temp += "/$(OutDir)/";
|
||||
temp = target.GetDirectory(configName);
|
||||
temp += "/";
|
||||
temp += targetNamePDB;
|
||||
fout << "\t\t\t\tProgramDataBaseFile=\"" <<
|
||||
this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
|
||||
|
@ -826,9 +824,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
{
|
||||
fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n";
|
||||
}
|
||||
temp = target.GetDirectory();
|
||||
temp += "/";
|
||||
temp += configName;
|
||||
temp = target.GetDirectory(configName, true);
|
||||
temp += "/";
|
||||
temp += targetNameImport;
|
||||
fout << "\t\t\t\tImportLibrary=\""
|
||||
|
@ -875,9 +871,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
<< " ";
|
||||
this->OutputLibraries(fout, linkLibs);
|
||||
fout << "\"\n";
|
||||
temp = target.GetDirectory();
|
||||
temp += "/";
|
||||
temp += configName;
|
||||
temp = target.GetDirectory(configName);
|
||||
temp += "/";
|
||||
temp += targetNameFull;
|
||||
fout << "\t\t\t\tOutputFile=\""
|
||||
|
@ -888,7 +882,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
|
|||
this->OutputLibraryDirectories(fout, linkDirs);
|
||||
fout << "\"\n";
|
||||
fout << "\t\t\t\tProgramDataBaseFile=\""
|
||||
<< target.GetDirectory() << "\\$(OutDir)\\" << targetNamePDB
|
||||
<< target.GetDirectory(configName) << "/" << targetNamePDB
|
||||
<< "\"\n";
|
||||
if(strcmp(configName, "Debug") == 0
|
||||
|| strcmp(configName, "RelWithDebInfo") == 0)
|
||||
|
|
|
@ -246,6 +246,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||
|
||||
// Construct the full path version of the names.
|
||||
std::string outpath;
|
||||
std::string outpathImp;
|
||||
if(relink)
|
||||
{
|
||||
outpath = this->Makefile->GetStartOutputDirectory();
|
||||
|
@ -253,17 +254,20 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||
outpath += "/CMakeRelink.dir";
|
||||
cmSystemTools::MakeDirectory(outpath.c_str());
|
||||
outpath += "/";
|
||||
outpathImp = outpath;
|
||||
}
|
||||
else
|
||||
{
|
||||
outpath = this->Target->GetDirectory();
|
||||
outpath += "/";
|
||||
outpathImp = this->Target->GetDirectory(0, true);
|
||||
outpathImp += "/";
|
||||
}
|
||||
std::string targetFullPath = outpath + targetName;
|
||||
std::string targetFullPathPDB = outpath + targetNamePDB;
|
||||
std::string targetFullPathSO = outpath + targetNameSO;
|
||||
std::string targetFullPathReal = outpath + targetNameReal;
|
||||
std::string targetFullPathImport = outpath + targetNameImport;
|
||||
std::string targetFullPathImport = outpathImp + targetNameImport;
|
||||
|
||||
// Construct the output path version of the names for use in command
|
||||
// arguments.
|
||||
|
|
|
@ -661,7 +661,7 @@ const std::vector<std::string>& cmTarget::GetLinkDirectories()
|
|||
// Add the directory only if it is not already present. This
|
||||
// is an N^2 algorithm for adding the directories, but N
|
||||
// should not get very big.
|
||||
const char* libpath = tgt->GetDirectory();
|
||||
const char* libpath = tgt->GetDirectory(0, true);
|
||||
if(std::find(this->LinkDirectories.begin(),
|
||||
this->LinkDirectories.end(),
|
||||
libpath) == this->LinkDirectories.end())
|
||||
|
@ -1091,11 +1091,11 @@ void cmTarget::SetProperty(const char* prop, const char* value)
|
|||
this->Properties.SetProperty(prop, value, cmProperty::TARGET);
|
||||
}
|
||||
|
||||
const char* cmTarget::GetDirectory(const char* config)
|
||||
const char* cmTarget::GetDirectory(const char* config, bool implib)
|
||||
{
|
||||
if(config)
|
||||
{
|
||||
this->Directory = this->GetOutputDir();
|
||||
this->Directory = this->GetOutputDir(implib);
|
||||
// Add the configuration's subdirectory.
|
||||
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
|
||||
AppendDirectoryForConfig("/", config, "", this->Directory);
|
||||
|
@ -1103,7 +1103,7 @@ const char* cmTarget::GetDirectory(const char* config)
|
|||
}
|
||||
else
|
||||
{
|
||||
return this->GetOutputDir();
|
||||
return this->GetOutputDir(implib);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1446,7 +1446,7 @@ void cmTarget::GetFullName(std::string& prefix, std::string& base,
|
|||
std::string cmTarget::GetFullPath(const char* config, bool implib)
|
||||
{
|
||||
// Start with the output directory for the target.
|
||||
std::string fpath = this->GetDirectory(config);
|
||||
std::string fpath = this->GetDirectory(config, implib);
|
||||
fpath += "/";
|
||||
|
||||
// Add the full name of the target.
|
||||
|
@ -1935,8 +1935,17 @@ std::string cmTarget::GetInstallNameDirForInstallTree(const char*)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const char* cmTarget::GetOutputDir()
|
||||
const char* cmTarget::GetOutputDir(bool implib)
|
||||
{
|
||||
// The implib option is only allowed for shared libraries.
|
||||
if(this->GetType() != cmTarget::SHARED_LIBRARY)
|
||||
{
|
||||
implib = false;
|
||||
}
|
||||
|
||||
// For now the import library is always in the same directory as the DLL.
|
||||
static_cast<void>(implib);
|
||||
|
||||
if(this->OutputDir.empty())
|
||||
{
|
||||
// Lookup the output path for this target type.
|
||||
|
|
|
@ -174,7 +174,7 @@ public:
|
|||
configuration name is given then the generator will add its
|
||||
subdirectory for that configuration. Otherwise just the canonical
|
||||
output directory is given. */
|
||||
const char* GetDirectory(const char* config = 0);
|
||||
const char* GetDirectory(const char* config = 0, bool implib = false);
|
||||
|
||||
/** Get the location of the target in the build tree for the given
|
||||
configuration. This location is suitable for use as the LOCATION
|
||||
|
@ -340,7 +340,7 @@ private:
|
|||
void SetPropertyDefault(const char* property, const char* default_value);
|
||||
|
||||
// Get the full path to the target output directory.
|
||||
const char* GetOutputDir();
|
||||
const char* GetOutputDir(bool implib);
|
||||
|
||||
private:
|
||||
std::string Name;
|
||||
|
|
Loading…
Reference in New Issue