cmGlobalNinjaGenerator: Clarify order of codegen build statement logic

Make it more consistent with the equivalent logic for "all".
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 9542237..ee02237 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1641,11 +1641,13 @@
         this->ConvertToNinjaPath(cmStrCat(currentBinaryDir, "/codegen"));
       for (auto const& config : configs) {
         build.ExplicitDeps.clear();
+        build.Outputs.front() =
+          this->BuildAlias(buildDirCodegenTarget, config);
+
         for (DirectoryTarget::Target const& t : dt.Targets) {
           if (this->IsExcludedFromAllInConfig(t, config)) {
             continue;
           }
-
           std::vector<cmSourceFile const*> customCommandSources;
           t.GT->GetCustomCommands(customCommandSources, config);
           for (cmSourceFile const* sf : customCommandSources) {
@@ -1660,8 +1662,6 @@
           }
         }
 
-        build.Outputs.front() =
-          this->BuildAlias(buildDirCodegenTarget, config);
         // Write target
         this->WriteBuild(this->EnableCrossConfigBuild() &&
                              this->CrossConfigs.count(config)