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 /Source/cmAddLibraryCommand.cxx | |
parent | 126c6ead7707ac29f3b2fa779752025c7cc0da32 (diff) | |
download | CMake-83b730cd1aeeafc05473d163e13fb5489817c149.zip CMake-83b730cd1aeeafc05473d163e13fb5489817c149.tar.gz CMake-83b730cd1aeeafc05473d163e13fb5489817c149.tar.bz2 |
Add AUTOMOC to the add_library() command
Alex
Diffstat (limited to 'Source/cmAddLibraryCommand.cxx')
-rw-r--r-- | Source/cmAddLibraryCommand.cxx | 50 |
1 files changed, 39 insertions, 11 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; } |