1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-19 11:31:30 +08:00

305 Commits

Author SHA1 Message Date
Alex Turbov
f71b88c4c1 cmFindPackageCommand: Move cmFindPackageCommandHoldFile to anonymous ns
Also, avoid `#include` in the middle of the module.
2022-07-11 17:14:01 +04:00
Alex Turbov
865cfaa492 cmFindPackageCommand: Move collectPathsForDebug() to anonymous namespace 2022-07-11 17:14:01 +04:00
Alex Turbov
6a95ab97e7 cmFindPackageCommand: Deduplicate version string comparator code 2022-07-11 17:14:01 +04:00
Alex Turbov
c6d3ef1c95 cmFindPackageCommand: Replace empty string literal w/ default std::string{} 2022-07-11 17:14:01 +04:00
Alex Turbov
f2a4e4f6fa cmFindPackageCommand: Simplify if-return-else-return into single return stmt 2022-07-11 17:14:01 +04:00
Alex Turbov
a3fe1aca0c cmFindPackageCommand: Replace strcmp with array subscription 2022-07-11 17:14:01 +04:00
Alex Turbov
b5f880d5c6 cmFindPackageCommand: Deduplicate code to exclude . and .. dir entries 2022-07-11 17:14:01 +04:00
Alex Turbov
045e36fe36 cmFindPackageCommand: Replace single-char string literals with char literals 2022-07-11 17:14:01 +04:00
Alex Turbov
1bed0be2cd cmFindPackageCommand: Use std::any_of instead of "manual" for loops 2022-07-11 17:14:01 +04:00
Sean McBride
d5694e4623 Source: Replace uses of sprintf with safer snprintf 2022-06-22 08:59:40 -04:00
FeRD (Frank Dana)
98a10290a8 cmSystemTools: Fix 'ErrorOccurred' spelling
Rename the booleans 's_ErrorOccured' and 's_FatalErrorOccured' to
's_ErrorOccurred' and 's_FatalErrorOccurred', respectively.

Rename the getters and setters to 'Get[Fatal]ErrorOccurred' and
'Set[Fatal]ErrorOccurred', and fix all uses across the codebase.
2022-06-13 09:05:24 -04:00
Craig Scott
2aa83fa15b Dependency providers: Add find_package and FetchContent support
Fixes: #22619
2022-05-25 08:46:18 +10:00
Craig Scott
74a6ddc339 cmFindPackageCommand: Handle Makefile variable definitions more robustly
During argument parsing in InitialPass(), Makefile variables were
being added for components. Most other such variables were set
in the call to SetModuleVariables(), which happens much later.
Both sets of variables were then restored to their previous values
as part of a call to AppendSuccessInformation(), but that is not an
obvious nor robust place to undo those variable changes.

InitialPass() also pushes a new item to the package root stack, but
the corresponding pop was in AppendSuccessInformation().
Again, this puts a symmetric operation in an asymmetric place.

Refactor the code slightly such that Makefile variables are set in
one clear location, then restored later in the same function.
Also move the package root stack pop into the same function as
the push. AppendSuccessInformation() now has one clear
responsibility and doesn't perform any unrelated cleanup on
behalf of InitialPass().
2022-05-17 14:33:29 +10:00
Craig Scott
c5dff5ace2 Merge topic 'FetchContent_find_package_integration'
29e31e2825 Packages: Integrate FetchContent and find_package()

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: huangqinjin <huangqinjin@gmail.com>
Merge-request: !5688
2022-05-06 08:33:38 -04:00
Craig Scott
29e31e2825 Packages: Integrate FetchContent and find_package()
Allow FetchContent_MakeAvailable() to try a call to
find_package() first, or redirect a find_package() call to
FetchContent_MakeAvailable(). The user can set variables
to control which of these are allowed or tried by default.

Fixes: #21687
2022-05-03 16:48:11 +10:00
Marc Chevrier
8d7e80cf3d find_* commands: add control over Windows registry views
Fixes: #22775
2022-04-29 22:00:02 +02:00
Robert Maynard
42f7e39789 Find: Support per call disabling of CMAKE_INSTALL_PREFIX
Fixes #23359
2022-04-15 09:33:55 -04:00
John Parent
2f1ffa003c find_package: Add support for default GLOBAL imported targets
Allow find package to promote scope of imported targets by specifying
an argument to `find_package` or by specifying a CMake variable.
    * Add support for CMAKE_GLOBAL_IMPORT_SCOPE variable
    * Add support for GLOBAL argument to find_package

Additionally add testing for above features.
2022-03-10 12:44:36 -05:00
Brad King
38de1bef2d find_package: Improve --debug-find-pkg= when using a find module
Extend the feature added by commit d7b18895bc (cmake: Add filtered
debug-find options, 2021-12-07, v3.23.0-rc1~217^2) to enable debug
output for `find_*` calls within a find module or cmake package
configuration file.

Fixes: #23211
2022-02-10 16:30:10 -05:00
Brad King
d634d20397 find_package: Avoid printing debug output header multiple times 2022-02-10 16:30:10 -05:00
Brad King
df3e29450a find_package: Mention package name in Config mode debug output
Otherwise, if there are no paths considered then the output does not
specify the name of the package.
2022-02-10 16:30:09 -05:00
Brad King
636ca7f25c find_package: Fix find module name in --debug-find output 2022-02-10 16:30:09 -05:00
Brad King
596e185409 find_package: Improve formatting of --debug-find output
Also spell out more complete content in the test's expect output.
2022-02-10 16:30:04 -05:00
Brad King
a690523fcf cmFindPackageCommand: Drop ComputeIfDebugModeWanted overload
The overload for `--debug-find-pkg` has the same signature as the base
class method for `--debug-find-var`.  To avoid confusion, drop the
overload and inline it its only call site.
2022-02-10 15:25:05 -05:00
Kyle Edwards
201d8c4298 find_*(): Add CMAKE_IGNORE_PREFIX_PATH variable
Fixes: #20878
2022-02-02 11:09:00 -05:00
Kyle Edwards
bd805a51ae Refactor: Keep track of prefixes in cmSearchPath 2022-02-02 11:09:00 -05:00
Kyle Edwards
11f97d1968 find_package(): Refactor CMAKE_[SYSTEM_]IGNORE_PATH
In the old implementation, CMAKE_[SYSTEM_]IGNORE_PATH was handled
in cmFindCommon. Move it into cmFindPackageCommand.
2022-01-31 10:41:04 -05:00
John Parent
d7b18895bc cmake: Add filtered debug-find options
Add a `--debug-find-pkg=` option to debug find calls for specific
packages.

Add a `--debug-find-var=` option to debug find calls for specific
return variables.

Fixes: #21880
2021-12-17 08:55:21 -05:00
Sean McBride
5ba6e8ac59 Source: Replace most calls to sprintf with snprintf 2021-10-25 18:23:13 -04:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Eugene Shalygin
a2e9fe38e4 find_package: Add variable to make package REQUIRED
Add a `CMAKE_REQUIRE_FIND_PACKAGE_<PackageName>` variable is complement
to `CMAKE_DISABLE_FIND_PACKAGE_<PackageName>` with just the opposite
behaviour: it turns non-required find_package call into the required one.

While optional package dependencies usually result in simple and clean
build logic, sometimes people want to be sure those optional
dependencies will be found and used. Examples are reproducible builds
and build instructions for 3rd parties. People choose to make
find_package calls REQUIRED and put them behind an option(). Such
workarounds blend build logic with build environment management and do
not look elegant.
2021-07-08 08:03:38 -04:00
Marc Chevrier
d96eb55282 set(CACHE): do not remove normal variable
Fixes: #22038
2021-05-20 17:50:13 +02:00
Ben Boeckel
ef935b17ab clang-tidy: fix readability-use-anyofallof warnings 2021-01-27 08:54:18 -05:00
Oleksandr Koval
209daa20b2 Code style: add missed explicit 'this->'
CMake uses explicit 'this->' style. Using custom clang-tidy check we can
detect and fix places where 'this->' was missed.
2021-01-05 14:32:36 +02:00
Brad King
0356b81525 find_package: Fix regression in searching root prefix
Fix the check added by commit 2ff1693066 (find_package: avoid showing
files as directories when searching config files, 2020-09-30,
v3.19.0-rc1~67^2) to avoid skipping the root prefix `/`.

Fixes: #21324
2020-10-19 11:08:49 -04:00
Brad King
95aa5c40cf Merge topic 'find_package-check-dir'
2ff1693066 find_package: avoid showing files as directories when searching config files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5301
2020-10-01 07:57:23 -04:00
sanchayanghosh
2ff1693066 find_package: avoid showing files as directories when searching config files
Teach `cmFileListGeneratorBase::Consider` to skip non-directories so
that all call sites get the check.

Fixes: #21212
2020-09-30 11:50:23 -04:00
Marc Chevrier
212b0afb66 find_package: raise error on empty version range 2020-09-29 13:06:09 +02:00
Brad King
7a4d84d8d2 Merge topic 'find_package_module_mode_print_debug_message'
b423a20ce1 FindPackage: Provide better debug message when <PKG_FOUND> is false
a7acafc977 FindPackage: find_package(MODULE) respects CMAKE_FIND_DEBUG_MODE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5256
2020-09-25 12:26:10 -04:00
Marc Chevier
d7df81067b find_package: Add support of version range
This enhancement is the first step for solving issue #21107
2020-09-23 12:52:25 +02:00
Marc Chevrier
09095dbcd2 cmFindPackageCommand: Refactoring
* Use member initialisation at declaration
* AddFindDefinition: same signature as cmMakefile::AddDefinition for consistency
* Factorise version variables creation
2020-09-23 12:52:25 +02:00
Robert Maynard
b423a20ce1 FindPackage: Provide better debug message when <PKG_FOUND> is false 2020-09-22 15:32:31 -04:00
Robert Maynard
a7acafc977 FindPackage: find_package(MODULE) respects CMAKE_FIND_DEBUG_MODE
Fixes #21216
2020-09-22 14:13:48 -04:00
Vitaly Stakhovsky
11425041f0 cmMakefile::GetDefinition: return cmProp 2020-09-02 07:27:32 -04:00
Kyle Edwards
63ecf481da Merge topic 'cmnonempty'
eaad8072ee cmNonempty: Convenience inlines to check for non-empty string

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5017
2020-07-15 10:53:43 -04:00
Vitaly Stakhovsky
eaad8072ee cmNonempty: Convenience inlines to check for non-empty string 2020-07-14 15:18:59 -04:00
Vitaly Stakhovsky
7156911242 cmIsOn: add overload accepting const std::string* 2020-07-14 08:22:24 -04:00
Brad King
a432b1075c Merge topic 'getdef-expand'
7ed8c9ebe3 cmMakefile: add GetDefExpandList() that splits value into std::vector

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4819
2020-06-02 08:02:24 -04:00
Vitaly Stakhovsky
b36d1bdd9d Single location for cmProp typedef 2020-06-01 08:54:20 -04:00
Vitaly Stakhovsky
7ed8c9ebe3 cmMakefile: add GetDefExpandList() that splits value into std::vector
Combines cmMakefile:GetDefinition() and cmExpandList()
2020-05-30 08:59:20 -04:00