summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2011-12-06 20:07:39 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2011-12-06 20:07:39 (GMT)
commit386cf3c593ad425fea9b2bddf5ee34d8d36dfe15 (patch)
tree4dabe2b44c04e1f5bf49defd4ce88e3c630d34d9 /Source
parentb8c0dd48b045457b97386ed6bad5f31b5788c6c5 (diff)
parentae62a1cd35fcd9be8d1beb11c864fbe417de429e (diff)
downloadCMake-386cf3c593ad425fea9b2bddf5ee34d8d36dfe15.zip
CMake-386cf3c593ad425fea9b2bddf5ee34d8d36dfe15.tar.gz
CMake-386cf3c593ad425fea9b2bddf5ee34d8d36dfe15.tar.bz2
Merge topic 'GNU-to-MS'
ae62a1c Test CMAKE_GNUtoMS option in ExportImport on MinGW and MSys afb00fe Add CMAKE_GNUtoMS option to convert GNU .dll.a to MS .lib 61e8629 Factor makefile generator link rule lookup into helper function a603250 Load platform files that need to know the ABI when possible ecd8414 Fortran: Detect pointer size in gfortran on MinGW
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDocumentVariables.cxx11
-rw-r--r--Source/cmExportBuildFileGenerator.cxx2
-rw-r--r--Source/cmInstallTargetGenerator.cxx26
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx10
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx9
-rw-r--r--Source/cmMakefileTargetGenerator.cxx17
-rw-r--r--Source/cmMakefileTargetGenerator.h3
-rw-r--r--Source/cmTarget.cxx38
-rw-r--r--Source/cmTarget.h8
9 files changed, 119 insertions, 5 deletions
diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx
index ed303c9..c8c83b9 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -1112,6 +1112,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
"Variables that Control the Build");
cm->DefineProperty
+ ("CMAKE_GNUtoMS", cmProperty::VARIABLE,
+ "Convert GNU import libraries (.dll.a) to MS format (.lib).",
+ "This variable is used to initialize the GNUtoMS property on targets "
+ "when they are created. "
+ "See that target property for additional information.",
+ false,
+ "Variables that Control the Build");
+
+ cm->DefineProperty
("CMAKE_DEBUG_POSTFIX", cmProperty::VARIABLE,
"See variable CMAKE_<CONFIG>_POSTFIX.",
"This variable is a special case of the more-general "
@@ -1515,6 +1524,8 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
cmProperty::VARIABLE,0,0);
cm->DefineProperty("CMAKE_<LANG>_COMPILER_ID_RUN",
cmProperty::VARIABLE,0,0);
+ cm->DefineProperty("CMAKE_<LANG>_ABI_FILES",
+ cmProperty::VARIABLE,0,0);
cm->DefineProperty("CMAKE_<LANG>_CREATE_ASSEMBLY_SOURCE",
cmProperty::VARIABLE,0,0);
cm->DefineProperty("CMAKE_<LANG>_CREATE_PREPROCESSED_SOURCE",
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 7e73e36..32595ee 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -125,6 +125,8 @@ cmExportBuildFileGenerator
std::string prop = "IMPORTED_IMPLIB";
prop += suffix;
std::string value = target->GetFullPath(config, true);
+ target->GetImplibGNUtoMS(value, value,
+ "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
properties[prop] = value;
}
}
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 33ffbfb..ac1c949 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -101,6 +101,13 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
std::string to1 = toDir + targetNameImport;
filesFrom.push_back(from1);
filesTo.push_back(to1);
+ std::string targetNameImportLib;
+ if(this->Target->GetImplibGNUtoMS(targetNameImport,
+ targetNameImportLib))
+ {
+ filesFrom.push_back(fromDirConfig + targetNameImportLib);
+ filesTo.push_back(toDir + targetNameImportLib);
+ }
// An import library looks like a static library.
type = cmTarget::STATIC_LIBRARY;
@@ -157,6 +164,13 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
std::string to1 = toDir + targetNameImport;
filesFrom.push_back(from1);
filesTo.push_back(to1);
+ std::string targetNameImportLib;
+ if(this->Target->GetImplibGNUtoMS(targetNameImport,
+ targetNameImportLib))
+ {
+ filesFrom.push_back(fromDirConfig + targetNameImportLib);
+ filesTo.push_back(toDir + targetNameImportLib);
+ }
// An import library looks like a static library.
type = cmTarget::STATIC_LIBRARY;
@@ -314,7 +328,11 @@ std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target,
if(nameType == NameImplib)
{
// Use the import library name.
- fname = targetNameImport;
+ if(!target->GetImplibGNUtoMS(targetNameImport, fname,
+ "${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
+ {
+ fname = targetNameImport;
+ }
}
else if(nameType == NameReal)
{
@@ -339,7 +357,11 @@ std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target,
if(nameType == NameImplib)
{
// Use the import library name.
- fname = targetNameImport;
+ if(!target->GetImplibGNUtoMS(targetNameImport, fname,
+ "${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
+ {
+ fname = targetNameImport;
+ }
}
else if(nameType == NameSO)
{
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index cd75d79..78278cb 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -241,6 +241,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
exeCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
+ std::string implib;
+ if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
+ {
+ exeCleanFiles.push_back(this->Convert(implib.c_str(),
+ cmLocalGenerator::START_OUTPUT,
+ cmLocalGenerator::UNCHANGED));
+ }
}
// List the PDB for cleaning only when the whole target is
@@ -270,8 +277,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
std::string linkRuleVar = "CMAKE_";
linkRuleVar += linkLanguage;
linkRuleVar += "_LINK_EXECUTABLE";
- std::string linkRule =
- this->Makefile->GetRequiredDefinition(linkRuleVar.c_str());
+ std::string linkRule = this->GetLinkRule(linkRuleVar.c_str());
std::vector<std::string> commands1;
cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
if(this->Target->IsExecutableWithExports())
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 31f7be5..b4174cc 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -512,6 +512,13 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
+ std::string implib;
+ if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
+ {
+ libCleanFiles.push_back(this->Convert(implib.c_str(),
+ cmLocalGenerator::START_OUTPUT,
+ cmLocalGenerator::UNCHANGED));
+ }
}
// List the PDB for cleaning only when the whole target is
@@ -772,7 +779,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
else
{
// Get the set of commands.
- std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
+ std::string linkRule = this->GetLinkRule(linkRuleVar);
cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
// Expand placeholders.
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 8b91194..a3a832b 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1634,6 +1634,23 @@ void cmMakefileTargetGenerator
}
//----------------------------------------------------------------------------
+std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar)
+{
+ std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
+ if(this->Target->HasImplibGNUtoMS())
+ {
+ std::string ruleVar = "CMAKE_";
+ ruleVar += this->Target->GetLinkerLanguage(this->ConfigName);
+ ruleVar += "_GNUtoMS_RULE";
+ if(const char* rule = this->Makefile->GetDefinition(ruleVar.c_str()))
+ {
+ linkRule += rule;
+ }
+ }
+ return linkRule;
+}
+
+//----------------------------------------------------------------------------
void cmMakefileTargetGenerator
::CloseFileStreams()
{
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 674cd13..8fba13f 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -120,6 +120,9 @@ protected:
// Append link rule dependencies (objects, etc.).
void AppendLinkDepends(std::vector<std::string>& depends);
+ // Lookup the link rule for this target.
+ std::string GetLinkRule(const char* linkRuleVar);
+
/** In order to support parallel builds for custom commands with
multiple outputs the outputs are given a serial order, and only
the first output actually has the build rule. Other outputs
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 7e02a39..87f8c5e 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -972,6 +972,23 @@ void cmTarget::DefineProperties(cmake *cm)
"is created its value is used to initialize this property.");
cm->DefineProperty
+ ("GNUtoMS", cmProperty::TARGET,
+ "Convert GNU import library (.dll.a) to MS format (.lib).",
+ "When linking a shared library or executable that exports symbols "
+ "using GNU tools on Windows (MinGW/MSYS) with Visual Studio installed "
+ "convert the import library (.dll.a) from GNU to MS format (.lib). "
+ "Both import libraries will be installed by install(TARGETS) and "
+ "exported by install(EXPORT) and export() to be linked by applications "
+ "with either GNU- or MS-compatible tools."
+ "\n"
+ "If the variable CMAKE_GNUtoMS is set when a target "
+ "is created its value is used to initialize this property. "
+ "The variable must be set prior to the first command that enables "
+ "a language such as project() or enable_language(). "
+ "CMake provides the variable as an option to the user automatically "
+ "when configuring on Windows with GNU tools.");
+
+ cm->DefineProperty
("XCODE_ATTRIBUTE_<an-attribute>", cmProperty::TARGET,
"Set Xcode target attributes directly.",
"Tell the Xcode generator to set '<an-attribute>' to a given value "
@@ -1210,6 +1227,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0);
this->SetPropertyDefault("Fortran_FORMAT", 0);
this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0);
+ this->SetPropertyDefault("GNUtoMS", 0);
this->SetPropertyDefault("OSX_ARCHITECTURES", 0);
this->SetPropertyDefault("AUTOMOC", 0);
this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0);
@@ -3472,6 +3490,26 @@ void cmTarget::GetExecutableNames(std::string& name,
}
//----------------------------------------------------------------------------
+bool cmTarget::HasImplibGNUtoMS()
+{
+ return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS");
+}
+
+//----------------------------------------------------------------------------
+bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName,
+ std::string& out, const char* newExt)
+{
+ if(this->HasImplibGNUtoMS() &&
+ gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a")
+ {
+ out = gnuName.substr(0, gnuName.size()-6);
+ out += newExt? newExt : ".lib";
+ return true;
+ }
+ return false;
+}
+
+//----------------------------------------------------------------------------
void cmTarget::GenerateTargetManifest(const char* config)
{
cmMakefile* mf = this->Makefile;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 0abdddb..09fee6c 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -369,6 +369,14 @@ public:
std::string& impName,
std::string& pdbName, const char* config);
+ /** Does this target have a GNU implib to convert to MS format? */
+ bool HasImplibGNUtoMS();
+
+ /** Convert the given GNU import library name (.dll.a) to a name with a new
+ extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */
+ bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
+ const char* newExt = 0);
+
/** Add the target output files to the global generator manifest. */
void GenerateTargetManifest(const char* config);