diff options
author | Brad King <brad.king@kitware.com> | 2007-03-19 14:00:36 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2007-03-19 14:00:36 (GMT) |
commit | fc7c43346318744d05829579e6312aecddc66207 (patch) | |
tree | c5189c40170f90423c4b2a0cf72a5610282d1d8e /Source/cmMakefileExecutableTargetGenerator.cxx | |
parent | 43589ec702cd037ed6b5c9f2c8b7558f4cb8801b (diff) | |
download | CMake-fc7c43346318744d05829579e6312aecddc66207.zip CMake-fc7c43346318744d05829579e6312aecddc66207.tar.gz CMake-fc7c43346318744d05829579e6312aecddc66207.tar.bz2 |
ENH: Added support for import libraries created by executable and module targets. The module import libraries should never be used but some windows compilers always create them for .dll files since there is no distinction from shared libraries on that platform. The executable import libraries may be used to create modules that when loaded bind to symbols from the executables. This is an enhancement related to bug#4210 though not requested by it explicitly.
Diffstat (limited to 'Source/cmMakefileExecutableTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 06b054a..2414458 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -110,9 +110,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the name of the executable to generate. std::string targetName; std::string targetNameReal; + std::string targetNameImport; std::string targetNamePDB; this->Target->GetExecutableNames - (targetName, targetNameReal, targetNamePDB, + (targetName, targetNameReal, targetNameImport, targetNamePDB, this->LocalGenerator->ConfigurationName.c_str()); // Construct the full path version of the names. @@ -167,6 +168,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) false, false, false); } #endif + std::string outpathImp; if(relink) { outpath = this->Makefile->GetStartOutputDirectory(); @@ -174,10 +176,23 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) outpath += "/CMakeRelink.dir"; cmSystemTools::MakeDirectory(outpath.c_str()); outpath += "/"; + if(!targetNameImport.empty()) + { + outpathImp = outpath; + } + } + else + { + if(!targetNameImport.empty()) + { + outpathImp = this->Target->GetDirectory(0, true); + outpathImp += "/"; + } } std::string targetFullPath = outpath + targetName; std::string targetFullPathReal = outpath + targetNameReal; std::string targetFullPathPDB = outpath + targetNamePDB; + std::string targetFullPathImport = outpathImp + targetNameImport; std::string targetOutPathPDB = this->Convert(targetFullPathPDB.c_str(), cmLocalGenerator::FULL, @@ -191,7 +206,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->Convert(targetFullPathReal.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); - + std::string targetOutPathImport = + this->Convert(targetFullPathImport.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + // Get the language to use for linking this executable. const char* linkLanguage = this->Target->GetLinkerLanguage(this->GlobalGenerator); @@ -258,14 +277,16 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) { std::string cleanName; std::string cleanRealName; + std::string cleanImportName; std::string cleanPDBName; this->Target->GetExecutableCleanNames - (cleanName, cleanRealName, cleanPDBName, + (cleanName, cleanRealName, cleanImportName, cleanPDBName, this->LocalGenerator->ConfigurationName.c_str()); std::string cleanFullName = outpath + cleanName; std::string cleanFullRealName = outpath + cleanRealName; std::string cleanFullPDBName = outpath + cleanPDBName; + std::string cleanFullImportName = outpathImp + cleanImportName; exeCleanFiles.push_back(this->Convert(cleanFullName.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); @@ -282,6 +303,12 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } + if(!cleanImportName.empty()) + { + exeCleanFiles.push_back(this->Convert(cleanFullImportName.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } // List the PDB for cleaning only when the whole target is // cleaned. We do not want to delete the .pdb file just before @@ -394,11 +421,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) vars.Flags = flags.c_str(); vars.LinkFlags = linkFlags.c_str(); // Expand placeholders in the commands. + this->LocalGenerator->TargetImplib = targetOutPathImport; for(std::vector<std::string>::iterator i = commands.begin(); i != commands.end(); ++i) { this->LocalGenerator->ExpandRuleVariables(*i, vars); } + this->LocalGenerator->TargetImplib = ""; // Write the build rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, |