summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-07-30 15:05:04 (GMT)
committerBrad King <brad.king@kitware.com>2019-07-30 15:17:28 (GMT)
commitf9b7c660d700ffa2166b80333bfd89f96fbfb186 (patch)
tree55dd5035668a38c969160dcd55b5b9cb5648152c /Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake
parentf43a7d76c737c5bb9b903a2b1be5186c081ec21e (diff)
downloadCMake-f9b7c660d700ffa2166b80333bfd89f96fbfb186.zip
CMake-f9b7c660d700ffa2166b80333bfd89f96fbfb186.tar.gz
CMake-f9b7c660d700ffa2166b80333bfd89f96fbfb186.tar.bz2
VS: Fix mapping of `-Qspectre-` flag
The mapping for this flag was added by commit 43aa632f57 (VS: Populate `-Qspectre-` flag table entry for v142, 2019-01-24, v3.14.0-rc1~74^2~7). However, it did not do anything because the special logic added by commit bb60ed6e72 (VS: Add flag table entry for -Qspectre, 2018-10-08, v3.13.0-rc1~4^2) to move the `SpectreMitigation` element from `ClCompile` to the top level only handled the presence of the setting and not its value. Extend the special logic to carry the value too. Fixes: #19535
Diffstat (limited to 'Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake')
-rw-r--r--Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake30
1 files changed, 30 insertions, 0 deletions
diff --git a/Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake b/Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake
new file mode 100644
index 0000000..6117763
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake
@@ -0,0 +1,30 @@
+macro(VsSpectreMitigation_check tgt spectre_expect)
+ set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj")
+ if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.")
+ return()
+ endif()
+
+ set(HAVE_SpectreMitigation 0)
+
+ file(STRINGS "${vcProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<SpectreMitigation>([^<>]+)</SpectreMitigation>")
+ set(spectre_actual "${CMAKE_MATCH_1}")
+ if(NOT "${spectre_actual}" STREQUAL "${spectre_expect}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <SpectreMitigation> '${spectre_actual}', not '${spectre_expect}'.")
+ return()
+ endif()
+ set(HAVE_SpectreMitigation 1)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT HAVE_SpectreMitigation AND NOT "${spectre_expect}" STREQUAL "")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <SpectreMitigation> field.")
+ return()
+ endif()
+endmacro()
+
+VsSpectreMitigation_check(SpectreMitigationOn-C "Spectre")
+VsSpectreMitigation_check(SpectreMitigationOff-C "false")