Commit Graph

52 Commits

Author SHA1 Message Date
Shin-ya Murakami
07a4be0d9c FindPkgConfig: On FreeBSD search in libdata/pkgconfig
The pkgconfig dir is placed at `${PREFIX}/libdata/pkgconfig` on FreeBSD
instead of `${PREFIX}/lib/pkgconfig`, where `${PREFIX}` is `/usr/local`
as default.
2017-08-07 10:51:16 -04:00
Rolf Eike Beer
3cf267cfbf FindPkgConfig: do not always rerun pkg_check_modules() with 2 arguments
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
2017-07-10 11:16:51 -04:00
Rolf Eike Beer
70a6cb70f6 FindPkgConfig: mention that variables will be ;-lists 2017-06-12 22:03:20 +02:00
Rolf Eike Beer
6610fdbed2 FindPkgConfig: fix confusing indentation 2017-06-12 22:03:20 +02:00
Yuriy Khokhulya
2e293c39da FindPkgConfig: Fix pkg_check_modules() non-standard location search
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
2017-05-12 09:21:21 -04:00
Steven Newbury
462cf25427 Add support for x32-abi
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
2017-03-07 15:22:55 -05:00
Gautier Pelloux-Prayer
8d71fa9283 FindPkgConfig: use new version checking "library >= version" syntax
Instead of the deprecated --atleast-version one.
2017-02-28 10:45:25 +01:00
Matthew Hanna
796dea67a6 FindPkgConfig: Recheck pkg-config on parameter change.
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.
2017-01-24 22:02:14 -05:00
Gautier Pelloux-Prayer
cbccebbac9 FindPkgConfig: Fix missing error text when library version is specified
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.
2016-11-28 16:18:07 -05:00
Florent Castelli
61898de641 PkgConfig: Fix FindPkgConfig imported target feature
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.
2016-11-04 23:35:27 +01:00
Brad King
86578eccf2 Simplify CMake per-source license notices
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.
2016-09-27 15:14:44 -04:00
Daniel Pfeifer
5d0d980d99 Use string(APPEND) in Modules
Automate with:

find Modules -type f -print0 | xargs -0 perl -i -0pe \
's/set\(([a-zA-Z0-9_]+)(\s+)"\$\{\1\}([^"])/string(APPEND \1\2"\3/g'
2016-07-28 00:41:13 +02:00
Brad King
95c5e00186 Merge topic 'pkgconfig-targets'
8345c646 FindPkgConfig: define the imported targets also when the data comes from cache
2016-06-20 09:55:59 -04:00
Rolf Eike Beer
8345c6463d FindPkgConfig: define the imported targets also when the data comes from cache 2016-06-19 09:35:05 +02:00
Daniel Scharrer
896ad251de Teach find_library and find_package to search lib32 paths (#11260)
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``.
2016-06-10 11:09:16 -04:00
Rolf Eike Beer
df97b9793f FindPkgConfig: optionally create imported target for the found libraries 2016-05-14 09:31:41 +02:00
Ben Boeckel
6f4f905483 FindPkgConfig: set correctly named variables in cache (#15903)
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
2016-03-21 08:58:12 -04:00
Ben Boeckel
40249bccdf FindPkgConfig: set standard variables in the cache
Fixes a regression introduced when the code was simplified to use the
variable queries.

Fixes #15903.

Reported-by: Bernd Lörwald
2016-01-21 10:38:30 -05:00
Rob Gowin
53511936e4 FindPkgConfig: Quote ${_pkgconfig_path} to protect semicolons on Windows 2016-01-19 09:39:04 -05:00
Rob Gowin
8979a10700 FindPkgConfig: Fix restoration of PKG_CONFIG_PATH in environment
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).
2016-01-15 15:12:34 -05:00
Sam Thursfield
36d87e18a1 FindPkgConfig: add PREFIX/share/pkgconfig to PKG_CONFIG_PATH (#15910)
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.
2016-01-12 13:42:17 -05:00
Benjamin Chrétien
1bfb527f56 FindPkgConfig: return actual error when a package is not found (#15810)
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.
2015-10-28 10:18:15 -04:00
Ben Boeckel
51b83f1445 FindPkgConfig: add a command to query arbitrary variables 2015-09-21 09:39:26 -04:00
Ben Boeckel
7f7f1eecfd FindPkgConfig: use execute_process to strip trailing whitespace 2015-09-17 21:08:19 -04:00
Rolf Eike Beer
b9ec9392da FindPkgConfig: remove variable dereference
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)
2015-08-18 12:14:43 +02:00
Christopher Meng
50c9f521e2 FindPkgConfig: Capitalize first letter of all message()s
This makes FindPkgConfig output more formal and more consistent with
many other messages produced by CMake.
2015-08-12 09:24:44 -04:00
Daniele E. Domenichelli
d4c6531a94 FindPkgConfig: Fix extra paths for CMAKE_{FRAMEWORK,APPBUNDLE}_PATH vars
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.
2015-05-29 19:22:57 +02:00
Daniele E. Domenichelli
a7631fc4e0 Modules: Check for ARGC before using ARGV#
ARGV# could be defined from a parent scope.
2015-02-27 10:59:23 -05:00
Brad King
20c5f4fbd9 Modules: Wrap long lines in pre-formatted documentation blocks
Help format the blocks better for display without a wide screen.
2014-11-06 14:52:26 -05:00
Rolf Eike Beer
2622bc3f65 Clean up usage of if(... MATCHES regex) followed string(REGEX REPLACE regex)
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.
2014-04-14 18:16:58 +02:00
Christoph Grüninger
63a4c0af31 FindPkgConfig: Stop processing when REQUIRED package not found (#14381)
Make the behavior similar to find_package.
2014-03-24 08:57:31 -04:00
Daniele E. Domenichelli
453d2b2438 FindPkgConfig: small refactoring 2014-03-17 17:50:35 +01:00
Daniele E. Domenichelli
3df5147043 FindPkgConfig: Extend PKG_CONFIG_PATH using CMake variables (#12926)
Use CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, and CMAKE_APPBUNDLE_PATH
cache and environment variables to extend PKG_CONFIG_PATH before calling
pkg-config.

In each of the path in these variables it searches for lib/pkgconfig.
Then, depending on the system, it searches for
lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig (debian) or for
lib64/pkgconfig (other 64 bit unixes). If any of these path is found,
it is appended to the PKG_CONFIG_PATH enviromnent variable.

Add two new arguments to the pkg_check_module and pkg_search_module
macro, NO_CMAKE_PATH and NO_CMAKE_ENVIRONMENT_PATH. The new signature
are therefore:

   pkg_check_modules(<PREFIX> [REQUIRED] [QUIET]
                     [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH]
                     <MODULE> [<MODULE>]*)
   pkg_search_module(<PREFIX> [REQUIRED] [QUIET]
                     [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH]
                     <MODULE> [<MODULE>]*)

By default, if CMAKE_MINIMUM_REQUIRED_VERSION is 3.1 or later (in
order to keep compatibility with the previous behavior), or if
PKG_CONFIG_USE_CMAKE_PREFIX_PATH is set, the CMAKE_PREFIX_PATH,
CMAKE_FRAMEWORK_PATH, and CMAKE_APPBUNDLE_PATH cache and environment
variables will be added to pkgconfig search path.

The NO_CMAKE_PATH and NO_CMAKE_ENVIRONMENT_PATH arguments disable this
behavior for the cache variables and the environment variables,
respectively, similarly to the find_package() command.
2014-03-17 09:43:08 -04:00
Daniele E. Domenichelli
49ef91d7a6 FindPkgConfig: restructure documentation and document commands and variables 2014-03-10 18:27:46 +01:00
Christoph Grüninger
c53b5cd221 FindPkgConfig: Prefer PKG_CONFIG to find pkg-config (#13175)
If the environment variable PKG_CONFIG is set, use this as the
default pkg-config executable.
2014-02-27 10:29:01 -05:00
Kitware Robot
f051814ed0 Convert builtin help to reStructuredText source files
Run the convert-help.bash script to convert documentation:

 ./convert-help.bash "/path/to/CMake-build/bin"

Then remove it.
2013-10-15 14:12:03 -04:00
Kitware Robot
9db3116226 Remove CMake-language block-end command arguments
Ancient versions of CMake required else(), endif(), and similar block
termination commands to have arguments matching the command starting the
block.  This is no longer the preferred style.

Run the following shell code:

for c in else endif endforeach endfunction endmacro endwhile; do
    echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
egrep -z -v 'Tests/CMakeTests/While-Endwhile-' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
2012-08-13 14:19:16 -04:00
Kitware Robot
7bbaa4283d Remove trailing whitespace from most CMake and C/C++ code
Our Git commit hooks disallow modification or addition of lines with
trailing whitespace.  Wipe out all remnants of trailing whitespace
everywhere except third-party code.

Run the following shell code:

git ls-files -z -- \
 bootstrap doxygen.config '*.readme' \
 '*.c' '*.cmake' '*.cpp' '*.cxx' \
 '*.el' '*.f' '*.f90' '*.h' '*.in' '*.in.l' '*.java' \
 '*.mm' '*.pike' '*.py' '*.txt' '*.vim' |
egrep -z -v '^(Utilities/cm|Source/(kwsys|CursesDialog/form)/)' |
egrep -z -v '^(Modules/CPack\..*\.in)' |
xargs -0 sed -i 's/ \+$//'
2012-08-13 14:18:39 -04:00
Rolf Eike Beer
3ea850a502 FindPkgConfig.cmake: fix documented output variable not set (#13125,#13132)
The real fix is from Yury G. Kudryashov while I added the surrounding cleanups.
An additional hint to really get this fixed came from Rex Dieter.
2012-04-15 08:39:51 +02:00
Rolf Eike Beer
27501155c7 FindPkgConfig: support version selection of pkg-config itself 2012-02-18 11:57:38 +01:00
Yury G. Kudryashov
55c3435d88 FindPkgConfig: respect REQUIRED (#12620)
find_package(PkgConfig REQUIRED) now fails if pkg-config is not found.
2012-01-20 08:33:51 -05:00
Todd Gamblin
2cde67a781 Modules: Fix spelling 'To distributed' -> 'To distribute' 2010-08-09 08:48:31 -04:00
Alex Neundorf
af3a288e55 -add QUIET keyword to pkgconfig macros
Synced from KDE svn: pkg_check_modules() and pkg_search_module() now
both support a QUIET keyword. When given, no messages will be printed (except the REQUIRED ones)

This also fixes #10469 (confusing output of FindLibXml2.cmake)

Alex
2010-05-08 10:36:42 +02:00
Brad King
940733997a Remove old license from FindPkgConfig.cmake module
This module was contributed under a BSD-like license.  We added CMake's
OSI-approved BSD License on top of it.  With the author's permission,
this commit removes the old license text and puts the author's copyright
notice in the block referring to the new license.
2009-10-05 09:13:29 -04:00
Brad King
c4bb9c9d42 Convert CMake find-modules to BSD License
This adds copyright/license notification blocks CMake's find-modules.
Many of the modules had no notices at all.  Some had notices referring
to the BSD license already.  This commit normalizes existing notices and
adds missing notices.
2009-09-28 11:45:50 -04:00
Bill Hoffman
4f44c7875f BUG: fix for bug 6117 pkgconfig 2008-02-07 13:19:38 -05:00
Bill Hoffman
1cfe812f11 BUG: fix for 5722 2007-12-17 21:37:16 -05:00
Bill Hoffman
a488c2646c BUG: fix for 6117, fix for second run 2007-12-14 12:51:43 -05:00
Alexander Neundorf
1410eef27a STYLE: fix typo
Alex
2007-08-26 02:42:46 -04:00
Bill Hoffman
ff6146334c ENH: better backwards compatibility, and deprecate PKGCONFIG 2006-12-09 15:02:19 -05:00