diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+## Changes in 0.38.2
+  - Infer `cabal-version: 3.12` when `PackageInfo_*` is used (see #620)
+
 ## Changes in 0.38.1
   - Add support for `extra-files` (see #603)
   - Preserve empty lines in `description` when `cabal-version >= 3` (see #612)
diff --git a/hpack.cabal b/hpack.cabal
--- a/hpack.cabal
+++ b/hpack.cabal
@@ -1,11 +1,11 @@
 cabal-version: 2.0
 
--- This file has been generated from package.yaml by hpack version 0.38.0.
+-- This file has been generated from package.yaml by hpack version 0.38.1.
 --
 -- see: https://github.com/sol/hpack
 
 name:           hpack
-version:        0.38.1
+version:        0.38.2
 synopsis:       A modern format for Haskell packages
 description:    See README at <https://github.com/sol/hpack#readme>
 category:       Development
@@ -63,7 +63,7 @@
       src
   ghc-options: -Wall -fno-warn-incomplete-uni-patterns
   build-depends:
-      Cabal >=3.0.0.0 && <3.15
+      Cabal >=3.0.0.0 && <3.17
     , Glob >=0.9.0
     , aeson >=1.4.3.0
     , base >=4.13 && <5
@@ -97,7 +97,7 @@
       driver
   ghc-options: -Wall -fno-warn-incomplete-uni-patterns
   build-depends:
-      Cabal >=3.0.0.0 && <3.15
+      Cabal >=3.0.0.0 && <3.17
     , Glob >=0.9.0
     , aeson >=1.4.3.0
     , base >=4.13 && <5
@@ -193,7 +193,7 @@
   build-tool-depends:
       hspec-discover:hspec-discover
   build-depends:
-      Cabal >=3.0.0.0 && <3.15
+      Cabal >=3.0.0.0 && <3.17
     , Glob >=0.9.0
     , HUnit >=1.6.0.0
     , QuickCheck
diff --git a/resources/test/hpack.cabal b/resources/test/hpack.cabal
--- a/resources/test/hpack.cabal
+++ b/resources/test/hpack.cabal
@@ -1,11 +1,11 @@
 cabal-version: 2.0
 
--- This file has been generated from package.yaml by hpack version 0.38.0.
+-- This file has been generated from package.yaml by hpack version 0.38.1.
 --
 -- see: https://github.com/sol/hpack
 
 name:           hpack
-version:        0.38.1
+version:        0.38.2
 synopsis:       A modern format for Haskell packages
 description:    See README at <https://github.com/sol/hpack#readme>
 category:       Development
@@ -63,7 +63,7 @@
       src
   ghc-options: -Wall -fno-warn-incomplete-uni-patterns
   build-depends:
-      Cabal >=3.0.0.0 && <3.15
+      Cabal >=3.0.0.0 && <3.17
     , Glob >=0.9.0
     , aeson >=1.4.3.0
     , base >=4.13 && <5
@@ -97,7 +97,7 @@
       driver
   ghc-options: -Wall -fno-warn-incomplete-uni-patterns
   build-depends:
-      Cabal >=3.0.0.0 && <3.15
+      Cabal >=3.0.0.0 && <3.17
     , Glob >=0.9.0
     , aeson >=1.4.3.0
     , base >=4.13 && <5
@@ -193,7 +193,7 @@
   build-tool-depends:
       hspec-discover:hspec-discover
   build-depends:
-      Cabal >=3.0.0.0 && <3.15
+      Cabal >=3.0.0.0 && <3.17
     , Glob >=0.9.0
     , HUnit >=1.6.0.0
     , QuickCheck
diff --git a/src/Hpack/Config.hs b/src/Hpack/Config.hs
--- a/src/Hpack/Config.hs
+++ b/src/Hpack/Config.hs
@@ -846,12 +846,24 @@
         makeVersion [1,22] <$ guard (has libraryReexportedModules)
       , makeVersion [2,0]  <$ guard (has librarySignatures)
       , makeVersion [2,0] <$ guard (has libraryGeneratedModules)
+      , makeVersion [3,12] <$ guard (libraryHasPackageInfoModule sect)
       , makeVersion [3,0] <$ guard (has libraryVisibility)
       , sectionCabalVersion (concatMap getLibraryModules) sect
       ]
       where
         has field = any (not . null . field) sect
 
+    libraryHasPackageInfoModule :: Section Library -> Bool
+    libraryHasPackageInfoModule =
+      any (hasPackageInfoModule . libraryGeneratedModules)
+
+    packageInfoModule :: Module
+    packageInfoModule =
+      Module ("PackageInfo_" ++ moduleNameFromPackageName packageName)
+
+    hasPackageInfoModule :: [Module] -> Bool
+    hasPackageInfoModule = any (== packageInfoModule)
+
     internalLibsCabalVersion :: Map String (Section Library) -> Maybe CabalVersion
     internalLibsCabalVersion internalLibraries
       | Map.null internalLibraries = Nothing
@@ -865,12 +877,17 @@
     executableCabalVersion :: Section Executable -> Maybe CabalVersion
     executableCabalVersion sect = maximum [
         makeVersion [2,0] <$ guard (executableHasGeneratedModules sect)
+      , makeVersion [3,12] <$ guard (executableHasPackageInfoModule sect)
       , sectionCabalVersion (concatMap getExecutableModules) sect
       ]
 
     executableHasGeneratedModules :: Section Executable -> Bool
     executableHasGeneratedModules = any (not . null . executableGeneratedModules)
 
+    executableHasPackageInfoModule :: Section Executable -> Bool
+    executableHasPackageInfoModule =
+      any (hasPackageInfoModule . executableGeneratedModules)
+
     sectionCabalVersion :: (Section a -> [Module]) -> Section a -> Maybe CabalVersion
     sectionCabalVersion getMentionedModules sect = maximum $ [
         makeVersion [2,2] <$ guard (sectionSatisfies (not . null . sectionCxxSources) sect)
@@ -1659,7 +1676,11 @@
     warnLegacySystemTool name = tell ["Listing " ++ show name ++ " under build-tools is deperecated! Please list system executables under system-build-tools instead!"]
 
 pathsModuleFromPackageName :: String -> Module
-pathsModuleFromPackageName name = Module ("Paths_" ++ map f name)
-  where
-    f '-' = '_'
-    f x = x
+pathsModuleFromPackageName name =
+  Module ("Paths_" ++ moduleNameFromPackageName name)
+
+moduleNameFromPackageName :: String -> String
+moduleNameFromPackageName = map f
+ where
+  f '-' = '_'
+  f x = x
diff --git a/test/EndToEndSpec.hs b/test/EndToEndSpec.hs
--- a/test/EndToEndSpec.hs
+++ b/test/EndToEndSpec.hs
@@ -1327,6 +1327,20 @@
           default-language: Haskell2010
           |]) {packageCabalVersion = "2.0"}
 
+      context "with PackageInfo_my_package" $ do
+        it "infers cabal-version 3.12" $ do
+          [i|
+          spec-version: 0.36.0
+          library:
+            generated-other-modules: PackageInfo_my_package
+          |] `shouldRenderTo` (library [i|
+          other-modules:
+              PackageInfo_my_package
+          autogen-modules:
+              PackageInfo_my_package
+          default-language: Haskell2010
+          |]) {packageCabalVersion = "3.12"}
+
     describe "internal-libraries" $ do
       it "accepts internal-libraries" $ do
         touch "src/Foo.hs"
@@ -1683,6 +1697,23 @@
                 Foo
             default-language: Haskell2010
           |]) {packageCabalVersion = "2.0"}
+
+        context "with PackageInfo_my_package" $ do
+          it "infers cabal-version 3.12" $ do
+            [i|
+            spec-version: 0.36.0
+            executables:
+              foo:
+                main: Main.hs
+                generated-other-modules: PackageInfo_my_package
+          |] `shouldRenderTo` (executable "foo" [i|
+            main-is: Main.hs
+            other-modules:
+                PackageInfo_my_package
+            autogen-modules:
+                PackageInfo_my_package
+            default-language: Haskell2010
+          |]) {packageCabalVersion = "3.12"}
 
         context "with a conditional" $ do
           it "doesn't infer any modules mentioned in that conditional" $ do
