Selaa lähdekoodia

CMakeFindPackageMode: Move documentation to --find-package option

- This moves the CMakeFindPackageMode internal module documentation to
  the --find-package option as this module itself cannot be used by the
  project.
- Additionally, some links added.
- The `QUIET` variable renamed in documentation to `SILENT` to be
  effective according to the current code.
Peter Kokot 7 kuukautta sitten
vanhempi
sitoutus
e9b86f5618
3 muutettua tiedostoa jossa 53 lisäystä ja 29 poistoa
  1. 42 5
      Help/manual/cmake.1.rst
  2. 2 2
      Help/prop_gbl/CMAKE_ROLE.rst
  3. 9 22
      Modules/CMakeFindPackageMode.cmake

+ 42 - 5
Help/manual/cmake.1.rst

@@ -1389,15 +1389,52 @@ CMake provides a pkg-config like helper for Makefile-based projects:
 
   cmake --find-package [<options>]
 
-It searches a package using :command:`find_package()` and prints the
-resulting flags to stdout.  This can be used instead of pkg-config
-to find installed libraries in plain Makefile-based projects or in
-autoconf-based projects (via ``share/aclocal/cmake.m4``).
-
 .. note::
   This mode is not well-supported due to some technical limitations.
   It is kept for compatibility but should not be used in new projects.
 
+.. option:: --find-package
+
+  It searches a package using the :command:`find_package` command and prints the
+  resulting flags to stdout.  This can be used instead of pkg-config to find
+  installed libraries in plain Makefile-based projects or in Autoconf-based
+  projects, using auxiliary macros installed in ``share/aclocal/cmake.m4`` on
+  the system.
+
+  When using this option, the following variables are expected:
+
+  ``NAME``
+    Name of the package as called in ``find_package(<PackageName>)``.
+
+  ``COMPILER_ID``
+    :variable:`Compiler ID <CMAKE_<LANG>_COMPILER_ID>` used for searching the
+    package, i.e. GNU/Intel/Clang/MSVC, etc.
+
+  ``LANGUAGE``
+    Language used for searching the package, i.e. C/CXX/Fortran/ASM, etc.
+
+  ``MODE``
+    The package search mode.  Value can be one of:
+
+    ``EXIST``
+      Only checks for existence of the given package.
+
+    ``COMPILE``
+      Prints the flags needed for compiling an object file which uses the given
+      package.
+
+    ``LINK``
+      Prints the flags needed for linking when using the given package.
+
+  ``SILENT``
+    (Optional) If TRUE, find result message is not printed.
+
+  For example:
+
+  .. code-block:: shell
+
+    cmake --find-package -DNAME=CURL -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
+
 .. _`Workflow Mode`:
 
 Run a Workflow Preset

+ 2 - 2
Help/prop_gbl/CMAKE_ROLE.rst

@@ -10,10 +10,10 @@ values:
   Running in project mode (processing a ``CMakeLists.txt`` file).
 
 ``SCRIPT``
-  Running in ``-P`` script mode.
+  Running in :ref:`cmake -P <Script Processing Mode>` script mode.
 
 ``FIND_PACKAGE``
-  Running in ``--find-package`` mode.
+  Running in :ref:`cmake --find-package <Find-Package Tool Mode>` mode.
 
 ``CTEST``
   Running in CTest script mode.

+ 9 - 22
Modules/CMakeFindPackageMode.cmake

@@ -5,28 +5,15 @@
 CMakeFindPackageMode
 --------------------
 
-This file is executed by cmake when invoked with
-:ref:`--find-package <Find-Package Tool Mode>`.
-It expects that the following variables are set using ``-D``:
-
-``NAME``
-  name of the package
-``COMPILER_ID``
-  the CMake compiler ID for which the result is,
-  i.e. GNU/Intel/Clang/MSVC, etc.
-``LANGUAGE``
-  language for which the result will be used,
-  i.e. C/CXX/Fortran/ASM
-``MODE``
-  ``EXIST``
-    only check for existence of the given package
-  ``COMPILE``
-    print the flags needed for compiling an object file which uses
-    the given package
-  ``LINK``
-    print the flags needed for linking when using the given package
-``QUIET``
-  if TRUE, don't print anything
+This module is executed by ``cmake`` when invoked with the
+:ref:`--find-package <Find-Package Tool Mode>` option to locate the requested
+package.
+
+.. note::
+
+  This is internal module and is not meant to be included directly in the
+  project.  For usage details, refer to the :ref:`--find-package
+  <Find-Package Tool Mode>` documentation.
 #]=======================================================================]
 
 if(NOT NAME)