Kaynağa Gözat

Merge topic 'cmake-module-path-example'

8763da8268 Help: Provide simple CMAKE_MODULE_PATH example

Acked-by: Kitware Robot <[email protected]>
Merge-request: !9498
Brad King 1 yıl önce
ebeveyn
işleme
a6aac9b96d
1 değiştirilmiş dosya ile 14 ekleme ve 1 silme
  1. 14 1
      Help/variable/CMAKE_MODULE_PATH.rst

+ 14 - 1
Help/variable/CMAKE_MODULE_PATH.rst

@@ -5,4 +5,17 @@ CMAKE_MODULE_PATH
 represented using forward slashes, specifying a search path for CMake modules
 to be loaded by the :command:`include` or :command:`find_package` commands
 before checking the default modules that come with CMake. By default it is
-empty.  It is intended to be set by the project.
+empty. It is intended to be set by the project.
+
+It's fairly common for a project to have a directory containing various
+``*.cmake`` files to assist in development. Adding the directory to the
+:variable:`CMAKE_MODULE_PATH` simplifies loading them. For example, a
+project's top-level ``CMakeLists.txt`` file may contain:
+
+.. code-block:: cmake
+
+  list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+  include(Foo) # Loads ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Foo.cmake
+
+  find_package(Bar) # Loads ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindBar.cmake