@@ -423,8 +423,8 @@ project(PHP)
423423find_package(Iconv)
424424```
425425
426- Create a module with the same name in your local project CMake modules
427- directory. For example:
426+ Create a module with the same name in local project CMake modules directory. For
427+ example:
428428
429429``` cmake
430430# cmake/modules/FindIconv.cmake
@@ -433,26 +433,22 @@ directory. For example:
433433# example, adding search paths, changing initial values of the find module,
434434# adding pkgconf/pkg-config functionality, and similar.
435435
436- # Find package with upstream CMake module; override CMAKE_MODULE_PATH to prevent
437- # the maximum nesting/recursion depth error on some systems, like macOS.
438- set(_php_cmake_module_path ${CMAKE_MODULE_PATH})
439- unset(CMAKE_MODULE_PATH)
440- include(FindIconv)
441- set(CMAKE_MODULE_PATH ${_php_cmake_module_path})
442- unset(_php_cmake_module_path)
436+ # Find package with upstream CMake find module. Absolute path prevents the
437+ # maximum nesting/recursion depth error on some systems, like macOS.
438+ include(${CMAKE_ROOT}/Modules/FindIconv.cmake)
443439
444440# Here, find module can be customized after including the upstream module. For
445441# example, adding new result variables.
446442```
447443
448- With this, when calling the find_package(Iconv), the local FindIconv module will
449- be used and the upstream CMake module will be included in it, making it possible
450- to adjust code before and after the inclusion.
444+ With this, when calling the ` find_package(Iconv) ` , the local ` FindIconv ` module
445+ will be used and the upstream CMake module will be included in it, making it
446+ possible to adjust code before and after the inclusion.
451447
452- Instead of calling ` find_package() ` inside a find module, the ` include() ` can be
453- used and ` CMAKE_MODULE_PATH ` disabled . Otherwise, on some systems the maximum
454- nesting/recursion depth error occurs because CMake will try to include the
455- local FindIconv recursively.
448+ Instead of calling ` find_package() ` inside a find module, the ` include() ` is
449+ used with specific path to CMake modules . Otherwise, on some systems the maximum
450+ nesting/recursion depth error occurs because CMake will try to include the local
451+ ` FindIconv ` recursively.
456452
457453### 4.2. FetchContent
458454
0 commit comments