automoc: Use a pre-build event in VS >= 7
In VS IDE generators add a pre-build event to perform automoc instead of using a separate custom target. This reduces the number of targets in the .sln that need to be loaded by the IDE. This also works around a VS 11 bug as discussed in issue 13900. Suggested-by: Hauke Heibel <hauke.heibel@gmail.com>
This commit is contained in:
parent
969a7fde7a
commit
20c99b1dbc
|
@ -17,6 +17,10 @@
|
||||||
#include "cmSourceFile.h"
|
#include "cmSourceFile.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
# include "cmLocalVisualStudioGenerator.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cmsys/Terminal.h>
|
#include <cmsys/Terminal.h>
|
||||||
#include <cmsys/ios/sstream>
|
#include <cmsys/ios/sstream>
|
||||||
|
|
||||||
|
@ -182,6 +186,35 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
|
||||||
std::string automocComment = "Automoc for target ";
|
std::string automocComment = "Automoc for target ";
|
||||||
automocComment += targetName;
|
automocComment += targetName;
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
bool usePRE_BUILD = false;
|
||||||
|
cmGlobalGenerator* gg = localGen->GetGlobalGenerator();
|
||||||
|
if(strstr(gg->GetName(), "Visual Studio"))
|
||||||
|
{
|
||||||
|
cmLocalVisualStudioGenerator* vslg =
|
||||||
|
static_cast<cmLocalVisualStudioGenerator*>(localGen);
|
||||||
|
// Under VS >= 7 use a PRE_BUILD event instead of a separate target to
|
||||||
|
// reduce the number of targets loaded into the IDE.
|
||||||
|
// This also works around a VS 11 bug that may skip updating the target:
|
||||||
|
// https://connect.microsoft.com/VisualStudio/feedback/details/769495
|
||||||
|
usePRE_BUILD = vslg->GetVersion() >= cmLocalVisualStudioGenerator::VS7;
|
||||||
|
}
|
||||||
|
if(usePRE_BUILD)
|
||||||
|
{
|
||||||
|
// Add the pre-build command directly to bypass the OBJECT_LIBRARY
|
||||||
|
// rejection in cmMakefile::AddCustomCommandToTarget because we know
|
||||||
|
// PRE_BUILD will work for an OBJECT_LIBRARY in this specific case.
|
||||||
|
std::vector<std::string> no_output;
|
||||||
|
cmCustomCommand cc(makefile, no_output, depends,
|
||||||
|
commandLines, automocComment.c_str(),
|
||||||
|
workingDirectory.c_str());
|
||||||
|
cc.SetEscapeOldStyle(false);
|
||||||
|
cc.SetEscapeAllowMakeVars(true);
|
||||||
|
target->GetPreBuildCommands().push_back(cc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
cmTarget* automocTarget = makefile->AddUtilityCommand(
|
cmTarget* automocTarget = makefile->AddUtilityCommand(
|
||||||
automocTargetName.c_str(), true,
|
automocTargetName.c_str(), true,
|
||||||
workingDirectory.c_str(), depends,
|
workingDirectory.c_str(), depends,
|
||||||
|
@ -190,6 +223,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
|
||||||
copyTargetProperty(automocTarget, target, "FOLDER");
|
copyTargetProperty(automocTarget, target, "FOLDER");
|
||||||
|
|
||||||
target->AddUtility(automocTargetName.c_str());
|
target->AddUtility(automocTargetName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// configure a file to get all information to automoc at buildtime:
|
// configure a file to get all information to automoc at buildtime:
|
||||||
std::string _moc_files;
|
std::string _moc_files;
|
||||||
|
|
Loading…
Reference in New Issue