summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-03-20 15:47:04 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-03-20 15:47:07 (GMT)
commite145cfe2e9d4afac060754097dee0b9439d470d7 (patch)
treed7dd9f8a5c1a01ec1520f71197aafd310453de3c /Source
parente22dbdb7df8b50b2e274e0bf3519edb81f99f2d1 (diff)
parentf89678f60948241355959fedc2d6239db1bedcd6 (diff)
downloadCMake-e145cfe2e9d4afac060754097dee0b9439d470d7.zip
CMake-e145cfe2e9d4afac060754097dee0b9439d470d7.tar.gz
CMake-e145cfe2e9d4afac060754097dee0b9439d470d7.tar.bz2
Merge topic 'autogen_source_group'
f89678f6 Autogen: Add AUTOGEN_SOURCE_GROUP release notes 850eb734 Autogen: Add AUTOGEN_SOURCE_GROUP documentation af1354d6 Autogen: Add AUTOGEN_SOURCE_GROUP support 379cf11b Autogen: Add generator type enum Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !586
Diffstat (limited to 'Source')
-rw-r--r--Source/cmQtAutoGeneratorCommon.h7
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx73
2 files changed, 74 insertions, 6 deletions
diff --git a/Source/cmQtAutoGeneratorCommon.h b/Source/cmQtAutoGeneratorCommon.h
index ee97b71..b54b6fa 100644
--- a/Source/cmQtAutoGeneratorCommon.h
+++ b/Source/cmQtAutoGeneratorCommon.h
@@ -16,6 +16,13 @@ class cmQtAutoGeneratorCommon
public:
static const char* listSep;
+ enum GeneratorType
+ {
+ MOC,
+ UIC,
+ RCC
+ };
+
public:
/// @brief Returns a the string escaped and enclosed in quotes
///
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")) {