summaryrefslogtreecommitdiffstats
path: root/Source/cmTargetLinkLibrariesCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmTargetLinkLibrariesCommand.cxx')
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 70ba944..d2d80df 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -25,6 +25,9 @@ bool cmTargetLinkLibrariesCommand::InitialPass(std::vector<std::string> const& a
this->SetError("called with incorrect number of arguments");
return false;
}
+
+ m_TargetName = args[0];
+
// but we might not have any libs after variable expansion
if(args.size() < 2)
{
@@ -59,11 +62,16 @@ bool cmTargetLinkLibrariesCommand::InitialPass(std::vector<std::string> const& a
if (cmSystemTools::IsOff(ldir))
{
std::string libPath = *i + "_CMAKE_PATH";
+
const char* dir = m_Makefile->GetDefinition(libPath.c_str());
if( dir )
{
m_Makefile->AddLinkDirectoryForTarget(args[0].c_str(), dir );
}
+ else
+ {
+ m_HasLocation.push_back(*i);
+ }
}
else
{
@@ -73,3 +81,23 @@ bool cmTargetLinkLibrariesCommand::InitialPass(std::vector<std::string> const& a
return true;
}
+void cmTargetLinkLibrariesCommand::FinalPass()
+{
+ std::vector<std::string>::size_type cc;
+ std::string libPath;
+ for ( cc = 0; cc < m_HasLocation.size(); cc ++ )
+ {
+ libPath = m_HasLocation[cc] + "_CMAKE_PATH";
+ const char* dir = m_Makefile->GetDefinition(libPath.c_str());
+ if ( dir )
+ {
+ std::string str = "Library " + m_HasLocation[cc] +
+ " is defined using ADD_LIBRARY after the library is used "
+ "using TARGET_LINK_LIBRARIES for the target " + m_TargetName +
+ ". This breaks CMake's dependency "
+ "handling. Please fix the CMakeLists.txt file.";
+ this->SetError(str.c_str());
+ cmSystemTools::Message(str.c_str(), "CMake Error");
+ }
+ }
+}