[Cmake-commits] CMake branch, master, updated. v3.15.1-530-gcb88632

Kitware Robot kwrobot at kitware.com
Wed Jul 31 11:42:05 EDT 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  cb8863279033d9dd81d01edcbb5cc8ae1911b06c (commit)
       via  f9b7c660d700ffa2166b80333bfd89f96fbfb186 (commit)
      from  72c1d564ccb1f1e33ff0c893b0bfc22abbda124e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cb8863279033d9dd81d01edcbb5cc8ae1911b06c
commit cb8863279033d9dd81d01edcbb5cc8ae1911b06c
Merge: 72c1d56 f9b7c66
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jul 31 15:41:22 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Jul 31 11:41:37 2019 -0400

    Merge topic 'vs-spectre-off'
    
    f9b7c660d7 VS: Fix mapping of `-Qspectre-` flag
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !3629


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9b7c660d700ffa2166b80333bfd89f96fbfb186
commit f9b7c660d700ffa2166b80333bfd89f96fbfb186
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jul 30 11:05:04 2019 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Jul 30 11:17:28 2019 -0400

    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

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 8c6ba4e..7d25713 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1229,8 +1229,11 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
   if (this->IPOEnabledConfigurations.count(config) > 0) {
     e1.Element("WholeProgramOptimization", "true");
   }
-  if (this->SpectreMitigationConfigurations.count(config) > 0) {
-    e1.Element("SpectreMitigation", "Spectre");
+  {
+    auto s = this->SpectreMitigation.find(config);
+    if (s != this->SpectreMitigation.end()) {
+      e1.Element("SpectreMitigation", s->second);
+    }
   }
 }
 
@@ -2760,8 +2763,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
     }
   }
 
-  if (clOptions.HasFlag("SpectreMitigation")) {
-    this->SpectreMitigationConfigurations.insert(configName);
+  if (const char* s = clOptions.GetFlag("SpectreMitigation")) {
+    this->SpectreMitigation[configName] = s;
     clOptions.RemoveFlag("SpectreMitigation");
   }
 
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 860b809..6607e77 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -215,7 +215,7 @@ private:
   unsigned int NsightTegraVersion[4];
   bool TargetCompileAsWinRT;
   std::set<std::string> IPOEnabledConfigurations;
-  std::set<std::string> SpectreMitigationConfigurations;
+  std::map<std::string, std::string> SpectreMitigation;
   cmGlobalVisualStudio10Generator* const GlobalGenerator;
   cmLocalVisualStudio10Generator* const LocalGenerator;
   std::set<std::string> CSharpCustomCommandNames;
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index 55ca9ea..27b81b7 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -26,3 +26,7 @@ run_cmake(VsPackageReferences)
 if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05)
   run_cmake(VsJustMyCode)
 endif()
+
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.20)
+  run_cmake(VsSpectreMitigation)
+endif()
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")
diff --git a/Tests/RunCMake/VS10Project/VsSpectreMitigation.cmake b/Tests/RunCMake/VS10Project/VsSpectreMitigation.cmake
new file mode 100644
index 0000000..b3779d7
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsSpectreMitigation.cmake
@@ -0,0 +1,8 @@
+set(CMAKE_CONFIGURATION_TYPES Debug)
+enable_language(C)
+
+add_library(SpectreMitigationOn-C empty.c)
+target_compile_options(SpectreMitigationOn-C PRIVATE -Qspectre)
+
+add_library(SpectreMitigationOff-C empty.c)
+target_compile_options(SpectreMitigationOff-C PRIVATE -Qspectre-)

-----------------------------------------------------------------------

Summary of changes:
 Source/cmVisualStudio10TargetGenerator.cxx         | 11 +++++---
 Source/cmVisualStudio10TargetGenerator.h           |  2 +-
 Tests/RunCMake/VS10Project/RunCMakeTest.cmake      |  4 +++
 .../VS10Project/VsSpectreMitigation-check.cmake    | 30 ++++++++++++++++++++++
 .../RunCMake/VS10Project/VsSpectreMitigation.cmake |  8 ++++++
 5 files changed, 50 insertions(+), 5 deletions(-)
 create mode 100644 Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake
 create mode 100644 Tests/RunCMake/VS10Project/VsSpectreMitigation.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list