ENH: fix for vtk 4.4 and other projects that may try to link to a module
This commit is contained in:
parent
c8c3fff032
commit
0f2f074978
|
@ -824,18 +824,37 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target,
|
||||||
this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0, lib);
|
this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0, lib);
|
||||||
if(tgt)
|
if(tgt)
|
||||||
{
|
{
|
||||||
|
bool allowModules = true;
|
||||||
|
const char* versionValue
|
||||||
|
= this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
|
||||||
|
if (versionValue && (atof(versionValue) >= 2.4) )
|
||||||
|
{
|
||||||
|
allowModules = false;
|
||||||
|
}
|
||||||
// if it is not a static or shared library then you can not link to it
|
// if it is not a static or shared library then you can not link to it
|
||||||
if(!((tgt->GetType() == cmTarget::STATIC_LIBRARY) ||
|
if(!((tgt->GetType() == cmTarget::STATIC_LIBRARY) ||
|
||||||
(tgt->GetType() == cmTarget::SHARED_LIBRARY)))
|
(tgt->GetType() == cmTarget::SHARED_LIBRARY)))
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
e << "Attempt to add link library " << lib
|
e << "Attempt to add link target " << lib << " of type: "
|
||||||
<< " which is not a library target to target "
|
<< cmTarget::TargetTypeNames[(int)tgt->GetType()]
|
||||||
<< tgt->GetType() << " " <<
|
<< "\nto target " << target
|
||||||
target << "\n";
|
<< ". You can only link to STATIC or SHARED libraries.";
|
||||||
|
// in older versions of cmake linking to modules was allowed
|
||||||
|
if( tgt->GetType() == cmTarget::MODULE_LIBRARY )
|
||||||
|
{
|
||||||
|
e << "\nTo allow linking of modules set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 or lower\n";
|
||||||
|
}
|
||||||
|
// if no modules are allowed then this is always an error
|
||||||
|
if(!allowModules ||
|
||||||
|
// if we allow modules but the type is not a module then it is
|
||||||
|
// still an error
|
||||||
|
(allowModules && tgt->GetType() != cmTarget::MODULE_LIBRARY))
|
||||||
|
{
|
||||||
cmSystemTools::Error(e.str().c_str());
|
cmSystemTools::Error(e.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
i->second.AddLinkLibrary( *this, target, lib, llt );
|
i->second.AddLinkLibrary( *this, target, lib, llt );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -23,6 +23,11 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <stdlib.h> // required for atof
|
#include <stdlib.h> // required for atof
|
||||||
|
const char* cmTarget::TargetTypeNames[] = {
|
||||||
|
"EXECUTABLE", "STATIC_LIBRARY",
|
||||||
|
"SHARED_LIBRARY", "MODULE_LIBRARY", "UTILITY", "GLOBAL_TARGET",
|
||||||
|
"INSTALL_FILES", "INSTALL_PROGRAMS", "INSTALL_DIRECTORY"
|
||||||
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmTarget::cmTarget()
|
cmTarget::cmTarget()
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
enum TargetType { EXECUTABLE, STATIC_LIBRARY,
|
enum TargetType { EXECUTABLE, STATIC_LIBRARY,
|
||||||
SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET,
|
SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET,
|
||||||
INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY};
|
INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY};
|
||||||
|
static const char* TargetTypeNames[];
|
||||||
enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD };
|
enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue