1CMAKE_FIND_PACKAGE_SORT_ORDER
2-----------------------------
3
4.. versionadded:: 3.7
5
6The default order for sorting packages found using :command:`find_package`.
7It can assume one of the following values:
8
9``NONE``
10  Default.  No attempt is done to sort packages.
11  The first valid package found will be selected.
12
13``NAME``
14  Sort packages lexicographically before selecting one.
15
16``NATURAL``
17  Sort packages using natural order (see ``strverscmp(3)`` manual),
18  i.e. such that contiguous digits are compared as whole numbers.
19
20Natural sorting can be employed to return the highest version when multiple
21versions of the same library are found by :command:`find_package`.  For
22example suppose that the following libraries have been found:
23
24* libX-1.1.0
25* libX-1.2.9
26* libX-1.2.10
27
28By setting ``NATURAL`` order we can select the one with the highest
29version number ``libX-1.2.10``.
30
31.. code-block:: cmake
32
33  set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
34  find_package(libX CONFIG)
35
36The sort direction can be controlled using the
37:variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION` variable
38(by default decrescent, e.g. lib-B will be tested before lib-A).
39