[cmake-commits] king committed cmLocalGenerator.cxx 1.205 1.206
cmMakefile.cxx 1.379 1.380
cmMakefileExecutableTargetGenerator.cxx 1.31 1.32 cmTarget.cxx
1.131 1.132
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Mar 22 08:45:27 EST 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv10697/Source
Modified Files:
cmLocalGenerator.cxx cmMakefile.cxx
cmMakefileExecutableTargetGenerator.cxx cmTarget.cxx
Log Message:
ENH: Added target property ENABLE_EXPORTS for executable targets. It enables the executables for linking by loadable modules that import symbols from the executable. This finishes the executable import library support mentioned in bug #4210.
Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.205
retrieving revision 1.206
diff -u -d -r1.205 -r1.206
--- cmLocalGenerator.cxx 16 Mar 2007 14:34:25 -0000 1.205
+++ cmLocalGenerator.cxx 22 Mar 2007 13:45:24 -0000 1.206
@@ -1659,9 +1659,19 @@
{
// Compute the proper name to use to link this library.
cmTarget* tgt = this->GlobalGenerator->FindTarget(0, lib.c_str());
- if(tgt && (tgt->GetType() == cmTarget::STATIC_LIBRARY ||
- tgt->GetType() == cmTarget::SHARED_LIBRARY ||
- tgt->GetType() == cmTarget::MODULE_LIBRARY))
+ bool impexe = (tgt &&
+ tgt->GetType() == cmTarget::EXECUTABLE &&
+ tgt->GetPropertyAsBool("ENABLE_EXPORTS"));
+ if(impexe && !implib)
+ {
+ // Skip linking to executables on platforms with no import
+ // libraries.
+ continue;
+ }
+ else if(tgt && (tgt->GetType() == cmTarget::STATIC_LIBRARY ||
+ tgt->GetType() == cmTarget::SHARED_LIBRARY ||
+ tgt->GetType() == cmTarget::MODULE_LIBRARY ||
+ impexe))
{
// This is a CMake target. Ask the target for its real name.
// Pass the full path to the target file but purposely leave
Index: cmMakefileExecutableTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileExecutableTargetGenerator.cxx,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- cmMakefileExecutableTargetGenerator.cxx 19 Mar 2007 14:00:35 -0000 1.31
+++ cmMakefileExecutableTargetGenerator.cxx 22 Mar 2007 13:45:24 -0000 1.32
@@ -347,6 +347,19 @@
std::string linkRule =
this->Makefile->GetRequiredDefinition(linkRuleVar.c_str());
cmSystemTools::ExpandListArgument(linkRule, commands1);
+ if(this->Target->GetPropertyAsBool("ENABLE_EXPORTS"))
+ {
+ // If a separate rule for creating an import library is specified
+ // add it now.
+ std::string implibRuleVar = "CMAKE_";
+ implibRuleVar += linkLanguage;
+ implibRuleVar += "_CREATE_IMPORT_LIBRARY";
+ if(const char* rule =
+ this->Makefile->GetDefinition(implibRuleVar.c_str()))
+ {
+ cmSystemTools::ExpandListArgument(rule, commands1);
+ }
+ }
this->LocalGenerator->CreateCDCommand
(commands1,
this->Makefile->GetStartOutputDirectory(),
Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- cmTarget.cxx 19 Mar 2007 14:00:35 -0000 1.131
+++ cmTarget.cxx 22 Mar 2007 13:45:24 -0000 1.132
@@ -259,6 +259,23 @@
"how the executable will be linked.");
cm->DefineProperty
+ ("ENABLE_EXPORTS", cmProperty::TARGET,
+ "Specify whether an executable exports symbols for loadable modules.",
+ "Normally an executable does not export any symbols because it is "
+ "the final program. It is possible for an executable to export "
+ "symbols to be used by loadable modules. When this property is "
+ "set to true CMake will allow other targets to \"link\" to the "
+ "executable with the TARGET_LINK_LIBRARIES command. "
+ "On all platforms a target-level dependency on the executable is "
+ "created for targets that link to it. "
+ "For non-DLL platforms the link rule is simply ignored since "
+ "the dynamic loader will automatically bind symbols when the "
+ "module is loaded. "
+ "For DLL platforms an import library will be created for the "
+ "exported symbols and then used for linking. "
+ "All Windows-based systems including Cygwin are DLL platforms.");
+
+ cm->DefineProperty
("OBJECT_FILES", cmProperty::TARGET,
"Used to get the resulting list of object files that make up a "
"target.",
Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.379
retrieving revision 1.380
diff -u -d -r1.379 -r1.380
--- cmMakefile.cxx 15 Mar 2007 17:48:15 -0000 1.379
+++ cmMakefile.cxx 22 Mar 2007 13:45:24 -0000 1.380
@@ -944,13 +944,16 @@
}
// if it is not a static or shared library then you can not link to it
if(!((tgt->GetType() == cmTarget::STATIC_LIBRARY) ||
- (tgt->GetType() == cmTarget::SHARED_LIBRARY)))
+ (tgt->GetType() == cmTarget::SHARED_LIBRARY) ||
+ (tgt->GetType() == cmTarget::EXECUTABLE &&
+ tgt->GetPropertyAsBool("ENABLE_EXPORTS"))))
{
cmOStringStream e;
e << "Attempt to add link target " << lib << " of type: "
<< cmTarget::TargetTypeNames[static_cast<int>(tgt->GetType())]
<< "\nto target " << target
- << ". You can only link to STATIC or SHARED libraries.";
+ << ". One can only link to STATIC or SHARED libraries, or "
+ << "to executables with the ENABLE_EXPORTS property set.";
// in older versions of cmake linking to modules was allowed
if( tgt->GetType() == cmTarget::MODULE_LIBRARY )
{
More information about the Cmake-commits
mailing list