Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meson should output more detailed error message when trying to find dependency using CMake and raised error #14050

Open
na-trium-144 opened this issue Dec 29, 2024 · 0 comments

Comments

@na-trium-144
Copy link

na-trium-144 commented Dec 29, 2024

Describe the bug
When trying to find a dependency using CMake and it raised error despite being found, meson should give more detailed error message instead of just saying the dependency not found.

To Reproduce

I think this can be reproduced with any other projects and platforms, but I first encountered this with the following situation:

On MacOS, install zstd and jeremy-rifkin/cpptrace with external zstd using CMake.

brew install zstd
git clone https://github.com/jeremy-rifkin/cpptrace
cd cpptrace
cmake -Bbuild -DCMAKE_INSTALL_PREFIX=/tmp/cpptrace -DCPPTRACE_USE_EXTERNAL_ZSTD=ON
cmake --build build -t install

Now /tmp/cpptrace/lib/cmake/cpptrace/cpptrace-config.cmake is installed, and I try to use this from Meson using the following meson.build and setup with -Dcmake_prefix_path=/tmp/cpptrace.

project('test')
dependency('cpptrace', method: 'cmake')
The Meson build system
Version: 1.6.1
Source dir: /private/tmp/cpptrace_test
Build dir: /private/tmp/cpptrace_test/build
Build type: native build
Project name: test
Project version: undefined
Host machine cpu family: aarch64
Host machine cpu: aarch64
Found CMake: /opt/homebrew/bin/cmake (3.31.3)
Run-time dependency cpptrace found: YES 0.7.4
Build targets in project: 0

But if I remove zstd (brew unlink zstd) this happens, despite cpptrace-config.cmake still exists and I'm sure passing correct cmake_prefix_path:

The Meson build system
Version: 1.6.1
Source dir: /private/tmp/cpptrace_test
Build dir: /private/tmp/cpptrace_test/build
Build type: native build
Project name: test
Project version: undefined
Host machine cpu family: aarch64
Host machine cpu: aarch64
Found CMake: /opt/homebrew/bin/cmake (3.31.3)
Run-time dependency cpptrace found: NO (tried cmake)

meson.build:2:0: ERROR: Dependency "cpptrace" not found, tried cmake

meson-log.txt does not provide any useful information either:

Determining dependency 'cpptrace' with CMake executable '/opt/homebrew/bin/cmake'
Try CMake generator: auto
Calling CMake (['/opt/homebrew/bin/cmake']) in /private/tmp/cpptrace_test/build/meson-private/cmake_cpptrace with:
  - "-DNAME=cpptrace"
  - "-DARCHS="
  - "-DVERSION="
  - "-DCOMPS="
  - "-DSTATIC=OFF"
  - "--trace-expand"
  - "--trace-format=json-v1"
  - "--no-warn-unused-cli"
  - "--trace-redirect=cmake_trace.txt"
  - "-DCMAKE_TOOLCHAIN_FILE=/private/tmp/cpptrace_test/build/meson-private/cmake_cpptrace/CMakeMesonToolchainFile.cmake"
  - "."
  - "-DCMAKE_PREFIX_PATH=/tmp/cpptrace"
Run-time dependency cpptrace found: NO (tried cmake)

meson.build:2:0: ERROR: Dependency "cpptrace" not found, tried cmake

Expected behavior

Meson should output more detailed message why the CMake call raised error to the console output or at least to the meson-log.txt.
In this case that's because zstd was not found, which is a dependency required by cpptrace.
If I try to use cpptrace from CMake like the following, CMake gives exact error message about this.

cmake_minimum_required(VERSION 3.10)
project(test)
find_package(cpptrace REQUIRED)
-- The C compiler identification is Clang 17.0.6
-- The CXX compiler identification is Clang 17.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/homebrew/opt/llvm@17/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/homebrew/opt/llvm@17/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /opt/homebrew/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find zstd (missing: zstd_LIBRARY zstd_INCLUDE_DIR)
Call Stack (most recent call first):
  /opt/homebrew/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  /opt/homebrew/lib/cmake/cpptrace/Findzstd.cmake:20 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  /opt/homebrew/share/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  /opt/homebrew/lib/cmake/cpptrace/cpptrace-config.cmake:13 (find_dependency)
  CMakeLists.txt:3 (find_package)


-- Configuring incomplete, errors occurred!

system parameters

  • Is this a cross build or just a plain native build (for the same computer)?
    • Native
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
    • MacOS Sonoma
  • what Python version are you using e.g. 3.8.0
    • Python 3.13.1
  • what meson --version
    • 1.6.1
  • what ninja --version if it's a Ninja build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant