BUG: Linking to modules is for 2.2 compat only
The compatibility check to allow linking to modules should test for CMake 2.2, not the unreleased 2.3. See issue #7500. Furthermore, the message should be more clear about fixing the code instead of setting CMAKE_BACKWARDS_COMPATIBILITY unless one is just trying to build an existing project.
This commit is contained in:
parent
5264834868
commit
8ee5c92015
|
@ -1222,24 +1222,27 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target,
|
||||||
if(tgt)
|
if(tgt)
|
||||||
{
|
{
|
||||||
// CMake versions below 2.4 allowed linking to modules.
|
// CMake versions below 2.4 allowed linking to modules.
|
||||||
bool allowModules = this->NeedBackwardsCompatibility(2,3);
|
bool allowModules = this->NeedBackwardsCompatibility(2,2);
|
||||||
// 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) ||
|
||||||
tgt->IsExecutableWithExports()))
|
tgt->IsExecutableWithExports()))
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
e << "Attempt to add link target " << lib << " of type: "
|
e << "Target \"" << lib << "\" of type "
|
||||||
<< cmTarget::TargetTypeNames[static_cast<int>(tgt->GetType())]
|
<< cmTarget::TargetTypeNames[static_cast<int>(tgt->GetType())]
|
||||||
<< "\nto target " << target
|
<< " may not be linked into another target. "
|
||||||
<< ". One can only link to STATIC or SHARED libraries, or "
|
<< "One may link only to STATIC or SHARED libraries, or "
|
||||||
<< "to executables with the ENABLE_EXPORTS property set.";
|
<< "to executables with the ENABLE_EXPORTS property set.";
|
||||||
// in older versions of cmake linking to modules was allowed
|
// in older versions of cmake linking to modules was allowed
|
||||||
if( tgt->GetType() == cmTarget::MODULE_LIBRARY )
|
if( tgt->GetType() == cmTarget::MODULE_LIBRARY )
|
||||||
{
|
{
|
||||||
e <<
|
e << "\n"
|
||||||
"\nTo allow linking of modules set "
|
<< "If you are developing a new project, re-organize it to avoid "
|
||||||
"CMAKE_BACKWARDS_COMPATIBILITY to 2.2 or lower\n";
|
<< "linking to modules. "
|
||||||
|
<< "If you are just trying to build an existing project, "
|
||||||
|
<< "set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 or lower to allow "
|
||||||
|
<< "linking to modules.";
|
||||||
}
|
}
|
||||||
// if no modules are allowed then this is always an error
|
// if no modules are allowed then this is always an error
|
||||||
if(!allowModules ||
|
if(!allowModules ||
|
||||||
|
@ -1247,7 +1250,7 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target,
|
||||||
// still an error
|
// still an error
|
||||||
(allowModules && tgt->GetType() != cmTarget::MODULE_LIBRARY))
|
(allowModules && tgt->GetType() != cmTarget::MODULE_LIBRARY))
|
||||||
{
|
{
|
||||||
cmSystemTools::Error(e.str().c_str());
|
this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue