Search code examples
c++cmakeconan

Error installing header only package via conan


I have an internal header-only C++ library built with CMake. I followed conan's instructions on how to package header-only libraries and ended up with this conanfile.py:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Conan file for KVAPI.

https://docs.conan.io/en/latest/howtos/header_only.html
"""

from conans import ConanFile, CMake


class KVAPIConan(ConanFile):
    name = "kvapi"
    version = "0.1.0.0"
    description = "Kiwi API library"
    exports_sources = "include/*"
    topics = ("kv", "kvapi", "C++")
    no_copy_source = True

    def package(self):
        self.copy("*.hpp")

    def package_id(self):
        self.info.header_only()

I create the package thus:

> conan create . kvapi/0.1.0.0@kiwi/testing
> conan upload kvapi* -r genetec

and install it thusly:

> conan install kvapi/0.1.0.0@kiwi/testing

which results in the error:

Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=15
os=Windows
os_build=Windows
[options]
[build_requires]
[env]

kvapi/0.1.0.0@kiwi/testing: Retrieving from server 'genetec'
kvapi/0.1.0.0@kiwi/testing: Trying with 'genetec'...
Downloading conanmanifest.txt
[==================================================] 848B/638B
Downloading conanfile.py
[==================================================] 513B/456B
kvapi/0.1.0.0@kiwi/testing: Downloaded recipe revision 0
Installing package: kvapi/0.1.0.0@kiwi/testing
Requirements
    kvapi/0.1.0.0@kiwi/testing from 'genetec' - Downloaded
Packages
    kvapi/0.1.0.0@kiwi/testing:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Missing

kvapi/0.1.0.0@kiwi/testing: WARN: Can't find a 'kvapi/0.1.0.0@kiwi/testing' package for the specified settings, options and dependencies:
- Settings:
- Options:
- Dependencies:
- Package ID: 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9

ERROR: Missing prebuilt package for 'kvapi/0.1.0.0@kiwi/testing'
Try to build it from sources with "--build kvapi"
Or read "http://docs.conan.io/en/latest/faq/troubleshooting.html#error-missing-prebuilt-package"

Is this expected for a header-only library?


Solution

  • When uploading Conan packages you need to be explicit when you want to upload binary packages too.

    The command conan upload kvapi* -r genetec only upload the recipe, not the package created. To upload both recipe package and binary package, which contains those headers, you need to add the argument --all

    conan upload kvapi* -r genetec --all

    reference: https://docs.conan.io/en/latest/uploading_packages/uploading_to_remotes.html