Merge topic 'patch-CheckIncludeFiles-LANGUAGE'

5000f895fd CheckIncludeFiles: Document version 3.11 for LANGUAGE option

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11123
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst
index a3ceef2..97390f7 100644
--- a/Help/command/find_package.rst
+++ b/Help/command/find_package.rst
@@ -338,7 +338,9 @@
 specified.  If ``REQUIRED`` is specified and the package is not found, a
 fatal error is generated and the configure step stops executing.  If
 ``<PackageName>_DIR`` has been set to a directory not containing a
-configuration file, CMake will ignore it and search from scratch.
+configuration file, or if the requested version is not compatible
+with the package found in that directory (see :ref:`version selection`),
+CMake will ignore it and search from scratch.
 
 Package maintainers providing package configuration files are encouraged to
 name and install them such that the :ref:`search procedure` outlined below
diff --git a/Help/release/dev/find-modules.rst b/Help/release/dev/find-modules.rst
index 29c9f27..4feb634 100644
--- a/Help/release/dev/find-modules.rst
+++ b/Help/release/dev/find-modules.rst
@@ -37,6 +37,12 @@
 * The :module:`FindHg` module now provides a ``Hg_VERSION`` result
   variable.  The ``HG_VERSION_STRING`` result variable is deprecated.
 
+* The :module:`FindHSPELL` module now provides a ``HSPELL_VERSION`` result
+  variable.  The ``HSPELL_VERSION_STRING`` result variable is deprecated.
+
+* The :module:`FindIcotool` module now provides a ``Icotool_VERSION`` result
+  variable.  The ``ICOTOOL_VERSION_STRING`` result variable is deprecated.
+
 * The :module:`FindJasper` module now provides a ``Jasper_VERSION`` result
   variable.  The ``JASPER_VERSION_STRING`` result variable is deprecated.
 
@@ -60,6 +66,9 @@
   ``Lua_VERSION`` instead of the now deprecated ``LUA_VERSION_STRING`` result
   variable.
 
+* The :module:`FindOpenCL` module now provides an ``OpenCL_VERSION`` result
+  variable.  The ``OpenCL_VERSION_STRING`` result variable is deprecated.
+
 * The :module:`FindOpenSceneGraph` module now provides an
   ``OpenSceneGraph_VERSION`` result variable.  The ``OPENSCENEGRAPH_VERSION``
   result variable is deprecated.
diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake
index b1acaab..d77e81c 100644
--- a/Modules/CheckPrototypeDefinition.cmake
+++ b/Modules/CheckPrototypeDefinition.cmake
@@ -93,10 +93,6 @@
   )
 #]=======================================================================]
 
-#
-
-get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
-
 include_guard(GLOBAL)
 
 function(check_prototype_definition _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
@@ -143,7 +139,7 @@
     set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE})
     set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN})
 
-    file(READ ${__check_proto_def_dir}/CheckPrototypeDefinition.c.in _SOURCE)
+    file(READ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CheckPrototypeDefinition.c.in _SOURCE)
     string(CONFIGURE "${_SOURCE}" _SOURCE @ONLY)
 
     try_compile(${_VARIABLE}
diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake
index 9643d87..c1a5a20 100644
--- a/Modules/CheckTypeSize.cmake
+++ b/Modules/CheckTypeSize.cmake
@@ -170,8 +170,6 @@
 include(CheckIncludeFile)
 include(CheckIncludeFileCXX)
 
-get_filename_component(__check_type_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
-
 include_guard(GLOBAL)
 
 block(SCOPE_FOR POLICIES)
@@ -232,7 +230,7 @@
 
   # Perform the check.
   set(bin ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.bin)
-  file(READ ${__check_type_size_dir}/CheckTypeSize.c.in src_content)
+  file(READ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CheckTypeSize.c.in src_content)
   string(CONFIGURE "${src_content}" src_content @ONLY)
   try_compile(HAVE_${var} SOURCE_FROM_VAR "${src}" src_content
     COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
@@ -280,7 +278,7 @@
 
     # Update the architecture-to-size map.
     if(mismatch AND keys)
-      configure_file(${__check_type_size_dir}/CheckTypeSizeMap.cmake.in ${map} @ONLY)
+      configure_file(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CheckTypeSizeMap.cmake.in ${map} @ONLY)
       set(${var} 0)
     else()
       file(REMOVE ${map})
diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake
index 9f3eacc..02d8bd9 100644
--- a/Modules/ExternalData.cmake
+++ b/Modules/ExternalData.cmake
@@ -492,7 +492,7 @@
 
   # Store configuration for use by build-time script.
   set(config ${CMAKE_CURRENT_BINARY_DIR}/${target}_config.cmake)
-  configure_file(${_ExternalData_SELF_DIR}/ExternalData_config.cmake.in ${config} @ONLY)
+  configure_file(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalData_config.cmake.in ${config} @ONLY)
 
   set(files "")
 
@@ -524,7 +524,7 @@
                                    -DExternalData_ACTION=local
                                    -DExternalData_SHOW_PROGRESS=${_ExternalData_add_target_SHOW_PROGRESS}
                                    -DExternalData_CONFIG=${config}
-                                   -P ${_ExternalData_SELF}
+                                   -P ${CMAKE_CURRENT_FUNCTION_LIST_FILE}
           MAIN_DEPENDENCY "${name}"
           )
       endif()
@@ -561,7 +561,7 @@
                                    -DExternalData_ACTION=fetch
                                    -DExternalData_SHOW_PROGRESS=${_ExternalData_add_target_SHOW_PROGRESS}
                                    -DExternalData_CONFIG=${config}
-                                   -P ${_ExternalData_SELF}
+                                   -P ${CMAKE_CURRENT_FUNCTION_LIST_FILE}
           # Update whenever the object hash changes.
           MAIN_DEPENDENCY "${name}${first_ext}"
           )
@@ -615,8 +615,6 @@
 
 set(_ExternalData_REGEX_ALGO "MD5|SHA1|SHA224|SHA256|SHA384|SHA512|SHA3_224|SHA3_256|SHA3_384|SHA3_512")
 set(_ExternalData_REGEX_EXT "md5|sha1|sha224|sha256|sha384|sha512|sha3-224|sha3-256|sha3-384|sha3-512")
-set(_ExternalData_SELF "${CMAKE_CURRENT_LIST_FILE}")
-get_filename_component(_ExternalData_SELF_DIR "${_ExternalData_SELF}" PATH)
 
 function(_ExternalData_compute_hash var_hash algo file)
   if("${algo}" MATCHES "^${_ExternalData_REGEX_ALGO}$")
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index bceb615..96b1659 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -584,10 +584,8 @@
 # This macro helps us find the location of helper files we will need the full path to
 macro(CUDA_FIND_HELPER_FILE _name _extension)
   set(_full_name "${_name}.${_extension}")
-  # CMAKE_CURRENT_LIST_FILE contains the full path to the file currently being
-  # processed.  Using this variable, we can pull out the current path, and
+  # Using CMAKE_CURRENT_LIST_DIR, we can pull out the current path, and
   # provide a way to get access to the other files we need local to here.
-  get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
   set(CUDA_${_name} "${CMAKE_CURRENT_LIST_DIR}/FindCUDA/${_full_name}")
   if(NOT EXISTS "${CUDA_${_name}}")
     set(error_message "${_full_name} not found in ${CMAKE_CURRENT_LIST_DIR}/FindCUDA")
diff --git a/Modules/FindHSPELL.cmake b/Modules/FindHSPELL.cmake
index f23acc5..dab21cd 100644
--- a/Modules/FindHSPELL.cmake
+++ b/Modules/FindHSPELL.cmake
@@ -17,13 +17,18 @@
 This module defines the following variables:
 
 ``HSPELL_FOUND``
-  Boolean indicating whether the Hspell is found.
-``HSPELL_VERSION_STRING``
+  Boolean indicating whether (the requested version of) Hspell is found.
+
+``HSPELL_VERSION``
+  .. versionadded:: 4.2
+
   The version of Hspell found (x.y).
-``HSPELL_MAJOR_VERSION``
-  The major version of Hspell.
-``HSPELL_MINOR_VERSION``
-  The minor version of Hspell.
+
+``HSPELL_VERSION_MAJOR``
+  The major version of Hspell found.
+
+``HSPELL_VERSION_MINOR``
+  The minor version of Hspell found.
 
 Cache Variables
 ^^^^^^^^^^^^^^^
@@ -32,9 +37,21 @@
 
 ``HSPELL_INCLUDE_DIR``
   The Hspell include directory.
+
 ``HSPELL_LIBRARIES``
   The libraries needed to use Hspell.
 
+Deprecated Variables
+^^^^^^^^^^^^^^^^^^^^
+
+The following variables are provided for backward compatibility:
+
+``HSPELL_VERSION_STRING``
+  .. deprecated:: 4.2
+    Use ``HSPELL_VERSION``, which has the same value.
+
+  The version of Hspell found (x.y).
+
 Examples
 ^^^^^^^^
 
@@ -56,14 +73,15 @@
     file(STRINGS "${HSPELL_INCLUDE_DIR}/hspell.h" HSPELL_H REGEX "#define HSPELL_VERSION_M(AJO|INO)R [0-9]+")
     string(REGEX REPLACE ".*#define HSPELL_VERSION_MAJOR ([0-9]+).*" "\\1" HSPELL_VERSION_MAJOR "${HSPELL_H}")
     string(REGEX REPLACE ".*#define HSPELL_VERSION_MINOR ([0-9]+).*" "\\1" HSPELL_VERSION_MINOR "${HSPELL_H}")
-    set(HSPELL_VERSION_STRING "${HSPELL_VERSION_MAJOR}.${HSPELL_VERSION_MINOR}")
+    set(HSPELL_VERSION "${HSPELL_VERSION_MAJOR}.${HSPELL_VERSION_MINOR}")
+    set(HSPELL_VERSION_STRING "${HSPELL_VERSION}")
     unset(HSPELL_H)
 endif()
 
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(HSPELL
                                   REQUIRED_VARS HSPELL_LIBRARIES HSPELL_INCLUDE_DIR
-                                  VERSION_VAR HSPELL_VERSION_STRING)
+                                  VERSION_VAR HSPELL_VERSION)
 
 mark_as_advanced(HSPELL_INCLUDE_DIR HSPELL_LIBRARIES)
 
diff --git a/Modules/FindIcotool.cmake b/Modules/FindIcotool.cmake
index 1009c75..2e28642 100644
--- a/Modules/FindIcotool.cmake
+++ b/Modules/FindIcotool.cmake
@@ -18,9 +18,13 @@
 This module defines the following variables:
 
 ``Icotool_FOUND``
-  True if ``icotool`` has been found.  For backward compatibility, the
-  ``ICOTOOL_FOUND`` variable is also set to the same value.
-``ICOTOOL_VERSION_STRING``
+  Boolean indicating whether (the requested version of) ``icotool`` has been
+  found.  For backward compatibility, the ``ICOTOOL_FOUND`` variable is also
+  set to the same value.
+
+``Icotool_VERSION``
+  .. versionadded:: 4.2
+
   The version of ``icotool`` found.
 
 Cache Variables
@@ -31,6 +35,17 @@
 ``ICOTOOL_EXECUTABLE``
   The full path to the ``icotool`` tool.
 
+Deprecated Variables
+^^^^^^^^^^^^^^^^^^^^
+
+The following variables are provided for backward compatibility:
+
+``ICOTOOL_VERSION_STRING``
+  .. deprecated:: 4.2
+    Use ``Icotool_VERSION``, which has the same value.
+
+  The version of ``icotool`` found.
+
 Examples
 ^^^^^^^^
 
@@ -55,27 +70,23 @@
 if(ICOTOOL_EXECUTABLE)
   execute_process(
     COMMAND ${ICOTOOL_EXECUTABLE} --version
-    OUTPUT_VARIABLE _icotool_version
+    OUTPUT_VARIABLE Icotool_VERSION
     ERROR_QUIET
     OUTPUT_STRIP_TRAILING_WHITESPACE
   )
-  if("${_icotool_version}" MATCHES "^icotool \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
-    set( ICOTOOL_VERSION_STRING
-      "${CMAKE_MATCH_1}"
-    )
+  if("${Icotool_VERSION}" MATCHES "^icotool \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
+    set(Icotool_VERSION "${CMAKE_MATCH_1}")
   else()
-    set( ICOTOOL_VERSION_STRING
-      ""
-    )
+    set(Icotool_VERSION "")
   endif()
-  unset(_icotool_version)
+  set(ICOTOOL_VERSION_STRING "${Icotool_VERSION}")
 endif()
 
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(
   Icotool
   REQUIRED_VARS ICOTOOL_EXECUTABLE
-  VERSION_VAR ICOTOOL_VERSION_STRING
+  VERSION_VAR Icotool_VERSION
 )
 
 mark_as_advanced(
diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake
index ccf78e9..ff4e1d2 100644
--- a/Modules/FindOpenCL.cmake
+++ b/Modules/FindOpenCL.cmake
@@ -13,19 +13,25 @@
 
   find_package(OpenCL [<version>] [...])
 
+OpenCL is a framework for writing programs that execute across heterogeneous
+platforms, such as CPUs, GPUs, and other accelerators.
+
+.. versionadded:: 3.24
+  Detection of OpenCL 3.0.
+
 .. versionadded:: 3.10
   Detection of OpenCL 2.1 and 2.2.
 
 Imported Targets
 ^^^^^^^^^^^^^^^^
 
-.. versionadded:: 3.7
-
-This module provides the following :ref:`Imported Targets`, if OpenCL has been
-found:
+This module provides the following :ref:`Imported Targets`:
 
 ``OpenCL::OpenCL``
-  Target providing OpenCL usage requirements.
+  .. versionadded:: 3.7
+
+  Target encapsulating the OpenCL usage requirements, available if OpenCL
+  has been found.
 
 Result Variables
 ^^^^^^^^^^^^^^^^
@@ -33,18 +39,26 @@
 This module defines the following variables:
 
 ``OpenCL_FOUND``
-  True if OpenCL was found.
-``OpenCL_INCLUDE_DIRS``
-  Include directories needed to use OpenCL.
-``OpenCL_LIBRARIES``
-  Libraries needed to link to OpenCL.
-``OpenCL_VERSION_STRING``
-  Highest supported OpenCL version (e.g., ``1.2``).
+  Boolean indicating whether (the requested version of) OpenCL was found.
+
+``OpenCL_VERSION``
+  .. versionadded:: 4.2
+
+  Highest supported OpenCL version found in form of ``<major>.<minor>``
+  (e.g., ``1.2``).
+
 ``OpenCL_VERSION_MAJOR``
   The major version of the OpenCL implementation.
+
 ``OpenCL_VERSION_MINOR``
   The minor version of the OpenCL implementation.
 
+``OpenCL_INCLUDE_DIRS``
+  Include directories needed to use OpenCL.
+
+``OpenCL_LIBRARIES``
+  Libraries needed to link to OpenCL.
+
 Cache Variables
 ^^^^^^^^^^^^^^^
 
@@ -52,9 +66,21 @@
 
 ``OpenCL_INCLUDE_DIR``
   The OpenCL include directory.
+
 ``OpenCL_LIBRARY``
   The path to the OpenCL library.
 
+Deprecated Variables
+^^^^^^^^^^^^^^^^^^^^
+
+The following variables are provided for backward compatibility:
+
+``OpenCL_VERSION_STRING``
+  .. deprecated:: 4.2
+    Use ``OpenCL_VERSION``, which has the same value.
+
+  Highest supported OpenCL version found in form of ``<major>.<minor>``.
+
 Examples
 ^^^^^^^^
 
@@ -66,21 +92,28 @@
   target_link_libraries(project_target PRIVATE OpenCL::OpenCL)
 #]=======================================================================]
 
+cmake_policy(PUSH)
+cmake_policy(SET CMP0140 NEW)
+
 set(_OPENCL_x86 "(x86)")
 
 function(_FIND_OPENCL_VERSION)
+  include(CheckIncludeFiles)
   include(CheckSymbolExists)
   include(CMakePushCheckState)
-  set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY})
 
   cmake_push_check_state()
-  foreach(VERSION "3_0" "2_2" "2_1" "2_0" "1_2" "1_1" "1_0")
-    set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}")
 
-    if(EXISTS ${OpenCL_INCLUDE_DIR}/Headers/cl.h)
+  set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY})
+  set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}")
+
+  check_include_files(OpenCL/cl.h OpenCL_HAVE_OPENCL_CL_H)
+
+  foreach(VERSION "3_0" "2_2" "2_1" "2_0" "1_2" "1_1" "1_0")
+    if(OpenCL_HAVE_OPENCL_CL_H)
       check_symbol_exists(
         CL_VERSION_${VERSION}
-        "Headers/cl.h"
+        "OpenCL/cl.h"
         OPENCL_VERSION_${VERSION})
     else()
       check_symbol_exists(
@@ -91,16 +124,25 @@
 
     if(OPENCL_VERSION_${VERSION})
       string(REPLACE "_" "." VERSION "${VERSION}")
-      set(OpenCL_VERSION_STRING ${VERSION} PARENT_SCOPE)
+      set(OpenCL_VERSION ${VERSION})
+      set(OpenCL_VERSION_STRING "${OpenCL_VERSION}")
       string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}")
       list(GET version_components 0 major_version)
       list(GET version_components 1 minor_version)
-      set(OpenCL_VERSION_MAJOR ${major_version} PARENT_SCOPE)
-      set(OpenCL_VERSION_MINOR ${minor_version} PARENT_SCOPE)
+      set(OpenCL_VERSION_MAJOR ${major_version})
+      set(OpenCL_VERSION_MINOR ${minor_version})
       break()
     endif()
   endforeach()
   cmake_pop_check_state()
+
+  return(
+    PROPAGATE
+      OpenCL_VERSION
+      OpenCL_VERSION_MAJOR
+      OpenCL_VERSION_MINOR
+      OpenCL_VERSION_STRING
+  )
 endfunction()
 
 find_path(OpenCL_INCLUDE_DIR
@@ -204,7 +246,8 @@
 find_package_handle_standard_args(
   OpenCL
   REQUIRED_VARS OpenCL_LIBRARY OpenCL_INCLUDE_DIR
-  VERSION_VAR OpenCL_VERSION_STRING)
+  VERSION_VAR OpenCL_VERSION
+)
 
 mark_as_advanced(
   OpenCL_INCLUDE_DIR
@@ -223,3 +266,5 @@
   set_target_properties(OpenCL::OpenCL PROPERTIES
     INTERFACE_INCLUDE_DIRECTORIES "${OpenCL_INCLUDE_DIRS}")
 endif()
+
+cmake_policy(POP)
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index c084e81..f4a532d 100644
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -1326,19 +1326,13 @@
     QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE QT_QCOLLECTIONGENERATOR_EXECUTABLE
     QT_DESIGNER_EXECUTABLE QT_LINGUIST_EXECUTABLE)
 
-
-  # get the directory of the current file, used later on in the file
-  get_filename_component( _qt4_current_dir  "${CMAKE_CURRENT_LIST_FILE}" PATH)
-
-
   ###############################################
   #
   #       configuration/system dependent settings
   #
   ###############################################
 
-  include("${_qt4_current_dir}/Qt4ConfigDependentSettings.cmake")
-
+  include(${CMAKE_CURRENT_LIST_DIR}/Qt4ConfigDependentSettings.cmake)
 
   #######################################
   #
@@ -1425,14 +1419,13 @@
     endforeach()
   endforeach()
 
-
   ######################################
   #
   #       Macros for building Qt files
   #
   ######################################
 
-  include("${_qt4_current_dir}/Qt4Macros.cmake")
+  include(${CMAKE_CURRENT_LIST_DIR}/Qt4Macros.cmake)
 
 endif()
 
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 07b1c75..2090cbf 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 4)
 set(CMake_VERSION_MINOR 1)
-set(CMake_VERSION_PATCH 20250827)
+set(CMake_VERSION_PATCH 20250902)
 #set(CMake_VERSION_RC 0)
 set(CMake_VERSION_IS_DIRTY 0)
 
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index baf8fbd..62b6eb2 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -589,11 +589,12 @@
     preset.setToolset = !p.ToolsetStrategy ||
       p.ToolsetStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set;
     preset.enabled = it.Expanded && it.Expanded->ConditionResult &&
-      std::find_if(this->AvailableGenerators.begin(),
-                   this->AvailableGenerators.end(),
-                   [&p](cmake::GeneratorInfo const& g) {
-                     return g.name == p.Generator;
-                   }) != this->AvailableGenerators.end();
+      ((p.OriginFile->Version >= 3 && p.Generator.empty()) ||
+       std::find_if(this->AvailableGenerators.begin(),
+                    this->AvailableGenerators.end(),
+                    [&p](cmake::GeneratorInfo const& g) {
+                      return g.name == p.Generator;
+                    }) != this->AvailableGenerators.end());
     presets.push_back(preset);
   }
   emit this->presetsChanged(presets);
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 675ba50..45b0a65 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1443,7 +1443,7 @@
 
   auto linklang = linkLineComputer.GetLinkerLanguage(target, config);
   auto ipoEnabled = target->IsIPOEnabled(linklang, config);
-  if (!ipoEnabled) {
+  if (!ipoEnabled && pcli) {
     ipoEnabled = linkLineComputer.ComputeRequiresDeviceLinkingIPOFlag(*pcli);
   }
   if (ipoEnabled) {
@@ -2989,9 +2989,8 @@
   } else {
     cc->SetOutputs(outputs);
     cmSourceFile* copy_rule = this->AddCustomCommandToOutput(std::move(cc));
-    copy_rule->SetProperty("CXX_SCAN_FOR_MODULES", "0");
-
     if (copy_rule) {
+      copy_rule->SetProperty("CXX_SCAN_FOR_MODULES", "0");
       target->AddSource(copy_rule->ResolveFullPath());
     }
   }
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 3ce9051..42d60fa 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -27,6 +27,10 @@
 #include "cmSystemTools.h"
 #include "cmake.h"
 
+namespace cmStateDetail {
+std::string const PropertySentinel = std::string{};
+} // namespace cmStateDetail
+
 cmState::cmState(Mode mode, ProjectKind projectKind)
   : StateMode(mode)
   , StateProjectKind(projectKind)
diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx
index 1c69b3b..8f5ea97 100644
--- a/Source/cmStateDirectory.cxx
+++ b/Source/cmStateDirectory.cxx
@@ -66,7 +66,7 @@
   auto end = content.begin() + contentEndPosition;
 
   auto rbegin = cm::make_reverse_iterator(end);
-  rbegin = std::find(rbegin, content.rend(), cmPropertySentinel);
+  rbegin = std::find(rbegin, content.rend(), cmStateDetail::PropertySentinel);
 
   return cmMakeRange(rbegin.base(), end);
 }
@@ -130,7 +130,7 @@
 
   auto rend = this->DirectoryState->IncludeDirectories.rend();
   auto rbegin = cm::make_reverse_iterator(entryEnd);
-  rbegin = std::find(rbegin, rend, cmPropertySentinel);
+  rbegin = std::find(rbegin, rend, cmStateDetail::PropertySentinel);
 
   auto entryIt = rbegin.base();
 
@@ -244,7 +244,7 @@
 
   auto rend = this->DirectoryState->LinkDirectories.rend();
   auto rbegin = cm::make_reverse_iterator(entryEnd);
-  rbegin = std::find(rbegin, rend, cmPropertySentinel);
+  rbegin = std::find(rbegin, rend, cmStateDetail::PropertySentinel);
 
   auto entryIt = rbegin.base();
 
diff --git a/Source/cmStatePrivate.h b/Source/cmStatePrivate.h
index 2a82414..651d993 100644
--- a/Source/cmStatePrivate.h
+++ b/Source/cmStatePrivate.h
@@ -22,10 +22,9 @@
 namespace cmStateDetail {
 struct BuildsystemDirectoryStateType;
 struct PolicyStackEntry;
+extern std::string const PropertySentinel;
 } // namespace cmStateDetail
 
-static std::string const cmPropertySentinel = std::string();
-
 struct cmStateDetail::SnapshotDataType
 {
   cmStateDetail::PositionType ScopeParent;
diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx
index 43d4f59..50fc8d1 100644
--- a/Source/cmStateSnapshot.cxx
+++ b/Source/cmStateSnapshot.cxx
@@ -290,7 +290,8 @@
 
   auto parentRbegin = cm::make_reverse_iterator(parentEnd);
   auto parentRend = parentContent.rend();
-  parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinel);
+  parentRbegin =
+    std::find(parentRbegin, parentRend, cmStateDetail::PropertySentinel);
   auto parentIt = parentRbegin.base();
 
   thisContent = std::vector<BT<std::string>>(parentIt, parentEnd);
diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
index 32e2a01..53bf7b6 100644
--- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
+++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
@@ -102,6 +102,7 @@
     ICOTOOL
     JASPER
     LIBLZMA LIBXML2 LIBXSLT LTTNGUST
+    OpenCL
     PERL PKG_CONFIG PNG PostgreSQL
     SDL
     TCLSH TIFF
@@ -120,10 +121,11 @@
     EXPAT
     FLEX Freetype
     Gettext GIF GnuTLS GNUTLS GTK2
-    HDF5 Hg
+    HDF5 Hg HSPELL
+    Icotool
     Jasper JPEG
     LibArchive LibLZMA LIBLZMA LibXml2 LibXslt LTTngUST
-    OpenSceneGraph OPENSCENEGRAPH OpenSSL OPENSSL
+    OpenCL OpenSceneGraph OPENSCENEGRAPH OpenSSL OPENSSL
     Perl PerlLibs PkgConfig PNG PostgreSQL Protobuf
     Ruby RUBY
     SDL SWIG
diff --git a/Tests/FindOpenCL/Test/CMakeLists.txt b/Tests/FindOpenCL/Test/CMakeLists.txt
index f08d4e5..ae99198 100644
--- a/Tests/FindOpenCL/Test/CMakeLists.txt
+++ b/Tests/FindOpenCL/Test/CMakeLists.txt
@@ -4,6 +4,10 @@
 
 find_package(OpenCL REQUIRED)
 
+add_compile_definitions(
+  CL_TARGET_OPENCL_VERSION=${OpenCL_VERSION_MAJOR}${OpenCL_VERSION_MINOR}0
+)
+
 add_executable(test_tgt main.c)
 target_link_libraries(test_tgt OpenCL::OpenCL)
 add_test(NAME test_tgt COMMAND test_tgt)