diff options
Diffstat (limited to 'Source/cmCPluginAPI.cxx')
-rw-r--r-- | Source/cmCPluginAPI.cxx | 66 |
1 files changed, 52 insertions, 14 deletions
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 3a08aea..b70074e 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); } |