summaryrefslogtreecommitdiffstats
path: root/Source/cmFindPackageCommand.h
Commit message (Collapse)AuthorAgeFilesLines
* IWYU: Update for Debian 13 CI jobBrad King2025-11-121-2/+0
| | | | | | | | | | | | | | | `include-what-you-use` diagnostics, in practice, are specific to the environment's compiler and standard library. Update includes to satisfy IWYU for our CI job under Debian 13. Some patterns: * Types named in virtual `override` signatures no longer require includes since the overridden signature already names them. * A function argument's type needs to be included even if its constructor is called only by implicit conversion. For example, constructing a `std::function` from a lambda now requires `<functional>`. * Some prior mysterious `<type_traits>` inclusions are no longer required.
* find_package: Report why a candidate was rejectedMatthew Woehlke2025-11-051-2/+8
| | | | | | | | | | | | | | | | | | | | Improve how find_package reports the list of candidate package configuration files that were considered but rejected to include a reason for rejection. For CPS in particular, this allows the user to tell if a CPS file was rejected due to a version mismatch, missing required components, or because the file could not be read. While we do not try to report more detail for why cmPackageInfoReader rejected a file, the possible reasons are usually easy enough to distinguish: - The file is so malformed that we cannot read a JSON object. - The schema version is not a version that CMake understands. - The root object does not contain a string named "name". - The root object does not contain an object named "components". - Prefix resolution failed. Three of these can only result from a file that fails schema validation.
* install(PACKAGE_INFO): Add version and location to package dependenciesTaylor Sasser2025-08-121-0/+3
| | | | | | | Refactor `cmFindPackageStack` to track additional metadata about <package> found. This includes two new fields, `Version` and `Location` which correspond to package version and path. The remaining package information will be implemented in a later commit
* find_package: Implement UNWIND_INCLUDEVito Gamberini2025-07-131-0/+1
| | | | | | | | | | | | | | | | This implements a limited exception mechanism for find_package() via the UNWIND_INCLUDE keyword. When package discovery via find_package(UNWIND_INCLUDE) fails the StateSnapshot is updated to an UNWINDING state. In this state further calls to find_package() and include() are forbidden. While in the UNWINDING state, the include() command immediately calls SetReturnInvoked() whenever it is reached. The UNWINDING state is reset when a parent call to find_package() is reached. Fixes: #26897
* find_package: Use deterministic search order by defaultMoritz Haase2025-06-181-4/+4
| | | | | | | | | | | | | | Historically, find_package() does not guarantee the order in which directories matching a search path containing a glob expression are processed in - the "first valid package" will be selected if there are multiple candidates. In such cases, which package is chosen is completely random and can change, potentially leading to build failures and reproducibility issues. This is rather unexpected and confusing for developers. Now that CMake has bumped its major version, it's a good time to change default sort order and direction could be changed to natural sorting with a descending order. That will result in the newest version of a library being picked in case there are multiple ones available.
* cmFindPackage: fix over-reportingBen Boeckel2025-06-101-0/+11
| | | | | | Both track when a `_DIR` variable is already defined and suppress implicit event reporting when a mode that has no reliable method for such detection.
* cmFindCommon: log search path variablesBen Boeckel2025-05-151-0/+2
| | | | | No pruning of variables which are not relevant is performed as it would involve duplication of determining which paths to manage.
* find_package: generate `find_package-v1` configure log eventsBen Boeckel2025-05-091-2/+40
| | | | | | | Since `find_package` is far more complex than other `find_*` commands, it gets its own event. Closes: #24833
* cmFindCommonDebugState: adopt event writing logicBen Boeckel2025-05-011-1/+11
| | | | | This lays the groundwork for `find_package` also using the same triggering logic.
* cmFindCommon: track debug state as an objectBen Boeckel2025-04-291-0/+13
| | | | | This also means that the `DebugState` instances do not need to ask if debug mode is enabled: if they exist, it is enabled.
* find_package: Improve support for CPS multiple inclusionMatthew Woehlke2025-04-031-2/+4
| | | | | | | | | | | | Keep track of CPS files we have imported in CMake's state, and use this (instead of the prior, temporary work-around that used `<name>_CONFIG`) as a guard for trying to import more than once from the same file. This has two advantages; first, it is robust against finding the same package name in different locations in alternating searches, and second, it allows us to load additional appendices associated with a root package that has already been loaded. Fixes: #26731
* Merge topic 'fix-cps-cmake-deps'Brad King2025-03-061-0/+1
|\ | | | | | | | | | | | | | | c3d279841b find_package: CPS component requirements != CMake components Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !10427
| * find_package: CPS component requirements != CMake componentsMatthew Woehlke2025-03-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modify how CMake handles required components of a CPS transitive dependency to not pass them as COMPONENTS if a CMake-script package is found as the resolved dependency. This is necessary as many CMake-script package description files do not treat component requests as target requests (which, in CPS-land, they effectively are), but do implement logic to mark themselves 'not found' if requested components are missing. As a result, passing in the required targets as required components is likely to cause the dependency to be spuriously not found if it is only available via a CMake-script package configuration file. Fix this by introducing a new 'required targets' concept, and by passing CPS component requirements as both required targets and optional components. The latter serves as a hint for packages that might provide only a subset of themselves. The former is used to post-validate a CMake-script package, or is folded on-the-fly into required components when considering CPS packages. Note that this functionality is not exposed to the user at this time, and is only used when resolving transitive dependencies for a CPS package.
| * LICENSE: Replace references to Copyright.txt with LICENSE.rstKitware Robot2025-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | ``` 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 ```
* | LICENSE: Replace references to Copyright.txt with LICENSE.rstKitware Robot2025-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | ``` 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 ```
* | find_*: Add variable to default calls to REQUIREDMartin Duffy2025-02-271-2/+12
|/ | | | | | | | | | | This adds a `CMAKE_FIND_REQUIRED` variable which causes `find_package`, `find_path`, `find_file`, `find_library` and `find_program` to be considered `REQUIRED` by default. It also introduces an `OPTIONAL` keyword to those commands, allowing them to ignore the value of this variable. Issue: #26576
* find_package: Find CPS componentsMatthew Woehlke2025-02-011-3/+11
| | | | | | | | Implement finding components of CPS packages. Specifically, reject any candidate packages that don't provide all required components, and ignore appendices that don't provide requested (required or optional) components. This applies to both top-level searches and also searching for package dependencies.
* Revise C++ coding style using clang-format with "east const"Kitware Robot2025-01-231-9/+9
| | | | | | | | | | | | | | | Run the `clang-format.bash` script to update all our C and C++ code to a new style defined by `.clang-format`, now with "east const" enforcement. Use `clang-format` version 18. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit. Issue: #26123
* find_package: Find CPS dependenciesMatthew Woehlke2025-01-131-4/+14
| | | | | | Implement finding dependencies of CPS packages. This is done by setting up additional `cmFindPackageCommand` instances which are used to look for a parent package's dependencies.
* cmFindPackageCommand: Fix searching a root path as a prefixBrad King2024-12-191-3/+3
| | | | | | A root path like `/` or `c:/` needs to end in a slash. Revise our prefix search logic to maintain a trailing slash instead of removing one just to add it again.
* find_package: Actually import .cps filesMatthew Woehlke2024-12-131-0/+3
| | | | | | | | | Implement logic (partly adapted from the 2023 proof-of-concept) to actually parse CPS files and generate imported targets. Implement logic to locate and load supplemental files. Adjust prefix handling to require that the CPS file provides sufficient information to translate the prefix placeholder into a meaningful path. (Note that this corresponds to a change in the specification.)
* find_package: Actually find .cps filesMatthew Woehlke2024-12-131-0/+4
| | | | | | | | | Add a helper class to read CPS files. Use this to teach find_package how to consider and accept .cps files in its search. (Note that no version testing is performed at this time.) Add a simple test that we can find a package from a .cps file and correctly extract the version information. Note that this doesn't actually import anything from CPS yet.
* find_package: Start implementing CPS searchMatthew Woehlke2024-12-131-4/+35
| | | | | | | | | | | | | | | | | Teach find_package to search CPS search paths, and to look for CPS file names. Modify the set of file names to also include the file type (CPS or CMake-script). Modify the search function to allow specifying which file type(s) to consider. During full path search, each possible path is searched for only one of the two possible file types. However, subsequent runs, or when considering a user-specified path (<name>_DIR), CMake will look for both file types. Note that this only adds the new path search logic as described above; CMake does not yet know how to read CPS files, and there is a high likelihood that Bad Things will happen if it tries. However, this seemed like a good place to checkpoint.
* find_package: Refactor in support of recursionMatthew Woehlke2024-12-031-4/+9
| | | | | | | | | | | | | Separate argument handling and actual operation of the find_package command into separate methods. This is preparatory to adding improved support for transitive dependencies and will allow nested calls to be set up using structured data types, rather than having to perform all communication via a constructed argument list. As a consequence, the sets of required and optional components, as well as the component list string, are now members rather than local variables. This also allows us to drop some parameters and simplify how we set the variables indicating which components are required.
* find_package: Ensure root path stack and module vars are restoredCraig Scott2023-03-171-0/+5
| | | | Fixes: #24595
* cmFindPackageCommand: Factor out methods for package root stack managementBrad King2023-02-231-0/+3
|
* cmFindPackageCommand: Avoid friendship between command class and generatorAlex Turbov2022-07-111-2/+0
|
* Dependency providers: Add find_package and FetchContent supportCraig Scott2022-05-241-0/+1
| | | Fixes: #22619
* cmFindPackageCommand: Handle Makefile variable definitions more robustlyCraig Scott2022-05-171-1/+3
| | | | | | | | | | | | | | | | | | | 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().
* Merge topic 'FetchContent_find_package_integration'Craig Scott2022-05-061-0/+3
|\ | | | | | | | | | | | | | | | | 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
| * Packages: Integrate FetchContent and find_package()Craig Scott2022-05-031-0/+3
| | | | | | | | | | | | | | | | 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
* | find_* commands: add control over Windows registry viewsMarc Chevrier2022-04-291-0/+1
|/ | | | Fixes: #22775
* find_package: Add support for default GLOBAL imported targetsJohn Parent2022-03-101-0/+1
| | | | | | | | | 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.
* cmFindPackageCommand: Drop ComputeIfDebugModeWanted overloadBrad King2022-02-101-2/+0
| | | | | | 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.
* find_*(): Add CMAKE_IGNORE_PREFIX_PATH variableKyle Edwards2022-02-021-0/+1
| | | | Fixes: #20878
* cmake: Add filtered debug-find optionsJohn Parent2021-12-171-0/+2
| | | | | | | | | | 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
* find_package: Add support of version rangeMarc Chevier2020-09-231-0/+13
| | | | This enhancement is the first step for solving issue #21107
* cmFindPackageCommand: RefactoringMarc Chevrier2020-09-231-26/+34
| | | | | | * Use member initialisation at declaration * AddFindDefinition: same signature as cmMakefile::AddDefinition for consistency * Factorise version variables creation
* Modernize: Use #pragma once in all header filesKitware Robot2020-09-031-4/+1
| | | | | | | | | | | | | | | | #pragma once is a widely supported compiler pragma, even though it is not part of the C++ standard. Many of the issues keeping #pragma once from being standardized (distributed filesystems, build farms, hard links, etc.) do not apply to CMake - it is easy to build CMake on a single machine. CMake also does not install any header files which can be consumed by other projects (though cmCPluginAPI.h has been deliberately omitted from this conversion in case anyone is still using it.) Finally, #pragma once has been required to build CMake since at least August 2017 (7f29bbe6 enabled server mode unconditionally, which had been using #pragma once since September 2016 (b13d3e0d)). The fact that we now require C++11 filters out old compilers, and it is unlikely that there is a compiler which supports C++11 but does not support #pragma once.
* Refactoring: Third-parties public headers are under cm3p prefixMarc Chevrier2020-05-071-1/+1
| | | | Fixes: #20666
* find_package: Improve debug logging outputRobert Maynard2020-01-011-0/+1
| | | | | The find_package debug log messages are now easier to read when enabled by the `--debug-find` command-line option or `CMAKE_FIND_DEBUG_MODE` variable.
* find_*: Use debug logging infrastructureRobert Maynard2019-12-191-1/+0
| | | | | | Teach the find_package, find_library, find_program, find_path, and find_file commands to print debug log messages when enabled by the `--debug-find` command-line option or `CMAKE_FIND_DEBUG_MODE` variable.
* Revise include order using clang-format-6.0Kitware Robot2019-10-011-1/+2
| | | | | Run the `clang-format.bash` script to update our C and C++ code to a new include order `.clang-format`. Use `clang-format` version 6.0.
* cmFind*: Port away from cmCommandRegina Pfeifer2019-09-101-20/+7
|
* clang-tidy: Replace typedef with usingRegina Pfeifer2019-09-031-2/+2
|
* modernize: manage cmCommand instances using unique_ptr.Marc Chevrier2019-07-141-2/+7
|
* find_package: Fixed CMAKE_FIND_PACKAGE_PREFER_CONFIG Module fallbackCristian Adam2019-06-131-1/+8
| | | | Fixes: #19361
* find_package: Factor out module and config find_package methodsCristian Adam2019-05-201-0/+3
|
* ReadListFile: Accept std::string argumentVitaly Stakhovsky2019-01-311-1/+1
|
* find_package: optionally resolve symlinks when discovering packagesDavid Aguilar2019-01-161-0/+1
| | | | | | | | | Teach find_package() to resolve symlinks when constructing relocatable prefix paths from discovered cmake config files. The `CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS` variable enables this behavior when set to `TRUE`. Fixes: #18704