diff options
author | Brad King <brad.king@kitware.com> | 2007-04-17 20:11:00 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2007-04-17 20:11:00 (GMT) |
commit | f9f577255792d567db0536c2a358b371de53bbe8 (patch) | |
tree | 77a9f834540ada8631e2cf9b2367baa48e9ef04b /Source | |
parent | 84584e118468298199400cf1699fe72cafbe7491 (diff) | |
download | CMake-f9f577255792d567db0536c2a358b371de53bbe8.zip CMake-f9f577255792d567db0536c2a358b371de53bbe8.tar.gz CMake-f9f577255792d567db0536c2a358b371de53bbe8.tar.bz2 |
ENH: Added use of platform variable CMAKE_SHARED_MODULE_LOADER_<lang>_FLAG to add a special flag when linking a plugin to an executable that loads it.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8a45dee..cd7822a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1585,7 +1585,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, for(std::vector<cmStdString>::iterator lib = libNames.begin(); lib != libNames.end(); ++lib) { - linkLibs += *lib; + linkLibs += this->Convert(lib->c_str(), NONE, SHELL, false); linkLibs += " "; } @@ -1639,10 +1639,33 @@ void cmLocalGenerator linkType = cmTarget::DEBUG; } + // Get the language used for linking. + const char* linkLanguage = + target.GetLinkerLanguage(this->GetGlobalGenerator()); + if(!linkLanguage) + { + cmSystemTools:: + Error("CMake can not determine linker language for target:", + target.GetName()); + return; + } + // Check whether we should use an import library for linking a target. bool implib = this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")?true:false; + // On platforms without import libraries there may be a special flag + // to use when creating a plugin (module) that obtains symbols from + // the program that will load it. + const char* loader_flag = 0; + if(!implib && target.GetType() == cmTarget::MODULE_LIBRARY) + { + std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; + loader_flag_var += linkLanguage; + loader_flag_var += "_FLAG"; + loader_flag = this->Makefile->GetDefinition(loader_flag_var.c_str()); + } + // Get the list of libraries against which this target wants to link. std::vector<std::string> linkLibraries; const cmTarget::LinkLibraryVectorType& inLibs = target.GetLinkLibraries(); @@ -1677,10 +1700,10 @@ void cmLocalGenerator bool impexe = (tgt && tgt->GetType() == cmTarget::EXECUTABLE && tgt->GetPropertyAsBool("ENABLE_EXPORTS")); - if(impexe && !implib) + if(impexe && !implib && !loader_flag) { // Skip linking to executables on platforms with no import - // libraries. + // libraries or loader flags. continue; } else if(tgt && (tgt->GetType() == cmTarget::STATIC_LIBRARY || @@ -1692,7 +1715,15 @@ 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, implib); + std::string linkItem; + if(impexe && loader_flag) + { + // This link item is an executable that may provide symbols + // used by this target. A special flag is needed on this + // platform. Add it now. + linkItem += loader_flag; + } + linkItem += tgt->GetDirectory(0, implib); linkItem += "/"; linkItem += tgt->GetFullName(config, implib); linkLibraries.push_back(linkItem); @@ -1735,17 +1766,6 @@ void cmLocalGenerator } if(target_type_str) { - // Get the language used for linking. - const char* linkLanguage = - target.GetLinkerLanguage(this->GetGlobalGenerator()); - - if(!linkLanguage) - { - cmSystemTools:: - Error("CMake can not determine linker language for target:", - target.GetName()); - return; - } std::string static_link_type_flag_var = "CMAKE_"; static_link_type_flag_var += target_type_str; static_link_type_flag_var += "_LINK_STATIC_"; |