summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGeneratorInitializer.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-03-15 09:50:23 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-03-16 10:52:20 (GMT)
commitaf1354d6c14097f9ec9dda25460e9228fa592fbc (patch)
treea65cbb86a4e5fa6712afa71e22908facded50456 /Source/cmQtAutoGeneratorInitializer.cxx
parent379cf11b3073caeb97727b17db48766624290caa (diff)
downloadCMake-af1354d6c14097f9ec9dda25460e9228fa592fbc.zip
CMake-af1354d6c14097f9ec9dda25460e9228fa592fbc.tar.gz
CMake-af1354d6c14097f9ec9dda25460e9228fa592fbc.tar.bz2
Autogen: Add AUTOGEN_SOURCE_GROUP support
Closes: #16501
Diffstat (limited to 'Source/cmQtAutoGeneratorInitializer.cxx')
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx73
1 files changed, 67 insertions, 6 deletions
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 94cc981..6ebc234 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -134,6 +134,61 @@ static void AddDefinitionEscaped(cmMakefile* makefile, const char* key,
key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str());
}
+static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName,
+ cmQtAutoGeneratorCommon::GeneratorType genType)
+{
+ cmSourceGroup* sourceGroup = CM_NULLPTR;
+ // Acquire source group
+ {
+ const char* groupName = CM_NULLPTR;
+ // Use generator specific group name
+ switch (genType) {
+ case cmQtAutoGeneratorCommon::MOC:
+ groupName =
+ makefile->GetState()->GetGlobalProperty("AUTOMOC_SOURCE_GROUP");
+ break;
+ case cmQtAutoGeneratorCommon::RCC:
+ groupName =
+ makefile->GetState()->GetGlobalProperty("AUTORCC_SOURCE_GROUP");
+ break;
+ default:
+ break;
+ }
+ // Use default group name on demand
+ if ((groupName == CM_NULLPTR) || (*groupName == 0)) {
+ groupName =
+ makefile->GetState()->GetGlobalProperty("AUTOGEN_SOURCE_GROUP");
+ }
+ // Generate a source group on demand
+ if ((groupName != CM_NULLPTR) && (*groupName != 0)) {
+ {
+ const char* delimiter =
+ makefile->GetDefinition("SOURCE_GROUP_DELIMITER");
+ if (delimiter == CM_NULLPTR) {
+ delimiter = "\\";
+ }
+ std::vector<std::string> folders =
+ cmSystemTools::tokenize(groupName, delimiter);
+ sourceGroup = makefile->GetSourceGroup(folders);
+ if (sourceGroup == CM_NULLPTR) {
+ makefile->AddSourceGroup(folders);
+ sourceGroup = makefile->GetSourceGroup(folders);
+ }
+ }
+ if (sourceGroup == CM_NULLPTR) {
+ cmSystemTools::Error(
+ "Autogen: Could not create or find source group: ",
+ cmQtAutoGeneratorCommon::Quoted(groupName).c_str());
+ return false;
+ }
+ }
+ }
+ if (sourceGroup != CM_NULLPTR) {
+ sourceGroup->AddGroupFile(fileName);
+ }
+ return true;
+}
+
static void AcquireScanFiles(cmGeneratorTarget const* target,
std::vector<std::string>& mocUicSources,
std::vector<std::string>& mocUicHeaders,
@@ -531,11 +586,14 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenSources(
{
if (target->GetPropertyAsBool("AUTOMOC")) {
cmMakefile* makefile = target->Target->GetMakefile();
- const std::string mocCppFile =
- GetAutogenTargetBuildDir(target) + "moc_compilation.cpp";
- cmSourceFile* gf = makefile->GetOrCreateSource(mocCppFile, true);
- gf->SetProperty("SKIP_AUTOGEN", "On");
+ std::string mocCppFile = GetAutogenTargetBuildDir(target);
+ mocCppFile += "moc_compilation.cpp";
+ {
+ cmSourceFile* gFile = makefile->GetOrCreateSource(mocCppFile, true);
+ gFile->SetProperty("SKIP_AUTOGEN", "On");
+ }
target->AddSource(mocCppFile);
+ AddToSourceGroup(makefile, mocCppFile, cmQtAutoGeneratorCommon::MOC);
}
}
@@ -700,9 +758,12 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
autogenProvides.push_back(rccOut);
// Add rcc output file to origin target sources
- cmSourceFile* gf = makefile->GetOrCreateSource(rccOut, true);
- gf->SetProperty("SKIP_AUTOGEN", "On");
+ {
+ cmSourceFile* gFile = makefile->GetOrCreateSource(rccOut, true);
+ gFile->SetProperty("SKIP_AUTOGEN", "On");
+ }
target->AddSource(rccOut);
+ AddToSourceGroup(makefile, rccOut, cmQtAutoGeneratorCommon::RCC);
}
if (PropertyEnabled(sf, "GENERATED")) {