Browse Source

Tests: Add a PCH example to RunCMake.FileAPI codemodel-v2

Justin Goshi 5 years ago
parent
commit
b698764a31

+ 2 - 1
Tests/RunCMake/CMakeLists.txt

@@ -200,7 +200,8 @@ add_RunCMake_test(DisallowedCommands)
 add_RunCMake_test(ExternalData)
 add_RunCMake_test(FeatureSummary)
 add_RunCMake_test(FPHSA)
-add_RunCMake_test(FileAPI -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE})
+add_RunCMake_test(FileAPI -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
+                          -DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID})
 add_RunCMake_test(FindBoost)
 add_RunCMake_test(FindLua)
 add_RunCMake_test(FindOpenGL)

+ 1 - 1
Tests/RunCMake/FileAPI/RunCMakeTest.cmake

@@ -23,7 +23,7 @@ function(check_python case)
   endif()
   file(GLOB index ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply/index-*.json)
   execute_process(
-    COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/${case}-check.py" "${index}"
+    COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/${case}-check.py" "${index}" "${CMAKE_CXX_COMPILER_ID}"
     RESULT_VARIABLE result
     OUTPUT_VARIABLE output
     ERROR_VARIABLE output

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

@@ -561,6 +561,20 @@ def gen_check_targets(c, g, inSource):
         read_codemodel_json_data("targets/generated_exe.json"),
     ]
 
+    if cxx_compiler_id in ['Clang', 'AppleClang', 'GNU', 'Intel', 'MSVC', 'Embarcadero'] and g["name"] != "Xcode":
+        for e in expected:
+            if e["name"] == "cxx_exe":
+                if matches(g["name"], "^(Visual Studio |Ninja Multi-Config)"):
+                    precompile_header_data = read_codemodel_json_data("targets/cxx_exe_precompileheader_multigen.json")
+                else:
+                    if ';' in os.environ.get("CMAKE_OSX_ARCHITECTURES", ""):
+                        precompile_header_data = read_codemodel_json_data("targets/cxx_exe_precompileheader_2arch.json")
+                    else:
+                        precompile_header_data = read_codemodel_json_data("targets/cxx_exe_precompileheader.json")
+                e["compileGroups"] = precompile_header_data["compileGroups"]
+                e["sources"] = precompile_header_data["sources"]
+                e["sourceGroups"] = precompile_header_data["sourceGroups"]
+
     if not os.path.exists(os.path.join(reply_dir, "..", "..", "..", "..", "ipo_enabled.txt")):
         for e in expected:
             try:
@@ -715,6 +729,7 @@ def check_object_codemodel(g):
             check_object_codemodel_configuration(c, g, inSource)
     return _check
 
+cxx_compiler_id = sys.argv[2]
 assert is_dict(index)
 assert sorted(index.keys()) == ["cmake", "objects", "reply"]
 check_objects(index["objects"], index["cmake"]["generator"])

+ 123 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe_precompileheader.json

@@ -0,0 +1,123 @@
+{
+  "compileGroups": [
+    {
+      "language": "CXX",
+      "sourcePaths": [
+        ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$"
+      ],
+      "includes": null,
+      "defines": null,
+      "compileCommandFragments": [
+        {
+          "fragment": "TargetCompileOptions",
+          "backtrace": [
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": 17,
+              "command": "target_compile_options",
+              "hasParent": true
+            },
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": null,
+              "command": null,
+              "hasParent": false
+            }
+          ]
+        }
+      ]
+    },
+    {
+      "language": "CXX",
+      "sourcePaths": [
+        "^empty\\.cxx$"
+      ],
+      "includes": null,
+      "defines": null,
+      "compileCommandFragments": [
+        {
+          "fragment": "TargetCompileOptions",
+          "backtrace": [
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": 17,
+              "command": "target_compile_options",
+              "hasParent": true
+            },
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": null,
+              "command": null,
+              "hasParent": false
+            }
+          ]
+        }
+      ]
+    }
+  ],
+  "sources": [
+    {
+      "path": ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Source Files",
+      "compileGroupLanguage": "CXX",
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    },
+    {
+      "path": "^empty\\.cxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Source Files",
+      "compileGroupLanguage": "CXX",
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": 5,
+          "command": "add_executable",
+          "hasParent": true
+        },
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    },
+    {
+      "path": ".*/cmake_pch(_[^.]+)?\\.hxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Precompile Header File",
+      "compileGroupLanguage": null,
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    }
+  ],
+  "sourceGroups": [
+    {
+      "name": "Source Files",
+      "sourcePaths": [
+        ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$",
+        "^empty\\.cxx$"
+      ]
+    },
+    {
+      "name": "Precompile Header File",
+      "sourcePaths": [
+        ".*/cmake_pch(_[^.]+)?\\.hxx$"
+      ]
+    }
+  ]
+}

+ 180 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe_precompileheader_2arch.json

@@ -0,0 +1,180 @@
+{
+  "compileGroups": [
+    {
+      "language": "CXX",
+      "sourcePaths": [
+        ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$"
+      ],
+      "includes": null,
+      "defines": null,
+      "compileCommandFragments": [
+        {
+          "fragment": "TargetCompileOptions",
+          "backtrace": [
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": 17,
+              "command": "target_compile_options",
+              "hasParent": true
+            },
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": null,
+              "command": null,
+              "hasParent": false
+            }
+          ]
+        }
+      ]
+    },
+    {
+      "language": "CXX",
+      "sourcePaths": [
+        ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$"
+      ],
+      "includes": null,
+      "defines": null,
+      "compileCommandFragments": [
+        {
+          "fragment": "TargetCompileOptions",
+          "backtrace": [
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": 17,
+              "command": "target_compile_options",
+              "hasParent": true
+            },
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": null,
+              "command": null,
+              "hasParent": false
+            }
+          ]
+        }
+      ]
+    },
+    {
+      "language": "CXX",
+      "sourcePaths": [
+        "^empty\\.cxx$"
+      ],
+      "includes": null,
+      "defines": null,
+      "compileCommandFragments": [
+        {
+          "fragment": "TargetCompileOptions",
+          "backtrace": [
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": 17,
+              "command": "target_compile_options",
+              "hasParent": true
+            },
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": null,
+              "command": null,
+              "hasParent": false
+            }
+          ]
+        }
+      ]
+    }
+  ],
+  "sources": [
+    {
+      "path": ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Source Files",
+      "compileGroupLanguage": "CXX",
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    },
+    {
+      "path": ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Source Files",
+      "compileGroupLanguage": "CXX",
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    },
+    {
+      "path": "^empty\\.cxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Source Files",
+      "compileGroupLanguage": "CXX",
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": 5,
+          "command": "add_executable",
+          "hasParent": true
+        },
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    },
+    {
+      "path": ".*/cmake_pch(_[^.]+)?\\.hxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Precompile Header File",
+      "compileGroupLanguage": null,
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    },
+    {
+      "path": ".*/cmake_pch(_[^.]+)?\\.hxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Precompile Header File",
+      "compileGroupLanguage": null,
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    }
+  ],
+  "sourceGroups": [
+    {
+      "name": "Source Files",
+      "sourcePaths": [
+        ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$",
+        ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$",
+        "^empty\\.cxx$"
+      ]
+    },
+    {
+      "name": "Precompile Header File",
+      "sourcePaths": [
+        ".*/cmake_pch(_[^.]+)?\\.hxx$",
+        ".*/cmake_pch(_[^.]+)?\\.hxx$"
+      ]
+    }
+  ]
+}

+ 168 - 0
Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe_precompileheader_multigen.json

@@ -0,0 +1,168 @@
+{
+  "compileGroups": [
+    {
+      "language": "CXX",
+      "sourcePaths": [
+        ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$"
+      ],
+      "includes": null,
+      "defines": null,
+      "compileCommandFragments": [
+        {
+          "fragment": "TargetCompileOptions",
+          "backtrace": [
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": 17,
+              "command": "target_compile_options",
+              "hasParent": true
+            },
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": null,
+              "command": null,
+              "hasParent": false
+            }
+          ]
+        }
+      ]
+    },
+    {
+      "language": "CXX",
+      "sourcePaths": [
+        "^empty\\.cxx$"
+      ],
+      "includes": null,
+      "defines": null,
+      "compileCommandFragments": [
+        {
+          "fragment": "TargetCompileOptions",
+          "backtrace": [
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": 17,
+              "command": "target_compile_options",
+              "hasParent": true
+            },
+            {
+              "file": "^cxx/CMakeLists\\.txt$",
+              "line": null,
+              "command": null,
+              "hasParent": false
+            }
+          ]
+        }
+      ]
+    }
+  ],
+  "sources": [
+    {
+      "path": ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Source Files",
+      "compileGroupLanguage": "CXX",
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    },
+    {
+      "path": "^empty\\.cxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Source Files",
+      "compileGroupLanguage": "CXX",
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": 5,
+          "command": "add_executable",
+          "hasParent": true
+        },
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    },
+    {
+      "path": ".*/Debug/cmake_pch(_[^.]+)?\\.hxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Precompile Header File",
+      "compileGroupLanguage": null,
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    },
+    {
+      "path": ".*/Release/cmake_pch(_[^.]+)?\\.hxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Precompile Header File",
+      "compileGroupLanguage": null,
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    },
+    {
+      "path": ".*/MinSizeRel/cmake_pch(_[^.]+)?\\.hxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Precompile Header File",
+      "compileGroupLanguage": null,
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    },
+    {
+      "path": ".*/RelWithDebInfo/cmake_pch(_[^.]+)?\\.hxx$",
+      "isGenerated": null,
+      "sourceGroupName": "Precompile Header File",
+      "compileGroupLanguage": null,
+      "backtrace": [
+        {
+          "file": "^cxx/CMakeLists\\.txt$",
+          "line": null,
+          "command": null,
+          "hasParent": false
+        }
+      ]
+    }
+  ],
+  "sourceGroups": [
+    {
+      "name": "Source Files",
+      "sourcePaths": [
+        ".*cmake_pch(_[^.]+)?(\\.hxx)?\\.cxx$",
+        "^empty\\.cxx$"
+      ]
+    },
+    {
+      "name": "Precompile Header File",
+      "sourcePaths": [
+        ".*/Debug/cmake_pch(_[^.]+)?\\.hxx$",
+        ".*/Release/cmake_pch(_[^.]+)?\\.hxx$",
+        ".*/MinSizeRel/cmake_pch(_[^.]+)?\\.hxx$",
+        ".*/RelWithDebInfo/cmake_pch(_[^.]+)?\\.hxx$"
+      ]
+    }
+  ]
+}

+ 2 - 0
Tests/RunCMake/FileAPI/cxx/CMakeLists.txt

@@ -17,3 +17,5 @@ target_link_libraries(cxx_static_exe PRIVATE cxx_static_lib)
 target_compile_options(cxx_exe PUBLIC TargetCompileOptions)
 target_link_options(cxx_exe PUBLIC TargetLinkOptions)
 target_link_directories(cxx_exe PUBLIC "${CMAKE_BINARY_DIR}/TargetLinkDir")
+
+target_precompile_headers(cxx_exe PUBLIC ../empty.h)

+ 0 - 0
Tests/RunCMake/FileAPI/empty.h