Merge topic 'vs9-deprecate'

d7f440c5db Deprecate Visual Studio 9 2008 generator

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8181
diff --git a/Help/generator/Visual Studio 9 2008.rst b/Help/generator/Visual Studio 9 2008.rst
index 3434956..816969d 100644
--- a/Help/generator/Visual Studio 9 2008.rst
+++ b/Help/generator/Visual Studio 9 2008.rst
@@ -1,7 +1,15 @@
 Visual Studio 9 2008
 --------------------
 
-Generates Visual Studio 9 2008 project files.
+Deprecated.  Generates Visual Studio 9 2008 project files.
+
+.. note::
+  This generator is deprecated and will be removed in a future version
+  of CMake.  It will still be possible to build with VS 9 2008 tools
+  using the :generator:`Visual Studio 12 2013` generator (or above,
+  and with VS 10 2010 also installed) with
+  :variable:`CMAKE_GENERATOR_TOOLSET` set to ``v90``,
+  or by using the :generator:`NMake Makefiles` generator.
 
 Platform Selection
 ^^^^^^^^^^^^^^^^^^
diff --git a/Help/release/dev/vs9-deprecate.rst b/Help/release/dev/vs9-deprecate.rst
new file mode 100644
index 0000000..46568f8
--- /dev/null
+++ b/Help/release/dev/vs9-deprecate.rst
@@ -0,0 +1,5 @@
+vs9-deprecate
+-------------
+
+* The :generator:`Visual Studio 9 2008` generator is now deprecated
+  and will be removed in a future version of CMake.
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index d483135..5de3a55 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -309,6 +309,26 @@
                                 GetSLNFile(this->LocalGenerators[0].get()));
   }
 
+  if (this->Version == VSVersion::VS9 &&
+      !this->CMakeInstance->GetIsInTryCompile()) {
+    std::string cmakeWarnVS9;
+    if (cmValue cached = this->CMakeInstance->GetState()->GetCacheEntryValue(
+          "CMAKE_WARN_VS9")) {
+      this->CMakeInstance->MarkCliAsUsed("CMAKE_WARN_VS9");
+      cmakeWarnVS9 = *cached;
+    } else {
+      cmSystemTools::GetEnv("CMAKE_WARN_VS9", cmakeWarnVS9);
+    }
+    if (cmakeWarnVS9.empty() || !cmIsOff(cmakeWarnVS9)) {
+      this->CMakeInstance->IssueMessage(
+        MessageType::WARNING,
+        "The \"Visual Studio 9 2008\" generator is deprecated "
+        "and will be removed in a future version of CMake."
+        "\n"
+        "Add CMAKE_WARN_VS9=OFF to the cache to disable this warning.");
+    }
+  }
+
   if (this->Version == VSVersion::VS11 &&
       !this->CMakeInstance->GetIsInTryCompile()) {
     std::string cmakeWarnVS11;
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index 9f6550b..e396405 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -64,7 +64,7 @@
   cmDocumentationEntry GetDocumentation() const override
   {
     return { std::string(vs9generatorName) + " [arch]",
-             "Generates Visual Studio 2008 project files.  "
+             "Deprecated.  Generates Visual Studio 2008 project files.  "
              "Optional [arch] can be \"Win64\" or \"IA64\"." };
   }
 
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index c22f704..38e0460 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -40,10 +40,12 @@
 endif()
 
 # Suppress generator deprecation warnings in test suite.
-if(CMAKE_GENERATOR MATCHES "^Visual Studio 11 2012")
-  set(TEST_WARN_VS11_CODE "set(ENV{CMAKE_WARN_VS11} OFF)")
+if(CMAKE_GENERATOR MATCHES "^Visual Studio 9 2008")
+  set(TEST_WARN_VS_CODE "set(ENV{CMAKE_WARN_VS9} OFF)")
+elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 11 2012")
+  set(TEST_WARN_VS_CODE "set(ENV{CMAKE_WARN_VS11} OFF)")
 else()
-  set(TEST_WARN_VS11_CODE "")
+  set(TEST_WARN_VS_CODE "")
 endif()
 
 # 3.9 or later provides a definitive answer to whether we are multi-config
diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in
index 7722d7d..61be40b 100644
--- a/Tests/EnforceConfig.cmake.in
+++ b/Tests/EnforceConfig.cmake.in
@@ -36,4 +36,4 @@
 unset(ENV{CMAKE_EXPORT_COMPILE_COMMANDS})
 
 @TEST_HOME_ENV_CODE@
-@TEST_WARN_VS11_CODE@
+@TEST_WARN_VS_CODE@
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS9-WARN-OFF.cmake b/Tests/RunCMake/CommandLine/DeprecateVS9-WARN-OFF.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/DeprecateVS9-WARN-OFF.cmake
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS9-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS9-WARN-ON-stderr.txt
new file mode 100644
index 0000000..c3329a0
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/DeprecateVS9-WARN-ON-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Warning:
+  The "Visual Studio 9 2008" generator is deprecated and will be removed in a
+  future version of CMake.
+
+  Add CMAKE_WARN_VS9=OFF to the cache to disable this warning.$
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS9-WARN-ON.cmake b/Tests/RunCMake/CommandLine/DeprecateVS9-WARN-ON.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/DeprecateVS9-WARN-ON.cmake
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 943be24..7ff417b 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -1101,6 +1101,13 @@
 run_cmake(ProfilingTest)
 unset(RunCMake_TEST_OPTIONS)
 
+if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 2008")
+  run_cmake_with_options(DeprecateVS9-WARN-ON -DCMAKE_WARN_VS9=ON)
+  unset(ENV{CMAKE_WARN_VS9})
+  run_cmake(DeprecateVS9-WARN-ON)
+  run_cmake_with_options(DeprecateVS9-WARN-OFF -DCMAKE_WARN_VS9=OFF)
+endif()
+
 if(RunCMake_GENERATOR MATCHES "^Visual Studio 11 2012")
   run_cmake_with_options(DeprecateVS11-WARN-ON -DCMAKE_WARN_VS11=ON)
   unset(ENV{CMAKE_WARN_VS11})