Merge topic 'FindFreeType-config-windows' into release-3.28

0117446c97 FindFreeType: also set `FREETYPE_FOUND`
2cf2d4f7df FindFreeType: insert Freetype's location to the start
1cfc708eea FindFreeType: handle config-specific `LOCATION` settings as well
ae9890cd36 FindFreeType: consider `IMPLIB`-using platforms

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8920
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 008b537..a7ee0c4 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -299,6 +299,8 @@
           list(APPEND _protobuf_include_path -I ${_abs_dir})
       endif()
     endforeach()
+  else()
+    set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
   endif()
 
   foreach(DIR ${protobuf_generate_IMPORT_DIRS})
@@ -309,10 +311,6 @@
     endif()
   endforeach()
 
-  if(NOT _protobuf_include_path)
-    set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
-  endif()
-
   set(_generated_srcs_all)
   foreach(_proto ${protobuf_generate_PROTOS})
     get_filename_component(_abs_file ${_proto} ABSOLUTE)
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 2ee4f47..91f7691 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -219,9 +219,11 @@
   state->AddDisallowedCommand(
     "use_mangled_mesa", cmUseMangledMesaCommand, cmPolicies::CMP0030,
     "The use_mangled_mesa command should not be called; see CMP0030.");
-  state->AddDisallowedCommand(
-    "exec_program", cmExecProgramCommand, cmPolicies::CMP0153,
-    "The exec_program command should not be called; see CMP0153.");
+  state->AddDisallowedCommand("exec_program", cmExecProgramCommand,
+                              cmPolicies::CMP0153,
+                              "The exec_program command should not be called; "
+                              "see CMP0153. Use execute_process() instead.",
+                              "Use execute_process() instead.");
 
 #endif
 }
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 05b6690..dabb078 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -1257,8 +1257,6 @@
 {
   cmNinjaBuild scanBuild(ruleName);
 
-  scanBuild.RspFile = "$out.rsp";
-
   if (compilePP) {
     // Move compilation dependencies to the scan/preprocessing build statement.
     std::swap(scanBuild.ExplicitDeps, objBuild.ExplicitDeps);
@@ -1299,6 +1297,7 @@
   // Tell dependency scanner where to store dyndep intermediate results.
   std::string ddiFileName = cmStrCat(objectFileName, ".ddi");
   scanBuild.Variables["DYNDEP_INTERMEDIATE_FILE"] = ddiFileName;
+  scanBuild.RspFile = cmStrCat(ddiFileName, ".rsp");
 
   // Outputs of the scan/preprocessor build statement.
   if (compilePP) {
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index d41e8e5..8ae2166 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -447,17 +447,23 @@
 void cmState::AddDisallowedCommand(std::string const& name,
                                    BuiltinCommand command,
                                    cmPolicies::PolicyID policy,
-                                   const char* message)
+                                   const char* message,
+                                   const char* additionalWarning)
 {
   this->AddBuiltinCommand(
     name,
-    [command, policy, message](const std::vector<cmListFileArgument>& args,
-                               cmExecutionStatus& status) -> bool {
+    [command, policy, message,
+     additionalWarning](const std::vector<cmListFileArgument>& args,
+                        cmExecutionStatus& status) -> bool {
       cmMakefile& mf = status.GetMakefile();
       switch (mf.GetPolicyStatus(policy)) {
-        case cmPolicies::WARN:
-          mf.IssueMessage(MessageType::AUTHOR_WARNING,
-                          cmPolicies::GetPolicyWarning(policy));
+        case cmPolicies::WARN: {
+          std::string warning = cmPolicies::GetPolicyWarning(policy);
+          if (additionalWarning) {
+            warning = cmStrCat(warning, '\n', additionalWarning);
+          }
+          mf.IssueMessage(MessageType::AUTHOR_WARNING, warning);
+        }
           CM_FALLTHROUGH;
         case cmPolicies::OLD:
           break;
diff --git a/Source/cmState.h b/Source/cmState.h
index b79f3e6..702b06f 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -183,7 +183,8 @@
   void AddFlowControlCommand(std::string const& name, Command command);
   void AddFlowControlCommand(std::string const& name, BuiltinCommand command);
   void AddDisallowedCommand(std::string const& name, BuiltinCommand command,
-                            cmPolicies::PolicyID policy, const char* message);
+                            cmPolicies::PolicyID policy, const char* message,
+                            const char* additionalWarning = nullptr);
   void AddUnexpectedCommand(std::string const& name, const char* error);
   void AddUnexpectedFlowControlCommand(std::string const& name,
                                        const char* error);
diff --git a/Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt b/Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt
index e24eee7..2b0a661 100644
--- a/Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt
+++ b/Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt
@@ -1,3 +1,4 @@
 ^CMake Error at [^
 ]*/Tests/RunCMake/CMP0153/CMP0153-NEW\.cmake:[0-9]+ \(exec_program\):
-  The exec_program command should not be called; see CMP0153\.$
+  The exec_program command should not be called; see CMP0153\.  Use
+  execute_process\(\) instead\.$
diff --git a/Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt b/Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt
index 8f22d4e..d0b9422 100644
--- a/Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt
+++ b/Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt
@@ -3,4 +3,6 @@
   Policy CMP0153 is not set: The exec_program command should not be called\.
   Run "cmake --help-policy CMP0153" for policy details\.  Use the cmake_policy
   command to set the policy and suppress this warning\.
+
+  Use execute_process\(\) instead\.
 This warning is for project developers\.  Use -Wno-dev to suppress it\.$
diff --git a/Tests/RunCMake/CXXModules/NinjaForceResponseFile-check.cmake b/Tests/RunCMake/CXXModules/NinjaForceResponseFile-check.cmake
new file mode 100644
index 0000000..b8863e7
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/NinjaForceResponseFile-check.cmake
@@ -0,0 +1,23 @@
+if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
+  set(path "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/impl-Debug.ninja")
+else ()
+  set(path "${RunCMake_TEST_BINARY_DIR}/build.ninja")
+endif ()
+
+if (NOT EXISTS "${path}")
+  list(APPEND RunCMake_TEST_FAILED
+    "Failed to find `ninja` build file: '${path}'")
+endif ()
+
+file(READ "${path}" rspfiles
+  REGEX "^ *RSP_FILE =")
+
+if (rspfiles MATCHES "\\$out\\.rsp$")
+  message(FATAL_ERROR
+    "rspfiles for modules should be specified explicitly")
+elseif (NOT rspfiles MATCHES "ddi\\.rsp")
+  message(FATAL_ERROR
+    "rspfiles for scanning rules should be specified according to scan output filenames")
+endif ()
+
+string(REPLACE ";" "\n  " RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}")
diff --git a/Tests/RunCMake/CXXModules/NinjaForceResponseFile.cmake b/Tests/RunCMake/CXXModules/NinjaForceResponseFile.cmake
new file mode 100644
index 0000000..bac3263
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/NinjaForceResponseFile.cmake
@@ -0,0 +1,27 @@
+# Fake out that we have dyndep; we only need to generate, not actually build
+# here.
+set(CMAKE_CXX_SCANDEP_SOURCE "")
+
+enable_language(CXX)
+
+if (NOT CMAKE_GENERATOR MATCHES "Ninja")
+  message(FATAL_ERROR
+    "This test requires a 'Ninja' generator to be used.")
+endif ()
+
+set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1)
+
+add_library(ninja-forced-response-file)
+target_sources(ninja-forced-response-file
+  PRIVATE
+    FILE_SET modules TYPE CXX_MODULES
+    BASE_DIRS
+      "${CMAKE_CURRENT_SOURCE_DIR}/sources"
+    FILES
+      sources/module.cxx
+      sources/module-part.cxx
+    FILE_SET internal_partitions TYPE CXX_MODULES FILES
+      sources/module-internal-part.cxx)
+target_compile_features(ninja-forced-response-file
+  PRIVATE
+    cxx_std_20)
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index e687e9f..c1c42c4 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -94,6 +94,7 @@
   run_cmake(NinjaDependInfoFileSet)
   run_cmake(NinjaDependInfoExport)
   run_cmake(NinjaDependInfoBMIInstall)
+  run_cmake(NinjaForceResponseFile) # issue#25367
 elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
   run_cmake(VisualStudioNoSyntheticTargets)
 else ()