diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index e07150af3d9a8bcb5afd2ee4868d43f4dd27ca04..9967d00e55c3cc88b1c6757ec3d195c20d6a01f1 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -16,8 +16,11 @@ Properties of Global Scope
    :maxdepth: 1
 
    /prop_gbl/ALLOW_DUPLICATE_CUSTOM_TARGETS
+   /prop_gbl/AUTOGEN_SOURCE_GROUP
    /prop_gbl/AUTOGEN_TARGETS_FOLDER
+   /prop_gbl/AUTOMOC_SOURCE_GROUP
    /prop_gbl/AUTOMOC_TARGETS_FOLDER
+   /prop_gbl/AUTORCC_SOURCE_GROUP
    /prop_gbl/CMAKE_C_KNOWN_FEATURES
    /prop_gbl/CMAKE_CXX_KNOWN_FEATURES
    /prop_gbl/DEBUG_CONFIGURATIONS
diff --git a/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst b/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst
new file mode 100644
index 0000000000000000000000000000000000000000..d294eb170ecf50ab97d647186dd191cf9e8d3096
--- /dev/null
+++ b/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst
@@ -0,0 +1,15 @@
+AUTOGEN_SOURCE_GROUP
+--------------------
+
+Name of the  :command:`source_group` for :prop_tgt:`AUTOMOC` and
+:prop_tgt:`AUTORCC` generated files.
+
+Files generated by :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` are not always
+known at configure time and therefore can't be passed to
+:command:`source_group`.
+:prop_gbl:`AUTOGEN_SOURCE_GROUP` an be used instead to generate or select
+a source group for :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` generated files.
+
+For :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` specific overrides see
+:prop_gbl:`AUTOMOC_SOURCE_GROUP` and :prop_gbl:`AUTORCC_SOURCE_GROUP`
+respectively.
diff --git a/Help/prop_gbl/AUTOGEN_TARGETS_FOLDER.rst b/Help/prop_gbl/AUTOGEN_TARGETS_FOLDER.rst
index fae56264880a9dd1ff9dc25107fcb7cf5c1e75cd..0b747b207405783ec7527a6ae164a334e90635bd 100644
--- a/Help/prop_gbl/AUTOGEN_TARGETS_FOLDER.rst
+++ b/Help/prop_gbl/AUTOGEN_TARGETS_FOLDER.rst
@@ -1,8 +1,8 @@
 AUTOGEN_TARGETS_FOLDER
 ----------------------
 
-Name of :prop_tgt:`FOLDER` for ``*_autogen`` targets that are added automatically by
-CMake for targets for which :prop_tgt:`AUTOMOC` is enabled.
+Name of :prop_tgt:`FOLDER` for ``*_autogen`` targets that are added
+automatically by CMake for targets for which :prop_tgt:`AUTOMOC` is enabled.
 
 If not set, CMake uses the :prop_tgt:`FOLDER` property of the parent target as a
 default value for this property.  See also the documentation for the
diff --git a/Help/prop_gbl/AUTOMOC_SOURCE_GROUP.rst b/Help/prop_gbl/AUTOMOC_SOURCE_GROUP.rst
new file mode 100644
index 0000000000000000000000000000000000000000..2455dc76311ffd8dcb592406d53b605024a79598
--- /dev/null
+++ b/Help/prop_gbl/AUTOMOC_SOURCE_GROUP.rst
@@ -0,0 +1,7 @@
+AUTOMOC_SOURCE_GROUP
+--------------------
+
+Name of the  :command:`source_group` for :prop_tgt:`AUTOMOC` generated files.
+
+When set this is used instead of :prop_gbl:`AUTOGEN_SOURCE_GROUP` for
+files generated by :prop_tgt:`AUTOMOC`.
diff --git a/Help/prop_gbl/AUTORCC_SOURCE_GROUP.rst b/Help/prop_gbl/AUTORCC_SOURCE_GROUP.rst
new file mode 100644
index 0000000000000000000000000000000000000000..65ea95b17f697c8c61c587f448f6faa455f3d841
--- /dev/null
+++ b/Help/prop_gbl/AUTORCC_SOURCE_GROUP.rst
@@ -0,0 +1,7 @@
+AUTORCC_SOURCE_GROUP
+--------------------
+
+Name of the  :command:`source_group` for :prop_tgt:`AUTORCC` generated files.
+
+When set this is used instead of :prop_gbl:`AUTOGEN_SOURCE_GROUP` for
+files generated by :prop_tgt:`AUTORCC`.
diff --git a/Help/prop_tgt/AUTOMOC.rst b/Help/prop_tgt/AUTOMOC.rst
index b729c0b1c0a53d8db452bda46e6da7182101a960..7e10fde3953233397e84f079fa9748a62b6417b2 100644
--- a/Help/prop_tgt/AUTOMOC.rst
+++ b/Help/prop_tgt/AUTOMOC.rst
@@ -57,6 +57,9 @@ See the documentation for this variable for more details.
 The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the
 automoc targets together in an IDE, e.g.  in MSVS.
 
+The global property :prop_gbl:`AUTOGEN_SOURCE_GROUP` can be used to group
+files generated by :prop_tgt:`AUTOMOC` together in an IDE, e.g.  in MSVS.
+
 Additional ``moc`` dependency file names can be extracted from source code
 by using :prop_tgt:`AUTOMOC_DEPEND_FILTERS`.
 
diff --git a/Help/prop_tgt/AUTORCC.rst b/Help/prop_tgt/AUTORCC.rst
index 1ad089576c142c0adf89f4557a52814ca767fb54..c0f6a26b2b9e9ac5ed440e40d446c23e97c022a7 100644
--- a/Help/prop_tgt/AUTORCC.rst
+++ b/Help/prop_tgt/AUTORCC.rst
@@ -19,6 +19,9 @@ Additional command line options for rcc can be set via the
 The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group
 the autorcc targets together in an IDE, e.g. in MSVS.
 
+The global property :prop_gbl:`AUTOGEN_SOURCE_GROUP` can be used to group
+files generated by :prop_tgt:`AUTORCC` together in an IDE, e.g.  in MSVS.
+
 When there are multiple ``.qrc`` files with the same name, CMake will
 generate unspecified unique names for ``rcc``.  Therefore if
 ``Q_INIT_RESOURCE()`` or ``Q_CLEANUP_RESOURCE()`` need to be used the
diff --git a/Help/release/dev/Autogen_source_group.rst b/Help/release/dev/Autogen_source_group.rst
new file mode 100644
index 0000000000000000000000000000000000000000..60faa8cde0923dff1268c337e3058d78cee39bc3
--- /dev/null
+++ b/Help/release/dev/Autogen_source_group.rst
@@ -0,0 +1,8 @@
+AutoGen source group
+--------------------
+
+* Global properties :prop_gbl:`AUTOGEN_SOURCE_GROUP`,
+  :prop_gbl:`AUTOMOC_SOURCE_GROUP` and
+  :prop_gbl:`AUTORCC_SOURCE_GROUP` were
+  introduced to allow files generated by :prop_tgt:`AUTOMOC` or
+  :prop_tgt:`AUTORCC` to be placed in a :command:`source_group`.
diff --git a/Source/cmQtAutoGeneratorCommon.h b/Source/cmQtAutoGeneratorCommon.h
index ee97b71336d4e81caf04f81855cb2d697346963d..b54b6fa33fde33a3ea199fa563b642b8945ead19 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 94cc981d32deab8675cf033f117646b37ad50015..6ebc2344387dfad1f09a91137281cde60da49455 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")) {