summaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/cmake.py
AgeCommit message (Collapse)Author
2025-12-17dependencies: Remove `log_tried` methodDylan Baker
It's now only used to populate the DependencyCandidate, so we can remove it and just calculate the same information from the `type_name` parameter. This reduces code and the number of method calls.
2025-12-17Dependencies: Make use of the DependencyCandidate classDylan Baker
This makes the type checking more reasonable (including fixing an issue that newer mypy is pointing out to us), consolidating special cases, and improving code readability.
2025-12-17dependencies: Require 'native' be passed in kwargsDylan Baker
This simplifies a bunch of cases, and likely fixes some annoying bugs in cross compile situations where should have been passing this and weren't.
2025-12-17dependencies: stop passing "language" as a keyword argumentDylan Baker
It's allowed in the `DependencyKeywordArguments` TypeDict already, so we now have two sources of truth. Additionally, it's often populated by reading from that dict, so we're just doing useless work.
2025-12-17dependencies: Pass the `name` to `ExternalDependency` constructorDylan Baker
So we don't create a default name that is overwritten except in the case of appleframeworks. This allows for some cleanup, including deleting some initializers that were only setting the name.
2025-12-17dependencies: Move type_name to class levelDylan Baker
This is really class constant for all dependencies, and by taking it out of the initializer we make the `__init__` call have a more consistent interface.
2025-10-20interpreter: port dependency optional_modules to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency native to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency modules to typed_kwargsDylan Baker
2025-10-20interpreter: port dependencies components to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency cmake_package_version to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency cmake_module_path to typed_kwargsDylan Baker
2025-10-20interpreter: port cmake_args to typed_kwargsDylan Baker
2025-10-20dependency: Use a TypedDict to describe the keyword arguments to DependencyDylan Baker
This allows us to check that all of the keyword arguments are of the correct type.
2025-04-20Log non-fatally if CMake doesn't find a packageBenjamin Gilbert
If CMake fails to find a package, we should log it in meson-log.txt, but shouldn't bother the user unless there are details to report. In addition, we were calling mlog.warning() without fatal=False, so if msetup was called with --fatal-meson-warnings we'd fail the entire setup in this case, even for optional dependencies. Log a notice with fatal=False if CMake reported an error, and a debug message otherwise. Notably, the "even though Meson's preliminary check succeeded" case can occur when a dependency is missing but its Find*.cmake is shipped with CMake itself. Fixes: 92c517ea69 ("output PACKAGE_NOT_FOUND_MESSAGE as warning when CMake package is not found")
2025-03-01output PACKAGE_NOT_FOUND_MESSAGE as warning when CMake package is not foundna-trium-144
2025-02-11Fix CMake import's linker args sorting algorithm mangling -framework argumentsMarco Rebhan
2024-09-21Add get_variable() system dependencyunknown
2024-07-10cmake dependency: Fix accidental use of T.Optional in warning messageAndres Freund
09b53c534f seems to have done an over-eager search-replace.
2024-02-12cmake dependency: avoid setting property to None as a workaroundEli Schwartz
It's an improper object model, but was used to signal to a subclass that self.traceparser did not exist. However, since it is always initialized from self.cmakebin, we can just check that instead.
2024-02-12defer setting values until after we know it cannot be NoneEli Schwartz
2024-02-07cmake: canonicalise -DSTATIC valueSam James
CMake really prefers ON/OFF and in some cases, depending on how the condition is written, ON/OFF vs other "truthy" (as far as CMake's lang supports) values work differently. Just be safe and use ON/OFF. Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field
2023-09-29Allow share/cmake/ as cmake_prefix_pathXiang Gao
This is to allow passing the path share/cmake/ as cmake_prefix_path. This is a case supported by cmake and is relied on by PyTorch. The cmake prefix of PyTorch can be found by running: python -c 'import torch.utils; print(torch.utils.cmake_prefix_path)' you will see something like below from the above command: /home/gaoxiang/.virtualenvs/nvfuser/lib/python3.11/site-packages/torch/share/cmake Inspecting this directory: ❯ tree /home/gaoxiang/.virtualenvs/nvfuser/lib/python3.11/site-packages/torch/share/cmake /home/gaoxiang/.virtualenvs/nvfuser/lib/python3.11/site-packages/torch/share/cmake ├── ATen │   └── ATenConfig.cmake ├── Caffe2 │   ├── Caffe2Config.cmake │   ├── Caffe2Targets.cmake │   ├── Caffe2Targets-release.cmake │   ├── FindCUDAToolkit.cmake │   ├── FindCUSPARSELT.cmake │   ├── Modules_CUDA_fix │   │   ├── FindCUDA.cmake │   │   ├── FindCUDNN.cmake │   │   └── upstream │   │   ├── CMakeInitializeConfigs.cmake │   │   ├── FindCUDA │   │   │   ├── make2cmake.cmake │   │   │   ├── parse_cubin.cmake │   │   │   ├── run_nvcc.cmake │   │   │   └── select_compute_arch.cmake │   │   ├── FindCUDA.cmake │   │   ├── FindPackageHandleStandardArgs.cmake │   │   └── FindPackageMessage.cmake │   └── public │   ├── cuda.cmake │   ├── gflags.cmake │   ├── glog.cmake │   ├── LoadHIP.cmake │   ├── mkl.cmake │   ├── mkldnn.cmake │   ├── protobuf.cmake │   └── utils.cmake ├── Tensorpipe │   ├── TensorpipeTargets.cmake │   └── TensorpipeTargets-release.cmake └── Torch ├── TorchConfig.cmake └── TorchConfigVersion.cmake 9 directories, 28 files However, meson currently filters this directory out by `_preliminary_find_check`. As a result, doing torch_dep = dependency('Torch') will fail, even if you set `cmake_prefix_path` with the value returned by PyTorch. Possibly related issues: https://stackoverflow.com/questions/68884434/libtorch-c-meson-dependency https://github.com/mesonbuild/meson/issues/9740 https://discuss.pytorch.org/t/libtorch-meson-build/139648
2023-09-18Remove get_pkgconfig_variable()Xavier Claessens
Make sure that pkgconfig_define is a pair of strings and not a list with more than 2 strings.
2023-09-12fix bug with openssl when cmake is missingCharles Brunet
Fixes #12098 DependencyFactory was returning a lambda, but it has no log_tried() function
2023-08-11treewide: automatic rewriting of all comment-style type annotationsEli Schwartz
Performed using https://github.com/ilevkivskyi/com2ann This has no actual effect on the codebase as type checkers (still) support both and negligible effect on runtime performance since __future__ annotations ameliorates that. Technically, the bytecode would be bigger for non function-local annotations, of which we have many either way. So if it doesn't really matter, why do a large-scale refactor? Simple: because people keep wanting to, but it's getting nickle-and-dimed. If we're going to do this we might as well do it consistently in one shot, using tooling that guarantees repeatability and correctness. Repeat with: ``` com2ann mesonbuild/ ```
2023-05-13Make `dependency('foo', static: true, method: 'cmake') link staticallyVolker Weißmann
Fixes #1709
2023-04-11fix various spelling issuesJosh Soref
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-29pylint: enable the bad_builtin checkerDylan Baker
This finds uses of deny-listed functions, which defaults to map and filter. These functions should be replaced by comprehensions in idiomatic python because: 1. comprehensions are more heavily optimized and are often faster 2. They avoid the need for lambdas in some cases, which make them faster 3. you can do the equivalent in one statement rather than two, which is faster 4. They're easier to read 5. if you need a concrete instance (ie, a list) then you don't have to convert the iterator to a list afterwards
2022-10-04pylint: enable use-a-generatorDylan Baker
This catches some optimization problems, mostly in the use of `all()` and `any()`. Basically writing `any([x == 5 for x in f])` vs `any(x == 5 for x in f)` reduces the performance because the entire concrete list must first be created, then iterated over, while in the second f is iterated and checked element by element.
2022-09-12dependencies: simplify log_tried into a staticmethodEli Schwartz
It doesn't really need class instantiation to just know what type it is, and this way we can get the information early if a dependency fails to init.
2022-08-26Remove redundant backslash and fix white space issueAlf Henrik Sauge
2022-08-26Fix purely white space issues reported by flake8Alf Henrik Sauge
2022-06-10treewide: various cleanups to move imports for mypy into typechecking blocksEli Schwartz
Along the way, add __future__ annotations where lacking.
2022-04-13dependencies: tighten type checking and fix cmake API violation for get_variableEli Schwartz
dep.get_variable() only supports string values for pkg-config and config-tool, because those interfaces use text communication, and internal variables (from declare_dependency) operate the same way. CMake had an oddity, where get_variable doesn't document that it allows list values but apparently it miiiiiight work? Actually getting that kind of result would be dangerously inconsistent though. Also, CMake does not support lists so it's a lie. Strings that are *treated* as lists with `;` splitting don't count... We could do two things here: - raise an error - treat it as a string and return a string It's not clear what the use case of get_variable() on a maybe-list is, and should probably be a hard error. But that's controversial, so instead we just return the original `;`-delimited string. It is probably the wrong thing, but users are welcome to cope with that somehow on their own.
2022-04-12cmake: Always use all compilers for LLVM (fixes #10249)Daniel Mensinger
2022-03-07Merge pull request #9743 from mensinda/cmakeGeneratorFixedJussi Pakkanen
cmake: Add TARGET_ generator expression support (fixes #9305)
2022-02-16flake8: fix wrong numbers of blank line separatorsEli Schwartz
2022-02-16flake8: fix typoed whitespace surrounding tokensEli Schwartz
2022-01-27fix some flake8 violations for unused importsEli Schwartz
And one undefined T.cast name in a file that isn't yet mypy-ready anyway.
2022-01-23cmake: Add TARGET_ generator expression support (fixes #9305)Daniel Mensinger
2022-01-10port from embedded data to importlib.resourcesEli Schwartz
2021-12-01cmake: Fix old style dependency lookup with imported targetsDaniel Mensinger
This also includes some refactoring, since the alternaticve would have been to duplicate the huge traceparser target code block again. fixes #9581
2021-11-20cmake: Use find_library() on bare library names in cmake dependenciesJon Turney
Convert bare library names to a dependency linker argument using find_library(), rather than hardcoding the MSVC transformation.
2021-10-24cmake: Add support for the Linux CMake registry (fixes #9418)Daniel Mensinger
2021-10-06cmake: Implement support for interpreting link "keywords"Daniel Mensinger
CMakes `target_link_libraries()` supports certain keywords to only enable specific libraries for specific CMake configurations. We now try our best to replicate this for Meson dependencies. Fixes #9197
2021-10-06cmake: Warn if we could use IMPORTED CMake targetsDaniel Mensinger
2021-07-13dependencies: drop Dependency.methods and Dependency.get_methods()Dylan Baker
Both of these are artifacts of the time before Dependency Factories, when a dependency that could be discovered multiple ways did ugly stuff like finding a specific dependency, then replacing it's own attributes with that dependency's attributes. We don't have cases of that left in the tree, so let's get rid of this code too
2021-06-29fix: Always explicitly set encoding for text files (fixes #8263)Daniel Mensinger