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

VS: Add compiler flag table entry for -FI followed by separate argument

The MSVC `/FI` flag accepts an attached value or a following argument.
Previously our flag tables only had entries for the former.  Add
the latter.

Fixes: #23382
Brad King 3 лет назад
Родитель
Сommit
20cd951c9f

+ 11 - 0
Templates/MSBuild/FlagTables/v10_CL.json

@@ -860,6 +860,17 @@
     "value": "",
     "flags": [
       "UserValue",
+      "UserRequired",
+      "SemicolonAppendable"
+    ]
+  },
+  {
+    "name": "ForcedIncludeFiles",
+    "switch": "FI",
+    "comment": "Forced Include File",
+    "value": "",
+    "flags": [
+      "UserFollowing",
       "SemicolonAppendable"
     ]
   },

+ 11 - 0
Templates/MSBuild/FlagTables/v11_CL.json

@@ -923,6 +923,17 @@
     "value": "",
     "flags": [
       "UserValue",
+      "UserRequired",
+      "SemicolonAppendable"
+    ]
+  },
+  {
+    "name": "ForcedIncludeFiles",
+    "switch": "FI",
+    "comment": "Forced Include File",
+    "value": "",
+    "flags": [
+      "UserFollowing",
       "SemicolonAppendable"
     ]
   },

+ 11 - 0
Templates/MSBuild/FlagTables/v12_CL.json

@@ -937,6 +937,17 @@
     "value": "",
     "flags": [
       "UserValue",
+      "UserRequired",
+      "SemicolonAppendable"
+    ]
+  },
+  {
+    "name": "ForcedIncludeFiles",
+    "switch": "FI",
+    "comment": "Forced Include File",
+    "value": "",
+    "flags": [
+      "UserFollowing",
       "SemicolonAppendable"
     ]
   },

+ 11 - 0
Templates/MSBuild/FlagTables/v140_CL.json

@@ -972,6 +972,17 @@
     "value": "",
     "flags": [
       "UserValue",
+      "UserRequired",
+      "SemicolonAppendable"
+    ]
+  },
+  {
+    "name": "ForcedIncludeFiles",
+    "switch": "FI",
+    "comment": "Forced Include File",
+    "value": "",
+    "flags": [
+      "UserFollowing",
       "SemicolonAppendable"
     ]
   },

+ 11 - 0
Templates/MSBuild/FlagTables/v141_CL.json

@@ -1077,6 +1077,17 @@
     "value": "",
     "flags": [
       "UserValue",
+      "UserRequired",
+      "SemicolonAppendable"
+    ]
+  },
+  {
+    "name": "ForcedIncludeFiles",
+    "switch": "FI",
+    "comment": "Forced Include File",
+    "value": "",
+    "flags": [
+      "UserFollowing",
       "SemicolonAppendable"
     ]
   },

+ 11 - 0
Templates/MSBuild/FlagTables/v142_CL.json

@@ -1286,6 +1286,17 @@
     "value": "",
     "flags": [
       "UserValue",
+      "UserRequired",
+      "SemicolonAppendable"
+    ]
+  },
+  {
+    "name": "ForcedIncludeFiles",
+    "switch": "FI",
+    "comment": "Forced Include File",
+    "value": "",
+    "flags": [
+      "UserFollowing",
       "SemicolonAppendable"
     ]
   },

+ 11 - 0
Templates/MSBuild/FlagTables/v143_CL.json

@@ -1285,6 +1285,17 @@
     "value": "",
     "flags": [
       "UserValue",
+      "UserRequired",
+      "SemicolonAppendable"
+    ]
+  },
+  {
+    "name": "ForcedIncludeFiles",
+    "switch": "FI",
+    "comment": "Forced Include File",
+    "value": "",
+    "flags": [
+      "UserFollowing",
       "SemicolonAppendable"
     ]
   },

+ 1 - 0
Tests/RunCMake/VS10Project/RunCMakeTest.cmake

@@ -35,6 +35,7 @@ run_cmake(VsProjectImport)
 run_cmake(VsPackageReferences)
 run_cmake(VsDpiAware)
 run_cmake(VsDpiAwareBadParam)
+run_cmake(VsForceInclude)
 run_cmake(VsPrecompileHeaders)
 run_cmake(VsPrecompileHeadersReuseFromCompilePDBName)
 run_cmake(VsDeployEnabled)

+ 18 - 0
Tests/RunCMake/VS10Project/VsForceInclude-check.cmake

@@ -0,0 +1,18 @@
+set(tgt_project "${RunCMake_TEST_BINARY_DIR}/tgt.vcxproj")
+if (NOT EXISTS "${tgt_project}")
+  set(RunCMake_TEST_FAILED "Generated project file does not exist:\n ${tgt_project}\n")
+  return()
+endif()
+
+file(STRINGS ${tgt_project} tgt_projects_strings REGEX ForcedIncludeFiles)
+
+foreach(line IN LISTS tgt_projects_strings)
+  if (line MATCHES "<ForcedIncludeFiles>force_include_1.h;force_include_2.h</ForcedIncludeFiles>")
+    set(have_FI ON)
+  endif()
+endforeach()
+
+if (NOT have_FI)
+  set(RunCMake_TEST_FAILED "Generated project does not have expected ForcedIncludeFiles.")
+  return()
+endif()

+ 5 - 0
Tests/RunCMake/VS10Project/VsForceInclude.cmake

@@ -0,0 +1,5 @@
+enable_language(CXX)
+
+add_library(tgt STATIC empty.cxx)
+target_compile_options(tgt PRIVATE "SHELL:/FI force_include_1.h")
+target_compile_options(tgt PRIVATE "/FIforce_include_2.h")