How do I use binaries from Conan packages?

How do I use binaries from Conan packages?

Problem Description:

I’m trying build a project using Emscripten installed form the Conan center. I’ve been able to get it working, but I’m confused as to how I’m supposed to use the binaries for building my project.

Here’s my conanfile:

[requires]
libxml2/2.10.3
zlib/1.2.13
zstd/1.5.2

[generators]
cmake

And my host profile:

[settings]
os=Emscripten
arch=wasm
compiler=clang
compiler.version=16
build_type=Release

[build_requires]
emsdk/3.1.23

[options]
libxml2:ftp=False
libxml2:shared=False
libxml2:threads=False
[env]

I thought I could use imports, but that didn’t seem to work. Binaries from libxml and zstd got imported, but not anything from emsdk.

I eventually found a solution using conan info + awk:

source $(conan info  . --package-filter emsdk/3.1.23 --paths --only "package_folder" -pr:h emscripten -pr:b default 2>/dev/null | awk ' $2 != "" {print $2}')/bin/emsdk_env.sh
export PATH=$PATH:$(conan info  . --package-filter nodejs/16.3.0 --paths --only "package_folder" -pr:h emscripten -pr:b default 2>/dev/null |  awk ' $2 != "" {print $2}')/bin

But I feel like there’s got to be a simpler way that I’ve just missed somehow.

Solution – 1

I was able to use them by switching to the python config format.

from conans import ConanFile, CMake


class SFCFEDecompress(ConanFile):
    description = ""
    license = "MIT"
    settings = {"os": ["Emscripten"]}
    exports_sources = ["./*"]
    generators = ["cmake"]

    def _configure_cmake(self):
        cmake = CMake(self)
        cmake.configure(source_folder=".")
        return cmake

    def build(self):
        cmake = self._configure_cmake()
        cmake.build()
        cmake.install()

After this I run install with my profile and then run conan build.

Strange that this is a requirement since the txt format is supposed to be sufficient for package consumers, but c’est la vie I guess.

Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject