Просмотр исходного кода

fileAPI: Add test coverage for interface direct and genex contexts

Craig Scott 4 недель назад
Родитель
Сommit
004d825f3e
21 измененных файлов с 1040 добавлено и 24 удалено
  1. 15 2
      Tests/RunCMake/FileAPI/codemodel-v2-check.py
  2. 23 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/directories/direct.json
  3. 15 14
      Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json
  4. 2 1
      Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json
  5. 21 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/projects/direct.json
  6. 106 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_direct.json
  7. 24 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json
  8. 3 3
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json
  9. 102 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/compile_usage_exe.json
  10. 1 1
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json
  11. 3 3
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json
  12. 39 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/inject_direct_lib.json
  13. 94 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/inject_direct_lib_impl.json
  14. 163 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_transitive_direct_exe.json
  15. 119 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_usage_exe.json
  16. 96 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/transitive_direct_lib.json
  17. 96 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/usage_lib.json
  18. 77 0
      Tests/RunCMake/FileAPI/codemodel-v2-data/targets/zero_check_direct.json
  19. 1 0
      Tests/RunCMake/FileAPI/codemodel-v2.cmake
  20. 40 0
      Tests/RunCMake/FileAPI/direct/CMakeLists.txt
  21. 0 0
      Tests/RunCMake/FileAPI/direct/other.c

+ 15 - 2
Tests/RunCMake/FileAPI/codemodel-v2-check.py

@@ -798,6 +798,7 @@ def gen_check_directories(c, g):
         read_codemodel_json_data("directories/fileset.json"),
         read_codemodel_json_data("directories/subdir.json"),
         read_codemodel_json_data("directories/framework.json"),
+        read_codemodel_json_data("directories/direct.json"),
     ]
 
     if matches(g["name"], "^Visual Studio "):
@@ -905,12 +906,21 @@ def gen_check_build_system_targets(c, g, inSource):
         read_codemodel_json_data("targets/zero_check_interface.json"),
         read_codemodel_json_data("targets/iface_srcs.json"),
 
+        read_codemodel_json_data("targets/all_build_direct.json"),
+        read_codemodel_json_data("targets/zero_check_direct.json"),
+        read_codemodel_json_data("targets/link_transitive_direct_exe.json"),
+        read_codemodel_json_data("targets/transitive_direct_lib.json"),
+        read_codemodel_json_data("targets/inject_direct_lib_impl.json"),
+        read_codemodel_json_data("targets/usage_lib.json"),
+        read_codemodel_json_data("targets/link_usage_exe.json"),
+        read_codemodel_json_data("targets/compile_usage_exe.json"),
+
         read_codemodel_json_data("targets/all_build_custom.json"),
         read_codemodel_json_data("targets/zero_check_custom.json"),
         read_codemodel_json_data("targets/custom_tgt.json"),
         read_codemodel_json_data("targets/custom_exe.json"),
         read_codemodel_json_data("targets/all_build_external.json"),
-        read_codemodel_json_data("targets/zero_check_external.json"),
+        read_codemodel_json_data("targets/zero_check_external.json"),  # Must be the last zero_check_... because matches all ZERO_CHECK::@XXX target ids
         read_codemodel_json_data("targets/generated_exe.json"),
 
         read_codemodel_json_data("targets/c_headers_1.json"),
@@ -1077,7 +1087,9 @@ def gen_check_abstract_targets(c, g, inSource):
         read_codemodel_json_data("targets/imported_static_lib.json"),
 
         read_codemodel_json_data("targets/iface_none.json"),
-        read_codemodel_json_data("targets/iface_symbolic.json")
+        read_codemodel_json_data("targets/iface_symbolic.json"),
+
+        read_codemodel_json_data("targets/inject_direct_lib.json"),
     ]
 
     if sys.platform == "darwin":
@@ -1124,6 +1136,7 @@ def gen_check_projects(c, g):
         read_codemodel_json_data("projects/custom.json"),
         read_codemodel_json_data("projects/external.json"),
         read_codemodel_json_data("projects/framework.json"),
+        read_codemodel_json_data("projects/direct.json"),
     ]
 
     if matches(g["name"], "^Visual Studio "):

+ 23 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/directories/direct.json

@@ -0,0 +1,23 @@
+{
+    "source": "^direct$",
+    "build": "^direct$",
+    "parentSource": "^\\.$",
+    "childSources": null,
+    "targetIds": [
+        "^ALL_BUILD::@79b6367c9e05c77f6a80$",
+        "^ZERO_CHECK::@79b6367c9e05c77f6a80$",
+        "^link_transitive_direct_exe::@79b6367c9e05c77f6a80$",
+        "^transitive_direct_lib::@79b6367c9e05c77f6a80$",
+        "^inject_direct_lib_impl::@79b6367c9e05c77f6a80$",
+        "^usage_lib::@79b6367c9e05c77f6a80$",
+        "^link_usage_exe::@79b6367c9e05c77f6a80$",
+        "^compile_usage_exe::@79b6367c9e05c77f6a80$"
+    ],
+    "abstractTargetIds": [
+        "^inject_direct_lib::@79b6367c9e05c77f6a80$"
+    ],
+    "projectName": "Direct",
+    "minimumCMakeVersion": "3.13",
+    "hasInstallRule": null,
+    "installers": []
+}

+ 15 - 14
Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json

@@ -13,7 +13,8 @@
         "^dir$",
         "^fileset$",
         "^subdir$",
-        "^framework$"
+        "^framework$",
+        "^direct$"
     ],
     "targetIds": [
         "^ALL_BUILD::@6890427a1f51a3e7e1df$",
@@ -54,7 +55,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 51,
+                    "line": 52,
                     "command": "install",
                     "hasParent": true
                 },
@@ -99,7 +100,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 54,
+                    "line": 55,
                     "command": "install",
                     "hasParent": true
                 },
@@ -147,7 +148,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 54,
+                    "line": 55,
                     "command": "install",
                     "hasParent": true
                 },
@@ -192,7 +193,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 54,
+                    "line": 55,
                     "command": "install",
                     "hasParent": true
                 },
@@ -236,7 +237,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 54,
+                    "line": 55,
                     "command": "install",
                     "hasParent": true
                 },
@@ -280,7 +281,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 59,
+                    "line": 60,
                     "command": "install",
                     "hasParent": true
                 },
@@ -327,7 +328,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 61,
+                    "line": 62,
                     "command": "install",
                     "hasParent": true
                 },
@@ -372,7 +373,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 62,
+                    "line": 63,
                     "command": "install",
                     "hasParent": true
                 },
@@ -421,7 +422,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 63,
+                    "line": 64,
                     "command": "install",
                     "hasParent": true
                 },
@@ -473,7 +474,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 64,
+                    "line": 65,
                     "command": "install",
                     "hasParent": true
                 },
@@ -522,7 +523,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 65,
+                    "line": 66,
                     "command": "install",
                     "hasParent": true
                 },
@@ -564,7 +565,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 66,
+                    "line": 67,
                     "command": "install",
                     "hasParent": true
                 },
@@ -606,7 +607,7 @@
             "backtrace": [
                 {
                     "file": "^codemodel-v2\\.cmake$",
-                    "line": 67,
+                    "line": 68,
                     "command": "install",
                     "hasParent": true
                 },

+ 2 - 1
Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json

@@ -9,7 +9,8 @@
         "Interface",
         "Object",
         "External",
-        "Framework"
+        "Framework",
+        "Direct"
     ],
     "directorySources": [
         "^\\.$",

+ 21 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/projects/direct.json

@@ -0,0 +1,21 @@
+{
+    "name": "Direct",
+    "parentName": "codemodel-v2",
+    "childNames": null,
+    "directorySources": [
+        "^direct$"
+    ],
+    "targetIds": [
+        "^ALL_BUILD::@79b6367c9e05c77f6a80$",
+        "^ZERO_CHECK::@79b6367c9e05c77f6a80$",
+        "^link_transitive_direct_exe::@79b6367c9e05c77f6a80$",
+        "^transitive_direct_lib::@79b6367c9e05c77f6a80$",
+        "^inject_direct_lib_impl::@79b6367c9e05c77f6a80$",
+        "^usage_lib::@79b6367c9e05c77f6a80$",
+        "^link_usage_exe::@79b6367c9e05c77f6a80$",
+        "^compile_usage_exe::@79b6367c9e05c77f6a80$"
+    ],
+    "abstractTargetIds": [
+        "^inject_direct_lib::@79b6367c9e05c77f6a80$"
+    ]
+}

+ 106 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_direct.json

@@ -0,0 +1,106 @@
+{
+    "name": "ALL_BUILD",
+    "id": "^ALL_BUILD::@79b6367c9e05c77f6a80$",
+    "directorySource": "^direct$",
+    "projectName": "Direct",
+    "type": "UTILITY",
+    "imported": null,
+    "local": null,
+    "abstract": null,
+    "symbolic": null,
+    "isGeneratorProvided": true,
+    "fileSets": null,
+    "sources": [
+        {
+            "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/direct/CMakeFiles/ALL_BUILD$",
+            "isGenerated": true,
+            "fileSetName": null,
+            "sourceGroupName": "",
+            "compileGroupLanguage": null,
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        },
+        {
+            "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/direct/CMakeFiles/ALL_BUILD\\.rule$",
+            "isGenerated": true,
+            "fileSetName": null,
+            "sourceGroupName": "CMake Rules",
+            "compileGroupLanguage": null,
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        }
+    ],
+    "sourceGroups": [
+        {
+            "name": "",
+            "sourcePaths": [
+                "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/direct/CMakeFiles/ALL_BUILD$"
+            ]
+        },
+        {
+            "name": "CMake Rules",
+            "sourcePaths": [
+                "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/direct/CMakeFiles/ALL_BUILD\\.rule$"
+            ]
+        }
+    ],
+    "compileGroups": null,
+    "backtrace": [
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": null,
+            "command": null,
+            "hasParent": false
+        }
+    ],
+    "folder": null,
+    "nameOnDisk": null,
+    "artifacts": null,
+    "build": "^direct$",
+    "source": "^direct$",
+    "install": null,
+    "link": null,
+    "archive": null,
+    "dependencies": [
+        {
+            "id": "^ZERO_CHECK::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        },
+        {
+            "id": "^link_transitive_direct_exe::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        },
+        {
+            "id": "^transitive_direct_lib::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        },
+        {
+            "id": "^inject_direct_lib_impl::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        },
+        {
+            "id": "^usage_lib::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        },
+        {
+            "id": "^link_usage_exe::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        },
+        {
+            "id": "^compile_usage_exe::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        }
+    ]
+}

+ 24 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json

@@ -237,6 +237,30 @@
         {
             "id": "^exe_framework::@217a96c3a62328a73ef4$",
             "backtrace": null
+        },
+        {
+            "id": "^link_transitive_direct_exe::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        },
+        {
+            "id": "^transitive_direct_lib::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        },
+        {
+            "id": "^inject_direct_lib_impl::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        },
+        {
+            "id": "^usage_lib::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        },
+        {
+            "id": "^link_usage_exe::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        },
+        {
+            "id": "^compile_usage_exe::@79b6367c9e05c77f6a80$",
+            "backtrace": null
         }
     ]
 }

+ 3 - 3
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json

@@ -130,7 +130,7 @@
                 "backtrace": [
                     {
                         "file": "^codemodel-v2\\.cmake$",
-                        "line": 54,
+                        "line": 55,
                         "command": "install",
                         "hasParent": true
                     },
@@ -160,7 +160,7 @@
                 "backtrace": [
                     {
                         "file": "^codemodel-v2\\.cmake$",
-                        "line": 54,
+                        "line": 55,
                         "command": "install",
                         "hasParent": true
                     },
@@ -190,7 +190,7 @@
                 "backtrace": [
                     {
                         "file": "^codemodel-v2\\.cmake$",
-                        "line": 59,
+                        "line": 60,
                         "command": "install",
                         "hasParent": true
                     },

+ 102 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/compile_usage_exe.json

@@ -0,0 +1,102 @@
+{
+    "name": "compile_usage_exe",
+    "id": "^compile_usage_exe::@79b6367c9e05c77f6a80$",
+    "directorySource": "^direct$",
+    "projectName": "Direct",
+    "type": "EXECUTABLE",
+    "imported": null,
+    "local": null,
+    "abstract": null,
+    "symbolic": null,
+    "isGeneratorProvided": null,
+    "fileSets": null,
+    "sources": [
+        {
+            "path": "^empty\\.c$",
+            "isGenerated": null,
+            "fileSetName": null,
+            "sourceGroupName": "Source Files",
+            "compileGroupLanguage": "C",
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": 38,
+                    "command": "add_executable",
+                    "hasParent": true
+                },
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        }
+    ],
+    "sourceGroups": [
+        {
+            "name": "Source Files",
+            "sourcePaths": [
+                "^empty\\.c$"
+            ]
+        }
+    ],
+    "compileGroups": [
+        {
+            "language": "C",
+            "sourcePaths": [
+                "^empty\\.c$"
+            ],
+            "includes": null,
+            "frameworks": null,
+            "defines": [
+                {
+                    "define": "_MBCS",
+                    "backtrace": null
+                }
+            ],
+            "compileCommandFragments": null
+        }
+    ],
+    "backtrace": [
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": 38,
+            "command": "add_executable",
+            "hasParent": true
+        },
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": null,
+            "command": null,
+            "hasParent": false
+        }
+    ],
+    "folder": null,
+    "nameOnDisk": "^compile_usage_exe(\\.exe)?$",
+    "artifacts": [
+        {
+            "path": "^direct/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?compile_usage_exe(\\.exe)?$",
+            "_dllExtra": false
+        },
+        {
+            "path": "^direct/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?compile_usage_exe\\.pdb$",
+            "_dllExtra": true
+        }
+    ],
+    "build": "^direct$",
+    "source": "^direct$",
+    "install": null,
+    "link": {
+        "language": "C",
+        "lto": null,
+        "commandFragments": null
+    },
+    "archive": null,
+    "dependencies": [
+        {
+            "id": "^ZERO_CHECK::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        }
+    ]
+}

+ 1 - 1
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json

@@ -148,7 +148,7 @@
                 "backtrace": [
                     {
                         "file": "^codemodel-v2\\.cmake$",
-                        "line": 51,
+                        "line": 52,
                         "command": "install",
                         "hasParent": true
                     },

+ 3 - 3
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json

@@ -106,7 +106,7 @@
                 "backtrace": [
                     {
                         "file": "^codemodel-v2\\.cmake$",
-                        "line": 54,
+                        "line": 55,
                         "command": "install",
                         "hasParent": true
                     },
@@ -136,7 +136,7 @@
                 "backtrace": [
                     {
                         "file": "^codemodel-v2\\.cmake$",
-                        "line": 54,
+                        "line": 55,
                         "command": "install",
                         "hasParent": true
                     },
@@ -166,7 +166,7 @@
                 "backtrace": [
                     {
                         "file": "^codemodel-v2\\.cmake$",
-                        "line": 59,
+                        "line": 60,
                         "command": "install",
                         "hasParent": true
                     },

+ 39 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/inject_direct_lib.json

@@ -0,0 +1,39 @@
+{
+    "name": "inject_direct_lib",
+    "id": "^inject_direct_lib::@79b6367c9e05c77f6a80$",
+    "directorySource": "^direct$",
+    "projectName": "Direct",
+    "type": "INTERFACE_LIBRARY",
+    "imported": null,
+    "local": null,
+    "abstract": true,
+    "symbolic": null,
+    "isGeneratorProvided": null,
+    "fileSets": null,
+    "sources": [],
+    "sourceGroups": null,
+    "compileGroups": null,
+    "backtrace": [
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": 5,
+            "command": "add_library",
+            "hasParent": true
+        },
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": null,
+            "command": null,
+            "hasParent": false
+        }
+    ],
+    "folder": null,
+    "nameOnDisk": null,
+    "artifacts": null,
+    "build": "^direct$",
+    "source": "^direct$",
+    "install": null,
+    "link": null,
+    "archive": null,
+    "dependencies": null
+}

+ 94 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/inject_direct_lib_impl.json

@@ -0,0 +1,94 @@
+{
+    "name": "inject_direct_lib_impl",
+    "id": "^inject_direct_lib_impl::@79b6367c9e05c77f6a80$",
+    "directorySource": "^direct$",
+    "projectName": "Direct",
+    "type": "OBJECT_LIBRARY",
+    "imported": null,
+    "local": null,
+    "abstract": null,
+    "symbolic": null,
+    "isGeneratorProvided": null,
+    "fileSets": null,
+    "sources": [
+        {
+            "path": "^direct/other\\.c$",
+            "isGenerated": null,
+            "fileSetName": null,
+            "sourceGroupName": "Source Files",
+            "compileGroupLanguage": "C",
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": 6,
+                    "command": "add_library",
+                    "hasParent": true
+                },
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        }
+    ],
+    "sourceGroups": [
+        {
+            "name": "Source Files",
+            "sourcePaths": [
+                "^direct/other\\.c$"
+            ]
+        }
+    ],
+    "compileGroups": [
+        {
+            "language": "C",
+            "sourcePaths": [
+                "^direct/other\\.c$"
+            ],
+            "includes": null,
+            "frameworks": null,
+            "defines": [
+                {
+                    "define": "_MBCS",
+                    "backtrace": null
+                }
+            ],
+            "compileCommandFragments": null
+        }
+    ],
+    "backtrace": [
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": 6,
+            "command": "add_library",
+            "hasParent": true
+        },
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": null,
+            "command": null,
+            "hasParent": false
+        }
+    ],
+    "folder": null,
+    "nameOnDisk": null,
+    "artifacts": [
+        {
+            "path": "^(direct|build/inject_direct_lib_impl\\.build)/.*/other(\\.c)?\\.o(bj)?$",
+            "_dllExtra": false
+        }
+    ],
+    "build": "^direct$",
+    "source": "^direct$",
+    "install": null,
+    "link": null,
+    "archive": null,
+    "dependencies": [
+        {
+            "id": "^ZERO_CHECK::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        }
+    ]
+}

+ 163 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_transitive_direct_exe.json

@@ -0,0 +1,163 @@
+{
+    "name": "link_transitive_direct_exe",
+    "id": "^link_transitive_direct_exe::@79b6367c9e05c77f6a80$",
+    "directorySource": "^direct$",
+    "projectName": "Direct",
+    "type": "EXECUTABLE",
+    "imported": null,
+    "local": null,
+    "abstract": null,
+    "symbolic": null,
+    "isGeneratorProvided": null,
+    "fileSets": null,
+    "sources": [
+        {
+            "path": "^empty\\.c$",
+            "isGenerated": null,
+            "fileSetName": null,
+            "sourceGroupName": "Source Files",
+            "compileGroupLanguage": "C",
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": 3,
+                    "command": "add_executable",
+                    "hasParent": true
+                },
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        },
+        {
+            "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/(direct|build/inject_direct_lib_impl\\.build)/.*/other(\\.c)?\\.o(bj)?$",
+            "isGenerated": true,
+            "fileSetName": null,
+            "sourceGroupName": "Object Libraries",
+            "compileGroupLanguage": null,
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": 13,
+                    "command": "set_property",
+                    "hasParent": true
+                },
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        }
+    ],
+    "sourceGroups": [
+        {
+            "name": "Source Files",
+            "sourcePaths": [
+                "^empty\\.c$"
+            ]
+        },
+        {
+            "name": "Object Libraries",
+            "sourcePaths": [
+                "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/(direct|build/inject_direct_lib_impl\\.build)/.*/other(\\.c)?\\.o(bj)?$"
+            ]
+        }
+    ],
+    "compileGroups": [
+        {
+            "language": "C",
+            "sourcePaths": [
+                "^empty\\.c$"
+            ],
+            "includes": null,
+            "frameworks": null,
+            "defines": [
+                {
+                    "define": "_MBCS",
+                    "backtrace": null
+                }
+            ],
+            "compileCommandFragments": null
+        }
+    ],
+    "backtrace": [
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": 3,
+            "command": "add_executable",
+            "hasParent": true
+        },
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": null,
+            "command": null,
+            "hasParent": false
+        }
+    ],
+    "folder": null,
+    "nameOnDisk": "^link_transitive_direct_exe(\\.exe)?$",
+    "artifacts": [
+        {
+            "path": "^direct/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_transitive_direct_exe(\\.exe)?$",
+            "_dllExtra": false
+        },
+        {
+            "path": "^direct/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_transitive_direct_exe\\.pdb$",
+            "_dllExtra": true
+        }
+    ],
+    "build": "^direct$",
+    "source": "^direct$",
+    "install": null,
+    "link": {
+        "language": "C",
+        "lto": null,
+        "commandFragments": null
+    },
+    "archive": null,
+    "dependencies": [
+        {
+            "id": "^transitive_direct_lib::@79b6367c9e05c77f6a80$",
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": 18,
+                    "command": "target_link_libraries",
+                    "hasParent": true
+                },
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        },
+        {
+            "id": "^inject_direct_lib_impl::@79b6367c9e05c77f6a80$",
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": 13,
+                    "command": "set_property",
+                    "hasParent": true
+                },
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        },
+        {
+            "id": "^ZERO_CHECK::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        }
+    ]
+}

+ 119 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/link_usage_exe.json

@@ -0,0 +1,119 @@
+{
+    "name": "link_usage_exe",
+    "id": "^link_usage_exe::@79b6367c9e05c77f6a80$",
+    "directorySource": "^direct$",
+    "projectName": "Direct",
+    "type": "EXECUTABLE",
+    "imported": null,
+    "local": null,
+    "abstract": null,
+    "symbolic": null,
+    "isGeneratorProvided": null,
+    "fileSets": null,
+    "sources": [
+        {
+            "path": "^empty\\.c$",
+            "isGenerated": null,
+            "fileSetName": null,
+            "sourceGroupName": "Source Files",
+            "compileGroupLanguage": "C",
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": 37,
+                    "command": "add_executable",
+                    "hasParent": true
+                },
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        }
+    ],
+    "sourceGroups": [
+        {
+            "name": "Source Files",
+            "sourcePaths": [
+                "^empty\\.c$"
+            ]
+        }
+    ],
+    "compileGroups": [
+        {
+            "language": "C",
+            "sourcePaths": [
+                "^empty\\.c$"
+            ],
+            "includes": null,
+            "frameworks": null,
+            "defines": [
+                {
+                    "define": "_MBCS",
+                    "backtrace": null
+                }
+            ],
+            "compileCommandFragments": null
+        }
+    ],
+    "backtrace": [
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": 37,
+            "command": "add_executable",
+            "hasParent": true
+        },
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": null,
+            "command": null,
+            "hasParent": false
+        }
+    ],
+    "folder": null,
+    "nameOnDisk": "^link_usage_exe(\\.exe)?$",
+    "artifacts": [
+        {
+            "path": "^direct/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_usage_exe(\\.exe)?$",
+            "_dllExtra": false
+        },
+        {
+            "path": "^direct/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_usage_exe\\.pdb$",
+            "_dllExtra": true
+        }
+    ],
+    "build": "^direct$",
+    "source": "^direct$",
+    "install": null,
+    "link": {
+        "language": "C",
+        "lto": null,
+        "commandFragments": null
+    },
+    "archive": null,
+    "dependencies": [
+        {
+            "id": "^usage_lib::@79b6367c9e05c77f6a80$",
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": 39,
+                    "command": "target_link_libraries",
+                    "hasParent": true
+                },
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        },
+        {
+            "id": "^ZERO_CHECK::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        }
+    ]
+}

+ 96 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/transitive_direct_lib.json

@@ -0,0 +1,96 @@
+{
+    "name": "transitive_direct_lib",
+    "id": "^transitive_direct_lib::@79b6367c9e05c77f6a80$",
+    "directorySource": "^direct$",
+    "projectName": "Direct",
+    "type": "STATIC_LIBRARY",
+    "imported": null,
+    "local": null,
+    "abstract": null,
+    "symbolic": null,
+    "isGeneratorProvided": null,
+    "fileSets": null,
+    "sources": [
+        {
+            "path": "^empty\\.c$",
+            "isGenerated": null,
+            "fileSetName": null,
+            "sourceGroupName": "Source Files",
+            "compileGroupLanguage": "C",
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": 4,
+                    "command": "add_library",
+                    "hasParent": true
+                },
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        }
+    ],
+    "sourceGroups": [
+        {
+            "name": "Source Files",
+            "sourcePaths": [
+                "^empty\\.c$"
+            ]
+        }
+    ],
+    "compileGroups": [
+        {
+            "language": "C",
+            "sourcePaths": [
+                "^empty\\.c$"
+            ],
+            "includes": null,
+            "frameworks": null,
+            "defines": [
+                {
+                    "define": "_MBCS",
+                    "backtrace": null
+                }
+            ],
+            "compileCommandFragments": null
+        }
+    ],
+    "backtrace": [
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": 4,
+            "command": "add_library",
+            "hasParent": true
+        },
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": null,
+            "command": null,
+            "hasParent": false
+        }
+    ],
+    "folder": null,
+    "nameOnDisk": "^(lib)?transitive_direct_lib\\.(a|lib|l)$",
+    "artifacts": [
+        {
+            "path": "^direct/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?transitive_direct_lib\\.(a|lib|l)$",
+            "_dllExtra": false
+        }
+    ],
+    "build": "^direct$",
+    "source": "^direct$",
+    "install": null,
+    "link": null,
+    "archive": {
+        "lto": null
+    },
+    "dependencies": [
+        {
+            "id": "^ZERO_CHECK::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        }
+    ]
+}

+ 96 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/usage_lib.json

@@ -0,0 +1,96 @@
+{
+    "name": "usage_lib",
+    "id": "^usage_lib::@79b6367c9e05c77f6a80$",
+    "directorySource": "^direct$",
+    "projectName": "Direct",
+    "type": "STATIC_LIBRARY",
+    "imported": null,
+    "local": null,
+    "abstract": null,
+    "symbolic": null,
+    "isGeneratorProvided": null,
+    "fileSets": null,
+    "sources": [
+        {
+            "path": "^empty\\.c$",
+            "isGenerated": null,
+            "fileSetName": null,
+            "sourceGroupName": "Source Files",
+            "compileGroupLanguage": "C",
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": 36,
+                    "command": "add_library",
+                    "hasParent": true
+                },
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        }
+    ],
+    "sourceGroups": [
+        {
+            "name": "Source Files",
+            "sourcePaths": [
+                "^empty\\.c$"
+            ]
+        }
+    ],
+    "compileGroups": [
+        {
+            "language": "C",
+            "sourcePaths": [
+                "^empty\\.c$"
+            ],
+            "includes": null,
+            "frameworks": null,
+            "defines": [
+                {
+                    "define": "_MBCS",
+                    "backtrace": null
+                }
+            ],
+            "compileCommandFragments": null
+        }
+    ],
+    "backtrace": [
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": 36,
+            "command": "add_library",
+            "hasParent": true
+        },
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": null,
+            "command": null,
+            "hasParent": false
+        }
+    ],
+    "folder": null,
+    "nameOnDisk": "^(lib)?usage_lib\\.(a|lib|l)$",
+    "artifacts": [
+        {
+            "path": "^direct/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?usage_lib\\.(a|lib|l)$",
+            "_dllExtra": false
+        }
+    ],
+    "build": "^direct$",
+    "source": "^direct$",
+    "install": null,
+    "link": null,
+    "archive": {
+        "lto": null
+    },
+    "dependencies": [
+        {
+            "id": "^ZERO_CHECK::@79b6367c9e05c77f6a80$",
+            "backtrace": null
+        }
+    ]
+}

+ 77 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/zero_check_direct.json

@@ -0,0 +1,77 @@
+{
+    "name": "ZERO_CHECK",
+    "id": "^ZERO_CHECK::@79b6367c9e05c77f6a80$",
+    "directorySource": "^direct$",
+    "projectName": "Direct",
+    "type": "UTILITY",
+    "imported": null,
+    "local": null,
+    "abstract": null,
+    "symbolic": null,
+    "isGeneratorProvided": true,
+    "fileSets": null,
+    "sources": [
+        {
+            "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/direct/CMakeFiles/ZERO_CHECK$",
+            "isGenerated": true,
+            "fileSetName": null,
+            "sourceGroupName": "",
+            "compileGroupLanguage": null,
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        },
+        {
+            "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/direct/CMakeFiles/ZERO_CHECK\\.rule$",
+            "isGenerated": true,
+            "fileSetName": null,
+            "sourceGroupName": "CMake Rules",
+            "compileGroupLanguage": null,
+            "backtrace": [
+                {
+                    "file": "^direct/CMakeLists\\.txt$",
+                    "line": null,
+                    "command": null,
+                    "hasParent": false
+                }
+            ]
+        }
+    ],
+    "sourceGroups": [
+        {
+            "name": "",
+            "sourcePaths": [
+                "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/direct/CMakeFiles/ZERO_CHECK$"
+            ]
+        },
+        {
+            "name": "CMake Rules",
+            "sourcePaths": [
+                "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/direct/CMakeFiles/ZERO_CHECK\\.rule$"
+            ]
+        }
+    ],
+    "compileGroups": null,
+    "backtrace": [
+        {
+            "file": "^direct/CMakeLists\\.txt$",
+            "line": null,
+            "command": null,
+            "hasParent": false
+        }
+    ],
+    "folder": null,
+    "nameOnDisk": null,
+    "artifacts": null,
+    "build": "^direct$",
+    "source": "^direct$",
+    "install": null,
+    "link": null,
+    "archive": null,
+    "dependencies": null
+}

+ 1 - 0
Tests/RunCMake/FileAPI/codemodel-v2.cmake

@@ -35,6 +35,7 @@ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../FileAPIExternalSource" "${CMAKE
 add_subdirectory(dir)
 add_subdirectory(fileset)
 add_subdirectory(framework)
+add_subdirectory(direct)
 
 set_property(TARGET c_shared_lib PROPERTY LIBRARY_OUTPUT_DIRECTORY lib)
 set_property(TARGET c_shared_lib PROPERTY RUNTIME_OUTPUT_DIRECTORY lib)

+ 40 - 0
Tests/RunCMake/FileAPI/direct/CMakeLists.txt

@@ -0,0 +1,40 @@
+project(Direct)
+
+add_executable(link_transitive_direct_exe ../empty.c)
+add_library(transitive_direct_lib STATIC ../empty.c)
+add_library(inject_direct_lib INTERFACE)
+add_library(inject_direct_lib_impl OBJECT other.c)
+
+set(head_targets
+  EXECUTABLE
+  SHARED_LIBRARY
+  MODULE_LIBRARY
+)
+set_property(TARGET inject_direct_lib PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT
+  # Skip intermediate targets, only apply to the head target
+  "$<$<IN_LIST:$<TARGET_PROPERTY:TYPE>,${head_targets}>:inject_direct_lib_impl>"
+)
+
+target_link_libraries(link_transitive_direct_exe
+  # Link interfaces are not supported for executables that do not export
+  # symbols, so even though this specifies PUBLIC here, the direct dependencies
+  # should show up as private.
+  PUBLIC
+    transitive_direct_lib
+)
+
+# This is not an executable, so the direct dependency types should follow the
+# keywords specified here.
+target_link_libraries(transitive_direct_lib
+  PUBLIC
+    inject_direct_lib
+  INTERFACE
+    -lm  # Doesn't need to exist, just verifying fragments in directDependencies
+)
+
+cmake_policy(SET CMP0131 NEW)
+add_library(usage_lib STATIC ../empty.c)
+add_executable(link_usage_exe ../empty.c)
+add_executable(compile_usage_exe ../empty.c)
+target_link_libraries(link_usage_exe PRIVATE $<LINK_ONLY:usage_lib>)
+target_link_libraries(compile_usage_exe PRIVATE $<COMPILE_ONLY:usage_lib>)

+ 0 - 0
Tests/RunCMake/FileAPI/direct/other.c