summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-02-18 20:37:23 (GMT)
committerBrad King <brad.king@kitware.com>2006-02-18 20:37:23 (GMT)
commit81677b31300f058830889e5603bf06ccd9221691 (patch)
tree35946600211458cb15f8269b2a5a607f43ecfc64 /Source
parent9ba02838701e2513414f258dec9d63566ee9b481 (diff)
downloadCMake-81677b31300f058830889e5603bf06ccd9221691.zip
CMake-81677b31300f058830889e5603bf06ccd9221691.tar.gz
CMake-81677b31300f058830889e5603bf06ccd9221691.tar.bz2
ENH: Generate import libraries for DLLs on Cygwin and MinGW.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalGenerator.cxx4
-rw-r--r--Source/cmLocalGenerator.h4
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx36
-rw-r--r--Source/cmTarget.cxx97
-rw-r--r--Source/cmTarget.h24
5 files changed, 109 insertions, 56 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 46fc4e9..4e03ba0 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -872,6 +872,10 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
{
return target;
}
+ if(variable == "TARGET_IMPLIB")
+ {
+ return m_TargetImplib;
+ }
if(variable == "TARGET_BASE")
{
// Strip the last extension off the target name.
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 9937cae..9b33118 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -247,6 +247,10 @@ protected:
bool m_UseRelativePaths;
bool m_IgnoreLibPrefix;
bool Configured;
+
+ // Hack for ExpandRuleVariable until object-oriented version is
+ // committed.
+ std::string m_TargetImplib;
};
#endif
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 206b49d..9f5ce12 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -202,8 +202,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string targetName;
std::string targetNameSO;
std::string targetNameReal;
- this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal,
- this->LocalGenerator->m_ConfigurationName.c_str());
+ std::string targetNameImport;
+ this->Target->GetLibraryNames(
+ targetName, targetNameSO, targetNameReal, targetNameImport,
+ this->LocalGenerator->m_ConfigurationName.c_str());
// Construct the full path version of the names.
std::string outpath = this->LocalGenerator->m_LibraryOutputPath;
@@ -222,6 +224,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string targetFullPath = outpath + targetName;
std::string targetFullPathSO = outpath + targetNameSO;
std::string targetFullPathReal = outpath + targetNameReal;
+ std::string targetFullPathImport = outpath + targetNameImport;
// Construct the output path version of the names for use in command
// arguments.
@@ -234,6 +237,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string targetOutPathReal =
this->Convert(targetFullPathReal.c_str(),cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::MAKEFILE);
+ std::string targetOutPathImport =
+ this->Convert(targetFullPathImport.c_str(),cmLocalGenerator::START_OUTPUT,
+ cmLocalGenerator::MAKEFILE);
// Add the link message.
std::string buildEcho = "Linking ";
@@ -260,15 +266,19 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string cleanSharedName;
std::string cleanSharedSOName;
std::string cleanSharedRealName;
- this->Target->GetLibraryCleanNames(cleanStaticName,
- cleanSharedName,
- cleanSharedSOName,
- cleanSharedRealName,
- this->LocalGenerator->m_ConfigurationName.c_str());
+ std::string cleanImportName;
+ this->Target->GetLibraryCleanNames(
+ cleanStaticName,
+ cleanSharedName,
+ cleanSharedSOName,
+ cleanSharedRealName,
+ cleanImportName,
+ this->LocalGenerator->m_ConfigurationName.c_str());
std::string cleanFullStaticName = outpath + cleanStaticName;
std::string cleanFullSharedName = outpath + cleanSharedName;
std::string cleanFullSharedSOName = outpath + cleanSharedSOName;
std::string cleanFullSharedRealName = outpath + cleanSharedRealName;
+ std::string cleanFullImportName = outpath + cleanImportName;
libCleanFiles.push_back
(this->Convert(cleanFullStaticName.c_str(),cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::MAKEFILE));
@@ -293,6 +303,16 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::MAKEFILE));
}
+ if(!cleanImportName.empty() &&
+ cleanImportName != cleanStaticName &&
+ cleanImportName != cleanSharedSOName &&
+ cleanImportName != cleanSharedRealName &&
+ cleanImportName != cleanSharedName)
+ {
+ libCleanFiles.push_back(this->Convert(cleanFullImportName.c_str(),
+ cmLocalGenerator::START_OUTPUT,
+ cmLocalGenerator::MAKEFILE));
+ }
}
// Add a command to remove any existing files for this library.
std::vector<std::string> commands1;
@@ -363,6 +383,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
cleanObjs += ")";
// Expand placeholders in the commands.
+ this->LocalGenerator->m_TargetImplib = targetOutPathImport;
for(std::vector<std::string>::iterator i = commands.begin();
i != commands.end(); ++i)
{
@@ -375,6 +396,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
targetNameSO.c_str(),
linkFlags.c_str());
}
+ this->LocalGenerator->m_TargetImplib = "";
// Write the build rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index c006bf2..985dd98 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -809,7 +809,7 @@ const char* cmTarget::GetLocation(const char* config)
m_Location += cfgid;
m_Location += "/";
}
- m_Location += this->GetFullName(config);
+ m_Location += this->GetFullName(config, false);
return m_Location.c_str();
}
@@ -997,19 +997,17 @@ const char* cmTarget::GetCreateRuleVariable()
return "";
}
-const char* cmTarget::GetSuffixVariable()
-{
- return this->GetSuffixVariableInternal(this->GetType());
-}
-
-const char* cmTarget::GetSuffixVariableInternal(TargetType type)
+const char* cmTarget::GetSuffixVariableInternal(TargetType type,
+ bool implib)
{
switch(type)
{
case cmTarget::STATIC_LIBRARY:
return "CMAKE_STATIC_LIBRARY_SUFFIX";
case cmTarget::SHARED_LIBRARY:
- return "CMAKE_SHARED_LIBRARY_SUFFIX";
+ return (implib
+ ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
+ : "CMAKE_SHARED_LIBRARY_SUFFIX");
case cmTarget::MODULE_LIBRARY:
return "CMAKE_SHARED_MODULE_SUFFIX";
case cmTarget::EXECUTABLE:
@@ -1023,19 +1021,17 @@ const char* cmTarget::GetSuffixVariableInternal(TargetType type)
}
-const char* cmTarget::GetPrefixVariable()
-{
- return this->GetPrefixVariableInternal(this->GetType());
-}
-
-const char* cmTarget::GetPrefixVariableInternal(TargetType type)
+const char* cmTarget::GetPrefixVariableInternal(TargetType type,
+ bool implib)
{
switch(type)
{
case cmTarget::STATIC_LIBRARY:
return "CMAKE_STATIC_LIBRARY_PREFIX";
case cmTarget::SHARED_LIBRARY:
- return "CMAKE_SHARED_LIBRARY_PREFIX";
+ return (implib
+ ? "CMAKE_IMPORT_LIBRARY_PREFIX"
+ : "CMAKE_SHARED_LIBRARY_PREFIX");
case cmTarget::MODULE_LIBRARY:
return "CMAKE_SHARED_MODULE_PREFIX";
case cmTarget::EXECUTABLE:
@@ -1048,20 +1044,22 @@ const char* cmTarget::GetPrefixVariableInternal(TargetType type)
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetFullName(const char* config)
+std::string cmTarget::GetFullName(const char* config, bool implib)
{
- return this->GetFullNameInternal(this->GetType(), config);
+ return this->GetFullNameInternal(this->GetType(), config, implib);
}
//----------------------------------------------------------------------------
void cmTarget::GetFullName(std::string& prefix, std::string& base,
- std::string& suffix, const char* config)
+ std::string& suffix, const char* config,
+ bool implib)
{
- this->GetFullNameInternal(this->GetType(), config, prefix, base, suffix);
+ this->GetFullNameInternal(this->GetType(), config, implib,
+ prefix, base, suffix);
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetFullPath(const char* config)
+std::string cmTarget::GetFullPath(const char* config, bool implib)
{
// Start with the output directory for the target.
std::string fpath = this->GetDirectory();
@@ -1072,23 +1070,25 @@ std::string cmTarget::GetFullPath(const char* config)
// Add the full name of the target.
fpath += "/";
- fpath += this->GetFullName(config);
+ fpath += this->GetFullName(config, implib);
return fpath;
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetFullNameInternal(TargetType type, const char* config)
+std::string cmTarget::GetFullNameInternal(TargetType type, const char* config,
+ bool implib)
{
std::string prefix;
std::string base;
std::string suffix;
- this->GetFullNameInternal(type, config, prefix, base, suffix);
+ this->GetFullNameInternal(type, config, implib, prefix, base, suffix);
return prefix+base+suffix;
}
//----------------------------------------------------------------------------
void cmTarget::GetFullNameInternal(TargetType type,
const char* config,
+ bool implib,
std::string& outPrefix,
std::string& outBase,
std::string& outSuffix)
@@ -1105,9 +1105,19 @@ void cmTarget::GetFullNameInternal(TargetType type,
return;
}
+ // The implib option is only allowed for shared libraries.
+ if(type != cmTarget::SHARED_LIBRARY)
+ {
+ implib = false;
+ }
+
// Compute the full name for main target types.
- const char* targetPrefix = this->GetProperty("PREFIX");
- const char* targetSuffix = this->GetProperty("SUFFIX");
+ const char* targetPrefix = (implib
+ ? this->GetProperty("IMPORT_PREFIX")
+ : this->GetProperty("PREFIX"));
+ const char* targetSuffix = (implib
+ ? this->GetProperty("IMPORT_SUFFIX")
+ : this->GetProperty("SUFFIX"));
const char* configPostfix = 0;
if(config && *config && type != cmTarget::EXECUTABLE)
{
@@ -1117,8 +1127,8 @@ void cmTarget::GetFullNameInternal(TargetType type,
configVar = cmSystemTools::UpperCase(configVar);
configPostfix = m_Makefile->GetDefinition(configVar.c_str());
}
- const char* prefixVar = this->GetPrefixVariableInternal(type);
- const char* suffixVar = this->GetSuffixVariableInternal(type);
+ const char* prefixVar = this->GetPrefixVariableInternal(type, implib);
+ const char* suffixVar = this->GetSuffixVariableInternal(type, implib);
const char* ll =
this->GetLinkerLanguage(
m_Makefile->GetLocalGenerator()->GetGlobalGenerator());
@@ -1173,23 +1183,26 @@ void cmTarget::GetFullNameInternal(TargetType type,
void cmTarget::GetLibraryNames(std::string& name,
std::string& soName,
std::string& realName,
+ std::string& impName,
const char* config)
{
// Get the names based on the real type of the library.
- this->GetLibraryNamesInternal(name, soName, realName, this->GetType(),
- config);
+ this->GetLibraryNamesInternal(name, soName, realName, impName,
+ this->GetType(), config);
}
void cmTarget::GetLibraryCleanNames(std::string& staticName,
std::string& sharedName,
std::string& sharedSOName,
std::string& sharedRealName,
+ std::string& importName,
const char* config)
{
// Get the name as if this were a static library.
std::string soName;
std::string realName;
- this->GetLibraryNamesInternal(staticName, soName, realName,
+ std::string impName;
+ this->GetLibraryNamesInternal(staticName, soName, realName, impName,
cmTarget::STATIC_LIBRARY, config);
// Get the names as if this were a shared library.
@@ -1200,22 +1213,22 @@ void cmTarget::GetLibraryCleanNames(std::string& staticName,
// shared library will never be present. In the latter case the
// type will never be MODULE. Either way the only names that
// might have to be cleaned are the shared library names.
- this->GetLibraryNamesInternal(sharedName, sharedSOName,
- sharedRealName, cmTarget::SHARED_LIBRARY,
+ this->GetLibraryNamesInternal(sharedName, sharedSOName, sharedRealName,
+ importName, cmTarget::SHARED_LIBRARY,
config);
}
else
{
// Use the name of the real type of the library (shared or module).
- this->GetLibraryNamesInternal(sharedName, sharedSOName,
- sharedRealName, this->GetType(),
- config);
+ this->GetLibraryNamesInternal(sharedName, sharedSOName, sharedRealName,
+ importName, this->GetType(), config);
}
}
void cmTarget::GetLibraryNamesInternal(std::string& name,
std::string& soName,
std::string& realName,
+ std::string& impName,
TargetType type,
const char* config)
{
@@ -1250,7 +1263,7 @@ void cmTarget::GetLibraryNamesInternal(std::string& name,
}
// The library name.
- name = this->GetFullNameInternal(type, config);
+ name = this->GetFullNameInternal(type, config, false);
// The library's soname.
soName = name;
@@ -1272,6 +1285,16 @@ void cmTarget::GetLibraryNamesInternal(std::string& name,
realName += ".";
realName += soversion;
}
+
+ // The import library name.
+ if(type == cmTarget::SHARED_LIBRARY)
+ {
+ impName = this->GetFullNameInternal(type, config, true);
+ }
+ else
+ {
+ impName = "";
+ }
}
void cmTarget::GetExecutableNames(std::string& name,
@@ -1310,7 +1333,7 @@ void cmTarget::GetExecutableNamesInternal(std::string& name,
#endif
// The executable name.
- name = this->GetFullNameInternal(type, config);
+ name = this->GetFullNameInternal(type, config, false);
// The executable's real name on disk.
realName = name;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 0f6749c..1d061f5 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -166,26 +166,23 @@ public:
///! Return the rule variable used to create this type of target,
// need to add CMAKE_(LANG) for full name.
const char* GetCreateRuleVariable();
- ///! Return the name of the variable to look up the target suffix
- const char* GetSuffixVariable();
- ///! Return the name of the variable to look up the target suffix
- const char* GetPrefixVariable();
/** Get the full name of the target according to the settings in its
makefile. */
- std::string GetFullName(const char* config=0);
+ std::string GetFullName(const char* config=0, bool implib = false);
void GetFullName(std::string& prefix, std::string& base, std::string& suffix,
- const char* config=0);
+ const char* config=0, bool implib = false);
/** Get the full path to the target according to the settings in its
makefile and the configuration type. */
- std::string GetFullPath(const char* config=0);
+ std::string GetFullPath(const char* config=0, bool implib = false);
/** Get the names of the library needed to generate a build rule
that takes into account shared library version numbers. This
should be called only on a library target. */
void GetLibraryNames(std::string& name, std::string& soName,
- std::string& realName, const char* config);
+ std::string& realName, std::string& impName,
+ const char* config);
/** Get the names of the library used to remove existing copies of
the library from the build tree either before linking or during
@@ -195,6 +192,7 @@ public:
std::string& sharedName,
std::string& sharedSOName,
std::string& sharedRealName,
+ std::string& importName,
const char* config);
/** Get the names of the executable needed to generate a build rule
@@ -272,15 +270,17 @@ private:
void GatherDependencies( const cmMakefile& mf, const std::string& lib,
DependencyMap& dep_map );
- const char* GetSuffixVariableInternal(TargetType type);
- const char* GetPrefixVariableInternal(TargetType type);
- std::string GetFullNameInternal(TargetType type, const char* config);
- void GetFullNameInternal(TargetType type, const char* config,
+ const char* GetSuffixVariableInternal(TargetType type, bool implib);
+ const char* GetPrefixVariableInternal(TargetType type, bool implib);
+ std::string GetFullNameInternal(TargetType type, const char* config,
+ bool implib);
+ void GetFullNameInternal(TargetType type, const char* config, bool implib,
std::string& outPrefix, std::string& outBase,
std::string& outSuffix);
void GetLibraryNamesInternal(std::string& name,
std::string& soName,
std::string& realName,
+ std::string& impName,
TargetType type,
const char* config);
void GetExecutableNamesInternal(std::string& name,