Commit Graph

107 Commits

Author SHA1 Message Date
Roger Leigh
99c8abed55 kFreeBSD: Remove support for obsolete platform
kFreeBSD is no longer maintained or supported and was never an
officially-supported release architecture for Debian.

Closes: #26742
2025-03-05 11:57:49 -05:00
Kitware Robot
1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Brad King
7afa58b15d Modules/Find*: Include FindPackageHandleStandardArgs normally
Since commit d74210a8bd (CMP0017: Remove support for OLD behavior,
2024-11-17) we can rely on CMP0017's NEW behavior unconditionally.
Calling `include(FindPackageHandleStandardArgs)` in a builtin module
will always get the builtin `FindPackageHandleStandardArgs`.
2025-01-30 08:53:12 -05:00
Peter Kokot
4e6a13f211 Use lower case style for commands
Where possible this syncs the CS for command names:

- check_c_source_compiles()
- check_cxx_compiler_flag()
- check_cxx_source_compiles()
- check_cxx_symbol_exists()
- check_include_file_cxx()
- check_include_file()
- check_include_files()
- check_library_exists()
- check_source_compiles()
- check_struct_has_member()
- check_symbol_exists()
- check_type_size()
- cmake_dependent_option()
- cmake_parse_arguments()
- feature_summary()
- file()
- find_package_handle_standard_args()
- if(), endif...
- install(FILES)
- list()
- message()
- pkg_check_modules()
- select_library_configurations()
- set_package_info()
- test_big_endian()
2025-01-28 13:51:46 -05:00
Brad King
c283aafe62 CMP0057: Remove support for OLD behavior 2025-01-22 10:40:53 -05:00
Brad King
90d814f024 CMP0054: Remove support for OLD behavior 2025-01-20 09:46:55 -05:00
FeRD (Frank Dana)
c14a9c4648 Help: Correct FindPkgConfig version tags
Two features in FindPkgConfig were added in a CMake version where
they were initially broken, and could only be used once the
implementation was fixed in a later version.

Previously, the docs contained a `.. versionadded` tag denoting the
version where the _broken_ implementation was introduced (its true
"version added", if we're being literal), with a comment in the
documentation source noting that the feature didn't actually work
correctly until whatever later version the comment specifies.

Since that's completely backwards, from a user perspective, reverse
the documentation so that the `.. versionadded` message shows when
the feature first worked **correctly**, with a comment noting that
support was technically introduced in an earlier version, but in a
broken/nonfunctioning state.
2024-11-19 02:23:25 -05:00
Kerem Aksu
9ddef32ba0 FindPkgConfig: Fix parsing of quoted lists with pkgconf <1.5.1
Unquote pkg-config output if they are printed within quotes. pkgconf
<1.5.1 and classic pkg-config <0.29.1 prints quoted variables without
unquoting them, this breaks returning variables with multiple values
as a list behavior of CMake.

Add a new test case for pkg_get_variable with multiple values to test
list behavior and backslash escaped spaces within variable values.

Fixes: #25904
2024-04-20 21:03:56 +03:00
Brad King
d0dd134bdb FindPkgConfig: Avoid finding Strawberry Perl's pkg-config
Strawberry Perl may be in the `PATH` to provide `perl`, but it also
comes with a `pkg-config` tool that is unrelated to normal MinGW
distributions.  Since commit c6efbd78d8 (MSVC: Teach find_library to
consider the 'libfoo.a' naming convention, 2024-01-19, v3.29.0-rc1~91^2)
we need to avoid searching Strawberry Perl's `.../c/lib` directory, so
do not let its `pkg-config` point us there.

Fixes: #25820
Issue: #23975
2024-03-26 08:51:32 -04:00
Kai Pastor
e50aaf8547 FindPkgConfig: Update cache variables after isystem extraction
Fixes: #25377
2024-01-04 22:22:52 +01:00
Kai Pastor
8fe6196714 FindPkgConfig: Update cache variables after framework extraction 2023-12-28 09:57:47 +01:00
Anthony Baker
4c96b31e4b FindPkgConfig: Report not-found package names in fatal error message 2023-10-03 11:59:12 -04:00
Corentin Noël
e0d00b9218 FindPkgConfig: Allow to override variables when calling pkg_get_variable
This is specifically useful when building applications within containers as we
sometimes need to redefine the prefix used in a variable.
2023-09-19 09:08:48 +02:00
Paul Zander
d47771bbb9 FindPkgConfig: ignore whitespace separators in version check
The regex used to split up the version if it contains an operator fails
if the string contains whitespaces. Resulting in an extra whitespace
after the package name and before the package version leading to
breakage in pkgconf and thus webkit-gtk.

See:
https://github.com/pkgconf/pkgconf/issues/317
https://bugs.webkit.org/show_bug.cgi?id=261125
https://bugs.gentoo.org/913644
2023-09-09 13:49:19 +02:00
Cristian Le
252c66c697 FindPkgConfig: Tolerate PKG_CONFIG_SYSTEM_INCLUDE_PATH in environment
Tell `pkg-config --cflags` not to filter out `-I` flags for entries of
`PKG_CONFIG_SYSTEM_INCLUDE_PATH` (and `CPATH` for `pkgconf`).

Fixes: #25228
2023-09-06 12:17:39 -04:00
Brad King
7e4adcac82 FindPkgConfig: Revert "Populate _STATIC_LINK_LIBRARIES. Add STATIC_TARGET."
Revert commit 020976d637 (FindPkgConfig: Populate
_STATIC_LINK_LIBRARIES. Add STATIC_TARGET., 2021-12-31,
v3.24.0-rc1~105^2).  Several regressions have been reported.
Revert the feature pending further discussion and design work.

Issue: #21714
Fixes: #23642
2022-06-22 10:13:00 -04:00
Brad King
1b30958719 Merge topic 'pkgconfig-static-libs'
020976d637 FindPkgConfig: Populate _STATIC_LINK_LIBRARIES. Add STATIC_TARGET.
3c5cc79adb Tests: De-duplicate some code in RunCMake.FindPkgConfig
5cfbc76371 FindPkgConfig: Fix parsing of backslash-escaped spaces in pkg-config output

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7070
2022-05-23 09:01:00 -04:00
Alex Birch
020976d637 FindPkgConfig: Populate _STATIC_LINK_LIBRARIES. Add STATIC_TARGET.
Add LINK_LIBRARIES test to demonstrate static linking of transitive
dependencies.

Add STATIC_TARGET argument to pkg_check_modules() and pkg_search_module().
Influences the properties of target produced by IMPORTED_TARGET.
When enabled: target's properties will be populated from <XXX>_STATIC_*
variables instead of from <XXX>_* variables.

Update existing tests concerning properties of targets produced via
IMPORTED_TARGET, to test STATIC_TARGET variant too.
Update existing tests concerning <XXX>_* variables to test <XXX>_STATIC_*
variables too.

Breaking changes to pkg_check_modules() and pkg_search_module():
- Variables CMAKE_FIND_LIBRARY_PREFIXES and CMAKE_FIND_LIBRARY_SUFFIXES can no
longer be used to influence library lookup (i.e. the internal call to
find_library()), because FindPkgConfig now internally relies on these
variables to differentiate between shared and static library lookup.
Prefer CMAKE_SHARED_LIBRARY_PREFIX + CMAKE_SHARED_LIBRARY_SUFFIX, or
CMAKE_STATIC_LIBRARY_PREFIX + CMAKE_STATIC_LIBRARY_SUFFIX, depending on
whether you wish to impact static or shared lookup.
- <XXX>_LINK_LIBRARIES will now be populated only with libraries
located via CMAKE_SHARED_LIBRARY_PREFIX + CMAKE_SHARED_LIBRARY_SUFFIX match
- <XXX>_STATIC_LIBRARIES now processes -framework options
- <XXX>_STATIC_LDFLAGS_OTHER now processes -framework options
- <XXX>_STATIC_CFLAGS_OTHER now processes -isystem options
- <XXX>_STATIC_INCLUDE_DIRS now processes -isystem options

Fixes: #21714
2022-05-20 09:45:12 -04:00
Brad King
11c8da94d4 FindPkgConfig: Fix preservation of ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS}
Fix the ENV save/restore added by commit 36979f5b43 (FindPkgConfig:
Tolerate PKG_CONFIG_SYSTEM_LIBRARY_PATH in environment, 2021-07-13,
v3.22.0-rc1~407^2) to unset the variable if it was originally not set.

While at it, clarify the value to which we temporarily set it. The
`pkg-config` and `pkgconf` tools only check that the variable is set,
and do not care about the value.  Set it to a more true-looking value.

Issue: #22148
2022-05-12 13:18:24 -04:00
Alex Birch
5cfbc76371 FindPkgConfig: Fix parsing of backslash-escaped spaces in pkg-config output
Treat backslash-escaped spaces as "space within argument" rather than
"space delimiting arguments".

Update our `FindPkgConfig_LIBRARY_PATH` test case to escape spaces in
the path, and run it unconditionally.
2022-05-12 12:26:04 -04:00
Brad King
90a49647e9 FindPkgConfig: Restore finding pkg-config before pkgconf
Since commit 94a84dc0af (FindPkgConfig: add pkgconf to the search list.,
2021-07-02, v3.22.0-rc1~468^2), `pkgconf` is preferred over `pkg-config`
if they appear in the same directory.  In some environments,
`pkg-config` may be a wrapper that adds semantics beyond either
`pkgconf` or the normal `pkg-config`.  Prefer `pkg-config` over
`pkgconf` in order to preserve the prior behavior in such environments.

Fixes: #22976
2021-12-02 12:38:22 -05:00
Craig Scott
76c0281421 Help: Clarify how PKG_CONFIG env var initializes cache vars
Fixes: #22870
2021-11-07 16:09:42 +11:00
Brad King
135e79038c Merge topic 'FindPkgConfig-restore-legacy-behavior'
17e4934dbf FindPkgConfig: Restore legacy behavior when CMP0126 is set to NEW

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6461
2021-08-19 10:27:24 -04:00
Marc Chevrier
17e4934dbf FindPkgConfig: Restore legacy behavior when CMP0126 is set to NEW
Module behavior must be independent from `CMP0126` policy.

Fixes: #22526
2021-08-18 14:51:50 -04:00
Brad King
36979f5b43 FindPkgConfig: Tolerate PKG_CONFIG_SYSTEM_LIBRARY_PATH in environment
Tell `pkg-config --libs` not to filter out `-L` flags for entries of
`PKG_CONFIG_SYSTEM_LIBRARY_PATH` (and `LIBRARY_PATH` for `pkgconf`).
We should always search everywhere the `.pc` file expects.

Fixes: #22148
2021-07-13 10:33:16 -04:00
Alexander Neumann
94a84dc0af FindPkgConfig: add pkgconf to the search list. 2021-07-02 17:06:31 +02:00
Christopher Degawa
35d3e00e4e FindPkgConfig: split args if loaded from environment
It's common for some people to use the PKG_CONFIG environment variable
to not only load a custom pkg-config/pkgconf but also to load some
default arguments such as `--static` or `--keep-system-libs` which often
worked since shell scripts would call `$PKG_CONFIG --libs pkg` without
quotes, but this breaks FindPkgConfig since it uses the full string as
`argv[0]` and might try looking for a binary called `pkgconf --static`,
instead of looking for `pkgconf` and adding `--static` as the `argv[1]`

Additionally adds RunCMake.FindPkgConfig ARGN test case

Fixes: #22305
Signed-off-by: Christopher Degawa <ccom@randomderp.com>
2021-06-18 11:10:12 -04:00
Adam Badura
6f14205e08 FindPkgConfig: Always create the imported target
Fixes: #22180
2021-06-04 08:33:27 -04:00
Brad King
87c6fe4997 Merge topic 'FindPkgConfig-NAMES_PER_DIR'
c7bd2d0d97 FindPkgConfig: Restore preference for first pkg-config in PATH

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5914
2021-03-17 09:38:47 -04:00
Brad King
c7bd2d0d97 FindPkgConfig: Restore preference for first pkg-config in PATH
Since commit ab8bd48352 (FindPkgConfig: Search for pkg-config.bat file
on a Windows host, 2020-09-25, v3.19.0-rc1~98^2) we prefer
`pkg-config.bat` over `pkg-config` regardless of the order they appear
in the `PATH`.  Tell `find_program` to consider all names in each
directory so that the first one in `PATH` of any name wins.

Issue: #21239
2021-03-16 09:04:56 -04:00
Nikita Nemkin
8fea95319b Help: Add .. versionadded directives to module docs
Issue: #19715
2020-12-02 21:00:30 +05:00
Alexandru Croitor
ab8bd48352 FindPkgConfig: Search for pkg-config.bat file on a Windows host
The strawberry perl distribution ships a pkg-config file and a
pkg-config.bat file.

find_program() does not usually look for a .bat file program unless
explicitly specified in the NAMES argument. This would cause
CMake to find the non-bat file, and executing that with
execute_process() leads to a
'%1 is not a valid Win32 application' error.

Prefer to search for pkg-config.bat file when on a Windows host, in
additiona to the regular pkg-config file.

Fixes: #21239
2020-09-25 15:56:05 +02:00
Alexandru Croitor
3201dd521e FindPkgConfig: Show more info when pkg-config --version fails
Fixes: #21239
2020-09-25 15:49:18 +02:00
Rolf Eike Beer
cd31a8acef FindPkgConfig: also handle "-isystem" prefixes for include directories
Fixes: #20652
2020-05-05 18:38:50 +02:00
Rolf Eike Beer
95ead38375 FindPkgConfig: fix handling of frameworks 2020-04-18 17:14:56 +02:00
Brad King
b59f36aad8 FindPkgConfig: Unset results when pkg-config is broken
Inspired-by: FUJI Goro <goro@fastly.com>
2020-03-16 12:27:11 -04:00
Brad King
2b615e6f5e Merge topic 'FindPkgConfig-scope'
c3e0d1ffe9 FindPkgConfig: set policies CMP0054 and CMP0057 to new

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4388
2020-02-25 08:55:50 -05:00
Rolf Eike Beer
c3e0d1ffe9 FindPkgConfig: set policies CMP0054 and CMP0057 to new
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.
2020-02-24 16:42:34 +01:00
Hugo Beauzée-Luyssen
f92a4b2399 FindPkgConfig: Fix path manipulations when cross compiling
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
2019-12-02 16:47:04 +01:00
Chuck Atkins
28cb86d796 FindPkgConfig: Allow libraries that can't be found with their full path
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
2019-09-16 13:02:08 -04:00
Christophe Giboudeaux
fe68387695 FindPkgConfig: return the module found by pkg_search_module
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
2019-08-29 21:50:49 +02:00
Dan Kegel
f401a57160 pkg_get_variable now sets PKG_CONFIG_PATH like pkg_check_modules
Fixes: #15805
2019-03-20 17:21:47 -04:00
Dan Kegel
4d76941924 FindPkgConfig: hoist PKG_CONFIG_PATH ops out into _pkg_set_path_internal 2019-03-20 17:20:30 -04:00
Radek Nadstawny
b759fa9b8e FindPkgConfig: Set linker flags on imported targets 2019-03-13 23:42:44 +01:00
Sylvain Joubert
f5c46dd84e PkgConfig: Be less verbose by mark(ing)_as_advanced the find_library result 2018-11-07 14:08:02 +01:00
Joachim Wuttke (o)
fc7ee1ca45 Help: Override pygments CMakeLexer to support <..> and [..]
* 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.
2018-10-19 07:25:34 +11:00
Joachim Wuttke (l)
74b3eacdc7 Help: Use appropriate list types in FindPkgConfig 2018-10-17 23:50:22 +11:00
Craig Scott
7f2bc70c5e FindPkgConfig: Document support for > and < operators
This was left out of commit v3.13.0-rc1~14^2 (FindPkgConfig: support
also > and < operators for version compares, 2018-10-02).
2018-10-15 10:14:51 -04:00
Rolf Eike Beer
aa51bfd74f FindPkgConfig: support also > and < operators for version compares
Fixes: #18416
2018-10-04 10:32:13 -04:00
Rolf Eike Beer
7aa26cf0e9 FindPkgConfig: allow to create global imported targets 2018-07-22 13:33:04 +02:00