meson icon indicating copy to clipboard operation
meson copied to clipboard

Possible bug: dependencies isolated from cmake projects?

Open ethindp opened this issue 1 year ago • 8 comments

I'm using the openssl wrap but I need it for a CMake dependency. The problem is that CMake can't find it even though I've dependency()'d it. An example snippet from my meson.build:

# Project setup...
openssl = dependency('openssl', static: true)
caf_opts = cmake.subproject_options()
caf_opts.add_cmake_defines(
    {
        'CAF_ENABLE_CURL_EXAMPLES': false,
        'CAF_ENABLE_PROTOBUF_EXAMPLES': false,
        'CAF_ENABLE_QT6_EXAMPLES': false,
        'CAF_ENABLE_ROBOT_TESTS': false,
        'CAF_ENABLE_RUNTIME_CHECKS': get_option('buildtype').startswith('debug')? true : false,
        'CAF_ENABLE_EXAMPLES': false,
        'CAF_ENABLE_EXCEPTIONS': true,
        'CAF_ENABLE_IO_MODULE': true,
        'CAF_ENABLE_NET_MODULE': true,
        'CAF_ENABLE_TESTING': false,
        'CAF_ENABLE_OPENSSL_MODULE': true,
        'CAF_CXX_VERSION': 20,
    },
)
caf_proj = cmake.subproject('caf', options: caf_opts)
caf = declare_dependency(
    dependencies: [
        caf_proj.dependency('core'),
        caf_proj.dependency('io'),
        caf_proj.dependency('net'),
    ],
)

With wrap:

[wrap-git]
url=https://github.com/actor-framework/actor-framework.git
revision=1.0.1

Is this a bug, or intended behavior? Is there some way of getting dependencies to propagate to CMake projects?

ethindp avatar Aug 22 '24 04:08 ethindp

How does the caf CMake build expect to find OpenSSL?

dcbaker avatar Aug 22 '24 15:08 dcbaker

@dcbaker It uses the standard find_package system.

ethindp avatar Aug 22 '24 15:08 ethindp

Which means it's using FindOpenSSL. It looks like there's a -DOPENSSL_ROOT_DIR option to pass to cmake in this case, but figuring out we need that option and passing it around might not be trivial... hmmm.

dcbaker avatar Aug 22 '24 18:08 dcbaker

Or correctly intercepting the find_package call. I'll have to dig into what the cmake module is doing a bit more

dcbaker avatar Aug 22 '24 18:08 dcbaker

Out of curiosity, does it work with static : false (or the static option removed)?

dcbaker avatar Aug 22 '24 18:08 dcbaker

Uh... No, it doesn't appear to find it if it's configured without static either. It's not on my system, either, or at least, not in a path CMake knows about, hence my desire to just tell Meson to build it.

ethindp avatar Aug 22 '24 19:08 ethindp

This is actually just #8089

There was an attempt at getting -uninstalled.pc files forwarded into the cmake subproject so that find_package(PkgConfig) and pkg_check_modules(OPENSSL IMPORTED_TARGET GLOBAL openssl) would work. But the PR had, uh, teething problems, so it ended up being closed.

eli-schwartz avatar Aug 22 '24 20:08 eli-schwartz

I'm wondering if we could just generate findXXXX.cmake/XXXX-Config.cmake files that just use pkgconfig (ensuring that CMake finds ours) and then let's CMake do the rest? It's uncommon, but I think it might be better to start with.

ethindp avatar Aug 22 '24 23:08 ethindp