diff options
author | Alex Neundorf <neundorf@kde.org> | 2011-08-10 17:51:07 (GMT) |
---|---|---|
committer | Alex Neundorf <neundorf@kde.org> | 2011-08-14 13:58:08 (GMT) |
commit | 83b730cd1aeeafc05473d163e13fb5489817c149 (patch) | |
tree | 9fbbc97050565198c21e6b58d54aba71da9ba656 | |
parent | 126c6ead7707ac29f3b2fa779752025c7cc0da32 (diff) | |
download | CMake-83b730cd1aeeafc05473d163e13fb5489817c149.zip CMake-83b730cd1aeeafc05473d163e13fb5489817c149.tar.gz CMake-83b730cd1aeeafc05473d163e13fb5489817c149.tar.bz2 |
Add AUTOMOC to the add_library() command
Alex
-rw-r--r-- | Source/cmAddLibraryCommand.cxx | 50 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 3 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 |
3 files changed, 42 insertions, 13 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index f522cee..2e0604e 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -12,6 +12,7 @@ #include "cmAddLibraryCommand.h" #include "cmake.h" +#include "cmQtAutomoc.h" // cmLibraryCommand bool cmAddLibraryCommand @@ -31,13 +32,14 @@ bool cmAddLibraryCommand } bool excludeFromAll = false; bool importTarget = false; - + bool doAutomoc = false; + std::vector<std::string>::const_iterator s = args.begin(); std::string libName = *s; ++s; - + // If the second argument is "SHARED" or "STATIC", then it controls // the type of library. Otherwise, it is treated as a source or // source list name. There may be two keyword arguments, check for them @@ -79,6 +81,11 @@ bool cmAddLibraryCommand ++s; importTarget = true; } + else if (*s == "AUTOMOC") + { + ++s; + doAutomoc = true; + } else { break; @@ -103,16 +110,23 @@ bool cmAddLibraryCommand type = cmTarget::STATIC_LIBRARY; } - // The IMPORTED signature requires a type to be specified explicitly. - if(importTarget && !haveSpecifiedType) - { - this->SetError("called with IMPORTED argument but no library type."); - return false; - } - // Handle imported target creation. if(importTarget) { + // The IMPORTED signature requires a type to be specified explicitly. + if (!haveSpecifiedType) + { + this->SetError("called with IMPORTED argument but no library type."); + return false; + } + + // Don't run automoc on an imported library + if (doAutomoc) + { + this->SetError("cannot be called with AUTOMOC for an IMPORTED library."); + return false; + } + // Make sure the target does not already exist. if(this->Makefile->FindTargetToUse(libName.c_str())) { @@ -164,8 +178,22 @@ bool cmAddLibraryCommand ++s; } - this->Makefile->AddLibrary(libName.c_str(), type, srclists, - excludeFromAll); + cmQtAutomoc* automoc = 0; + if ( doAutomoc ) + { + automoc = new cmQtAutomoc; + automoc->SetupAutomocTarget(this->Makefile, libName.c_str(), srclists); + } + + cmTarget* tgt =this->Makefile->AddLibrary(libName.c_str(), type, srclists, + excludeFromAll); + + if ( automoc ) + { + automoc->AddTargetDependency(this->Makefile, tgt); + delete automoc; + automoc = 0; + } return true; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a5cdee4..45165e5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1886,7 +1886,7 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target) } -void cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, +cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, const std::vector<std::string> &srcs, bool excludeFromAll) { @@ -1909,6 +1909,7 @@ void cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, } target->AddSources(srcs); this->AddGlobalLinkInformation(lname, *target); + return target; } cmTarget* cmMakefile::AddExecutable(const char *exeName, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index c01bb5d..618f4f3 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -325,7 +325,7 @@ public: /** * Set the name of the library. */ - void AddLibrary(const char *libname, cmTarget::TargetType type, + cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type, const std::vector<std::string> &srcs, bool excludeFromAll = false); |