通过柯南安装仅头文件包时出错

时间:2019-06-19 13:01:23

标签: c++ cmake conan

我有一个使用CMake构建的仅内部标头的C ++库。我遵循柯南的instructions来介绍如何打包仅标头的库,并最终得到了这个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()

我这样创建包:

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

并按以下方式安装:

> conan install kvapi/0.1.0.0@kiwi/testing

这会导致错误:

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"

这仅用于标头库吗?

1 个答案:

答案 0 :(得分:1)

上传Conan软件包时,还需要明确地上传二进制软件包。

命令conan upload kvapi* -r genetec仅上传配方,而不上传创建的包。要同时上传包含这些标头的配方包和二进制包,您需要添加参数--all

conan upload kvapi* -r genetec --all

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