From 528f60f4a60440097a4a4997cdf59f0e564ba370 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 9 Mar 2007 09:30:16 -0500 Subject: ENH: Added implib option to cmTarget::GetDirectory to support a separate directory containing the import library. This is an incremental step for bug#4210. --- Source/cmInstallTargetGenerator.cxx | 2 +- Source/cmLocalGenerator.cxx | 8 ++++++-- Source/cmLocalVisualStudio7Generator.cxx | 24 +++++++++--------------- Source/cmMakefileLibraryTargetGenerator.cxx | 6 +++++- Source/cmTarget.cxx | 21 +++++++++++++++------ Source/cmTarget.h | 4 ++-- 6 files changed, 38 insertions(+), 27 deletions(-) diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 916d990..fd585da 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -54,7 +54,7 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os) } else { - fromDir = this->Target->GetDirectory(); + fromDir = this->Target->GetDirectory(0, this->ImportLibrary); fromDir += "/"; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8184a8e..4556715 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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 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) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 218acc8..3ddc2d5 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -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 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) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 786afa3..3d0f092 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -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. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f3e59e5..47e8a90 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -661,7 +661,7 @@ const std::vector& 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(implib); + if(this->OutputDir.empty()) { // Lookup the output path for this target type. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c58f853..d5b5474 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -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; -- cgit v0.12