One may encounter warnings if FindPkgConfig is used in any project, even
indirectly, that has set any of these policies to old explicitely or requires
an older version.
When cross compiling from a unix machine, if(UNIX) is false,
whih causes the path not to be fixed for unix, leading to false
negative if PKG_CONFIG_PATH needs to be probed
pkg-config's .pc files can sometimes provide libraries that are visible to
the linker but not present in CMake's known search paths. In the case
where CMake can find some, but not all of the library dependencies
provided in a .pc file, this allows them to be passed through as "-lfoo"
when the full path can't be found.
This also removes the test failure cases that occured because of this
scenario and adjsuts the remaining tests to account for not-found
libraries
When running `pkg_search_module`, it may be useful to get the matching
module name in order to run `pkg_get_variable`.
`pkg_search_module` now defines `<prefix>_MODULE_NAME` which contains
the first matching module name.
Fixes: #19648
* The code snippets in the docs consist of CMake code mixed
with syntax definition punctuation like < > [ ] ... Therefore
a pure CMake lexer is inadequate. Here it is replaced by a
CMake syntax definition parser.
* Fixed syntax definition snippets in FindPkgConfig.cmake to
make best use of syntax highlighting. This source file is the
hardest to support because it contains comparison operators
<= = >=, which need special attention to avoid confusion
with the placeholder indicators <...>.
* Fixed syntax in execute_process.rst (there were unbalanced
brackets).
* Disabled syntax highlighting for long string examples in
cmake-language.7.rst.
* No highlighting of removed syntax in CMP0049
* To inspect the outcome of this patch, see e.g. the pages
* manual/cmake-buildsystem.7.html
* module/ExternalProject.html
* module/FindPkgConfig.html
which are particularly rich in complex code snippets.
`-L` in LDFLAGS doesn't mean that standard search paths should be
excluded. Example:
$ pkg-config --libs libmutter-2
-L/usr/lib/mutter -lmutter-2 -lgtk-3 -lgdk-3 -lmutter-clutter-2 -lcairo-gobject -latk-1.0 -lpangocairo-1.0 -lpango-1.0 -lfribidi -ljson-glib-1.0 -lgio-2.0 -lwayland-egl -lwayland-client -lXtst -lXi -lmutter-cogl-2 -lcairo
-lgmodule-2.0 -pthread -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lgbm -ldrm -lwayland-server -lEGL -lXext -lXdamage -lXfixes -lXcomposite -lXrandr -lX11
Most of these libraries are located at standard paths, not in
`/usr/lib/mutter`.
Fixes: #17954
The pkgconfig dir is placed at `${PREFIX}/libdata/pkgconfig` on FreeBSD
instead of `${PREFIX}/lib/pkgconfig`, where `${PREFIX}` is `/usr/local`
as default.
Since commit v3.8.0-rc1~47^2 (FindPkgConfig: Recheck pkg-config on
parameter change, 2017-01-17) calling `pkg_check_modules` always
re-runs. The problem is that if there are only 2 arguments passed to
`pkg_check_modules```, then `_module0` will be set and `ARGN` will be
empty. When this is written to cache it will be stored as just the
value of `_module0` without any semicolon, so on the next run this
doesn't match the expected value and the search is rerun.
Revise the logic to handle the case of empty `ARGN` separately.
Fixes: #17003
During search of the library file `pkg_check_modules()` attempts to find
it in last specified library path in `${_prefix}_LDFLAGS`, that after
dependency resolving contains path to standard location.
So in case when `${_prefix}_LDFLAGS` has:
-L/prefix;-L/usr/local/lib;-llibrary_from_prefix;-ldependency
`library_from_prefix` will not be found.
As solution need try to find the library in all paths preceding to the
library.
Fixes: #16873
Detect x32-abi through CMakeCompilerABI infrastruture and use this
information at runtime to determine the correct library paths with
`FIND_LIBRARY_USE_LIBX32_PATHS`.
Fixes: #15994
Currently, once pkg_check_modules succeeds, it will never call
_pkg_check_modules_internal again. That means that if the parameters
to pkg_check_modules are changed, cmake will be called to reconfigure,
but nothing will change. This change is to store the full string of
arguments to pkg_check_modules and override the FOUND optimization so
that the arguments are reevaluated when modified.
Calls like `pkg_check_modules(somelibrary>=3.22)` that specify a version
requirement should still display an informative error when the package
is not found. Fix our logic accordingly.
The options to the find_library call to create the imported target
used a literal string "HINTS /path NO_DEFAULT_PATH" instead of a
list of options. This resulted in never finding any library in my
testing.
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool. Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience. Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.
Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices. It also references version control
history for more precise information. Therefore we no longer need to spell
out the list of Contributors in each source file notice.
Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing". The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.
Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically. Manually fix up shebang lines and trailing
newlines in a few files. Manually update the notices in a few files that the
script does not handle.
Add a ``FIND_LIBRARY_USE_LIB32_PATHS`` global property analogous to the
``FIND_LIBRARY_USE_LIB64_PATHS`` property. This helps find commands on
multilib systems that use ``lib32`` directories and either do not have
``lib`` symlinks or point ``lib`` to ``lib64``.
The fix in commit v3.5.0-rc1~27^2 (FindPkgConfig: set standard variables
in the cache, 2016-01-20) added the wrong variable name to the cache.
The test was only testing that the cache variable existed, not that it
also had the correct value. Update the test to ensure that the cache
value matches the local variable value.
Reported-by: Bernd Lörwald
The original value is saved in `_pkg_config_path_old`. Fix this typo
left by commit v3.1.0-rc1~763^2 (FindPkgConfig: Extend PKG_CONFIG_PATH
using CMake variables, 2014-03-06).
Most packages install their .pc files into PREFIX/lib/pkgconfig, but
some put them into PREFIX/share/pkgconfig. Either is valid, and
pkg-config itself looks in both for the /usr and /usr/local prefixes.
This fixes an issue where some packages (yajl, for example) are not
found if they are installed into a non-standard prefix and
CMAKE_PREFIX_PATH is used to locate them.
In some cases, CMake returned the following error:
-- Checking for module 'foo'
-- Package 'foo' not found
When the actual error returned by pkg-config was:
Package 'bar', required by 'foo', not found
Now, the actual error is forwarded to the user.
-- Checking for module 'foo'
-- Package 'bar', required by 'foo', not found
For the standard case (i.e. the package was indeed not found), the
CMake error was:
-- Checking for module 'foo'
-- Package 'foo' not found
But it now prints:
-- Checking for module 'foo'
-- No package 'foo' found
The associated test was also updated. ${last} refers to the last
CLI argument.
If CMAKE_MINIMUM_REQUIRED_VERSION is not set because no
cmake_minimum_required() call is present this line can lead to an error as that
string is empty so too few arguments are passed to if():
See also "/var/tmp/paludis/build/kde-krdc-15.08.0/work/build/CMakeFiles/CMakeOutput.log".
See also "/var/tmp/paludis/build/kde-krdc-15.08.0/work/build/CMakeFiles/CMakeError.log".
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:112 (elseif):
given arguments:
"VERSION_LESS" "3.1"
Unknown arguments specified
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPkgConfig.cmake:501 (_pkgconfig_parse_options)
/usr/share/cmake/Modules/FindOpenSSL.cmake:43 (pkg_check_modules)
The CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH cache variables are
supposed to be used to generate the extra paths passed to pkg-config,
but instead the CMAKE_PREFIX_PATH variable is used.
This bug was introduced by the refactor in commit v3.1.0-rc1~747^2~1.
The matches have already been calculated and can simply be taken from
CMAKE_MATCH_n variables. This avoids multiple compilations of the same or very
similar regular expressions.