5d45fb0b687ece2f0c927dc5ae891ea449f4ba26
[platform/upstream/cmake.git] / Help / variable / CMAKE_FIND_PACKAGE_REDIRECTS_DIR.rst
1 CMAKE_FIND_PACKAGE_REDIRECTS_DIR
2 --------------------------------
3
4 .. versionadded:: 3.24
5
6 This read-only variable specifies a directory that the :command:`find_package`
7 command will check first before searching anywhere else for a module or config
8 package file.  A config package file in this directory will always be found in
9 preference to any other Find module file or config package file.
10
11 The primary purpose of this variable is to facilitate integration between
12 :command:`find_package` and :command:`FetchContent_MakeAvailable`.  The latter
13 command may create files in the ``CMAKE_FIND_PACKAGE_REDIRECTS_DIR`` directory
14 when it populates a dependency.  This allows subsequent calls to
15 :command:`find_package` for the same dependency to re-use the populated
16 contents instead of trying to satisfy the dependency from somewhere external
17 to the build.  Projects may also want to write files into this directory in
18 some situations (see :ref:`FetchContent-find_package-integration-examples`
19 for examples).
20
21 The directory that ``CMAKE_FIND_PACKAGE_REDIRECTS_DIR`` points to will always
22 be erased and recreated empty at the start of every CMake run.  Any files
23 written into this directory during the CMake run will be lost the next time
24 CMake configures the project.
25
26 ``CMAKE_FIND_PACKAGE_REDIRECTS_DIR`` is only set in CMake project mode.
27 It is not set when CMake is run in script mode
28 (i.e. :manual:`cmake -P ... <cmake(1)>`).