summaryrefslogtreecommitdiffstats
path: root/Source/cmCPluginAPI.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmCPluginAPI.cxx')
-rw-r--r--Source/cmCPluginAPI.cxx74
1 files changed, 56 insertions, 18 deletions
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 3a08aea..d1f8446 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -7,10 +7,12 @@
#include "cmCPluginAPI.h"
+#include "cmExecutionStatus.h"
+#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
-#include "cmVersion.h"
-
#include "cmSourceFile.h"
+#include "cmState.h"
+#include "cmVersion.h"
#include <stdlib.h>
@@ -75,22 +77,22 @@ void CCONV cmAddCacheDefinition(void* arg, const char* name, const char* value,
switch (type) {
case CM_CACHE_BOOL:
- mf->AddCacheDefinition(name, value, doc, cmState::BOOL);
+ mf->AddCacheDefinition(name, value, doc, cmStateEnums::BOOL);
break;
case CM_CACHE_PATH:
- mf->AddCacheDefinition(name, value, doc, cmState::PATH);
+ mf->AddCacheDefinition(name, value, doc, cmStateEnums::PATH);
break;
case CM_CACHE_FILEPATH:
- mf->AddCacheDefinition(name, value, doc, cmState::FILEPATH);
+ mf->AddCacheDefinition(name, value, doc, cmStateEnums::FILEPATH);
break;
case CM_CACHE_STRING:
- mf->AddCacheDefinition(name, value, doc, cmState::STRING);
+ mf->AddCacheDefinition(name, value, doc, cmStateEnums::STRING);
break;
case CM_CACHE_INTERNAL:
- mf->AddCacheDefinition(name, value, doc, cmState::INTERNAL);
+ mf->AddCacheDefinition(name, value, doc, cmStateEnums::INTERNAL);
break;
case CM_CACHE_STATIC:
- mf->AddCacheDefinition(name, value, doc, cmState::STATIC);
+ mf->AddCacheDefinition(name, value, doc, cmStateEnums::STATIC);
break;
}
}
@@ -162,7 +164,14 @@ void CCONV cmAddLinkDirectoryForTarget(void* arg, const char* tgt,
const char* d)
{
cmMakefile* mf = static_cast<cmMakefile*>(arg);
- mf->AddLinkDirectoryForTarget(tgt, d);
+ cmTarget* t = mf->FindLocalNonAliasTarget(tgt);
+ if (!t) {
+ cmSystemTools::Error(
+ "Attempt to add link directories to non-existent target: ", tgt,
+ " for directory ", d);
+ return;
+ }
+ t->AddLinkDirectory(d);
}
void CCONV cmAddExecutable(void* arg, const char* exename, int numSrcs,
@@ -330,6 +339,35 @@ void CCONV cmAddCustomCommandToTarget(void* arg, const char* target,
cctype, no_comment, no_working_dir);
}
+static void addLinkLibrary(cmMakefile* mf, std::string const& target,
+ std::string const& lib, cmTargetLinkLibraryType llt)
+{
+ cmTarget* t = mf->FindLocalNonAliasTarget(target);
+ if (!t) {
+ std::ostringstream e;
+ e << "Attempt to add link library \"" << lib << "\" to target \"" << target
+ << "\" which is not built in this directory.";
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return;
+ }
+
+ cmTarget* tgt = mf->GetGlobalGenerator()->FindTarget(lib);
+ if (tgt && (tgt->GetType() != cmStateEnums::STATIC_LIBRARY) &&
+ (tgt->GetType() != cmStateEnums::SHARED_LIBRARY) &&
+ (tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
+ !tgt->IsExecutableWithExports()) {
+ std::ostringstream e;
+ e << "Target \"" << lib << "\" of type "
+ << cmState::GetTargetTypeName(tgt->GetType())
+ << " may not be linked into another target. "
+ << "One may link only to STATIC or SHARED libraries, or "
+ << "to executables with the ENABLE_EXPORTS property set.";
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ }
+
+ t->AddLinkLibrary(*mf, lib, llt);
+}
+
void CCONV cmAddLinkLibraryForTarget(void* arg, const char* tgt,
const char* value, int libtype)
{
@@ -337,13 +375,13 @@ void CCONV cmAddLinkLibraryForTarget(void* arg, const char* tgt,
switch (libtype) {
case CM_LIBRARY_GENERAL:
- mf->AddLinkLibraryForTarget(tgt, value, GENERAL_LibraryType);
+ addLinkLibrary(mf, tgt, value, GENERAL_LibraryType);
break;
case CM_LIBRARY_DEBUG:
- mf->AddLinkLibraryForTarget(tgt, value, DEBUG_LibraryType);
+ addLinkLibrary(mf, tgt, value, DEBUG_LibraryType);
break;
case CM_LIBRARY_OPTIMIZED:
- mf->AddLinkLibraryForTarget(tgt, value, OPTIMIZED_LibraryType);
+ addLinkLibrary(mf, tgt, value, OPTIMIZED_LibraryType);
break;
}
}
@@ -357,8 +395,8 @@ void CCONV cmAddLibrary(void* arg, const char* libname, int shared,
for (i = 0; i < numSrcs; ++i) {
srcs2.push_back(srcs[i]);
}
- mf->AddLibrary(libname,
- (shared ? cmState::SHARED_LIBRARY : cmState::STATIC_LIBRARY),
+ mf->AddLibrary(libname, (shared ? cmStateEnums::SHARED_LIBRARY
+ : cmStateEnums::STATIC_LIBRARY),
srcs2);
}
@@ -370,7 +408,7 @@ char CCONV* cmExpandVariablesInString(void* arg, const char* source,
std::string result = mf->ExpandVariablesInString(
barf, (escapeQuotes ? true : false), (atOnly ? true : false));
char* res = static_cast<char*>(malloc(result.size() + 1));
- if (result.size()) {
+ if (!result.empty()) {
strcpy(res, result.c_str());
}
res[result.size()] = '\0';
@@ -532,7 +570,7 @@ void* CCONV cmAddSource(void* arg, void* arg2)
rsf->GetProperties() = osf->Properties;
for (std::vector<std::string>::iterator i = osf->Depends.begin();
i != osf->Depends.end(); ++i) {
- rsf->AddDepend(i->c_str());
+ rsf->AddDepend(*i);
}
// Create the proxy for the real source file.
@@ -638,7 +676,7 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
std::string hname = pathname;
if (cmSystemTools::FileExists(hname.c_str())) {
sf->SourceName = cmSystemTools::GetFilenamePath(name);
- if (sf->SourceName.size() > 0) {
+ if (!sf->SourceName.empty()) {
sf->SourceName += "/";
}
sf->SourceName += cmSystemTools::GetFilenameWithoutLastExtension(name);
@@ -718,7 +756,7 @@ void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir,
fname += ".";
fname += ext;
}
- sf->FullPath = cmSystemTools::CollapseFullPath(fname.c_str(), dir);
+ sf->FullPath = cmSystemTools::CollapseFullPath(fname, dir);
cmSystemTools::ConvertToUnixSlashes(sf->FullPath);
sf->SourceExtension = ext;
}