summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-16 14:21:17 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-09-16 14:21:17 (GMT)
commit38a378e10d93740c11ac713c6035e26d6838ad96 (patch)
treeac9275461a775d47b371392b6e56196fba681082 /Help
parent3efb3c0012a05ce1f19c99fb27b835c3ec057270 (diff)
parent31be918b0b2dd445bdf85d72a8eaa29841137bc8 (diff)
downloadCMake-38a378e10d93740c11ac713c6035e26d6838ad96.zip
CMake-38a378e10d93740c11ac713c6035e26d6838ad96.tar.gz
CMake-38a378e10d93740c11ac713c6035e26d6838ad96.tar.bz2
Merge topic 'find_package-dir-sort'
31be918b find_package: Optionally sort globbed directories in a meaningful order
Diffstat (limited to 'Help')
-rw-r--r--Help/command/find_package.rst18
-rw-r--r--Help/manual/cmake-variables.7.rst2
-rw-r--r--Help/release/dev/find_package-dir-sort.rst13
-rw-r--r--Help/variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION.rst16
-rw-r--r--Help/variable/CMAKE_FIND_PACKAGE_SORT_ORDER.rst36
5 files changed, 81 insertions, 4 deletions
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst
index c44fe86..2cb1e5f 100644
--- a/Help/command/find_package.rst
+++ b/Help/command/find_package.rst
@@ -170,11 +170,21 @@ is acceptable the following variables are set:
``<package>_VERSION_COUNT``
number of version components, 0 to 4
-and the corresponding package configuration file is loaded. When
-multiple package configuration files are available whose version files
+and the corresponding package configuration file is loaded.
+When multiple package configuration files are available whose version files
claim compatibility with the version requested it is unspecified which
-one is chosen. No attempt is made to choose a highest or closest
-version number.
+one is chosen: unless the variable :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER`
+is set no attempt is made to choose a highest or closest version number.
+
+To control the order in which ``find_package`` checks for compatibiliy use
+the two variables :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` and
+:variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION`.
+For instance in order to select the highest version one can set::
+
+ SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
+ SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
+
+before calling ``find_package``.
Config mode provides an elaborate interface and search procedure.
Much of the interface is provided for completeness and for use
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 74c9265..9e0efe9 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -38,6 +38,8 @@ Variables that Provide Information
/variable/CMAKE_EXTRA_GENERATOR
/variable/CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES
/variable/CMAKE_FIND_PACKAGE_NAME
+ /variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION
+ /variable/CMAKE_FIND_PACKAGE_SORT_ORDER
/variable/CMAKE_GENERATOR
/variable/CMAKE_GENERATOR_PLATFORM
/variable/CMAKE_GENERATOR_TOOLSET
diff --git a/Help/release/dev/find_package-dir-sort.rst b/Help/release/dev/find_package-dir-sort.rst
new file mode 100644
index 0000000..67b93eb
--- /dev/null
+++ b/Help/release/dev/find_package-dir-sort.rst
@@ -0,0 +1,13 @@
+find_package-dir-sort
+---------------------
+
+* The :command:`find_package` command gained the possibility of
+ sorting compatible libraries by ``NAME`` or by ``NATURAL`` sorting by
+ setting the two new variables :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER`
+ and :variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION`.
+
+* Variable :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` was added to control
+ the sorting mode of the :command:`find_package` command.
+
+* Variable :variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION` was added to control
+ the sorting direction the :command:`find_package` command.
diff --git a/Help/variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION.rst b/Help/variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION.rst
new file mode 100644
index 0000000..99e4ec1
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION.rst
@@ -0,0 +1,16 @@
+CMAKE_FIND_PACKAGE_SORT_DIRECTION
+---------------------------------
+
+The sorting direction used by :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER`.
+It can assume one of the following values:
+
+``DEC``
+ Default. Ordering is done in descending mode.
+ The highest folder found will be tested first.
+
+``ASC``
+ Ordering is done in ascending mode.
+ The lowest folder found will be tested first.
+
+If :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` is not set or is set to ``NONE``
+this variable has no effect.
diff --git a/Help/variable/CMAKE_FIND_PACKAGE_SORT_ORDER.rst b/Help/variable/CMAKE_FIND_PACKAGE_SORT_ORDER.rst
new file mode 100644
index 0000000..ba5f3a8
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_PACKAGE_SORT_ORDER.rst
@@ -0,0 +1,36 @@
+CMAKE_FIND_PACKAGE_SORT_ORDER
+-----------------------------
+
+The default order for sorting packages found using :command:`find_package`.
+It can assume one of the following values:
+
+``NONE``
+ Default. No attempt is done to sort packages.
+ The first valid package found will be selected.
+
+``NAME``
+ Sort packages lexicographically before selecting one.
+
+``NATURAL``
+ Sort packages using natural order (see ``strverscmp(3)`` manual),
+ i.e. such that contiguous digits are compared as whole numbers.
+
+Natural sorting can be employed to return the highest version when multiple
+versions of the same library are found by :command:`find_package`. For
+example suppose that the following libraries have been found:
+
+* libX-1.1.0
+* libX-1.2.9
+* libX-1.2.10
+
+By setting ``NATURAL`` order we can select the one with the highest
+version number ``libX-1.2.10``.
+
+.. code-block:: cmake
+
+ set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
+ find_package(libX CONFIG)
+
+The sort direction can be controlled using the
+:variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION` variable
+(by default decrescent, e.g. lib-B will be tested before lib-A).