簡體   English   中英

帶有 cmake-conan 的柯南缺少 conanbuild.conf

[英]Conan with cmake-conan missing conanbuild.conf

我想用柯南打包一個 CMake 項目。 為此,我使用以下conanfile.py

import os
from conans import ConanFile, tools
from conan.tools.cmake import CMake, CMakeToolchain
from conans.tools import Version

class BaseLibrary(ConanFile):
    name = "base-library"
    version = "1.0.0"
    description = """This is a test project with a library base::io
    and base::math and an executable cli."""
    license = "MIT"
    generators = "cmake_find_package_multi", "cmake_find_package",
    default_options = {"fmt:shared": True}
    build_policy = "missing"  # if this package is build by default if missing.
    settings = "os", "compiler", "build_type", "arch"
    exports_sources = "*"

    _cmake = None

    def requirements(self):
        if Version(self.version) >= "1.0.0":
            self.requires("fmt/8.0.1")

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

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

    def package(self):
        cmake = self._configure_cmake()
        cmake.install()
        tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
        tools.rmdir(os.path.join(self.package_folder, "share"))

    def package_info(self):
        self.cpp_info.names["cmake_find_package"] = "base"
        self.cpp_info.names["cmake_find_package_multi"] = "base"
        self.cpp_info.names["pkg_config"] = "base"

它位於我的主要CMakeLists.txt文件旁邊。 CMake 項目構建沒有問題,並且還有一個正確的install目標,可以正確安裝所有內容: bin,lib,include,share 在 CMake 中,我使用conan-cmake模塊,基本上是這樣的

當我跑

conan create -s build_type=Release . demo/testing

我收到以下奇怪的錯誤:

...
Requirements
    base-library/1.0.0@demo/testing from local cache - Cache
    fmt/8.0.1 from 'conancenter' - Cache
Packages
    base-library/1.0.0@demo/testing:4f2b14d304ab8e4391d162a6eb44110cc27a3faa - Build
    fmt/8.0.1:d4e9c4f02b4f03edf5a640dcd22779727d782e79 - Cache

Installing (downloading, building) binaries...
fmt/8.0.1: Already installed!
base-library/1.0.0@demo/testing: WARN: Build folder is dirty, removing it: /home/developer/.conan/data/base-library/1.0.0/demo/testing/build/4f2b14d304ab8e4391d162a6eb44110cc27a3faa
base-library/1.0.0@demo/testing: Configuring sources in /home/developer/.conan/data/base-library/1.0.0/demo/testing/source
base-library/1.0.0@demo/testing: Copying sources to build folder
base-library/1.0.0@demo/testing: Building your package in /home/developer/.conan/data/base-library/1.0.0/demo/testing/build/4f2b14d304ab8e4391d162a6eb44110cc27a3faa
base-library/1.0.0@demo/testing: Generator cmake_find_package created Findfmt.cmake
base-library/1.0.0@demo/testing: Generator cmake_find_package_multi created fmt-config-version.cmake
base-library/1.0.0@demo/testing: Generator cmake_find_package_multi created fmt-config.cmake
base-library/1.0.0@demo/testing: Generator cmake_find_package_multi created fmtTargets.cmake
base-library/1.0.0@demo/testing: Generator cmake_find_package_multi created fmtTarget-release.cmake
base-library/1.0.0@demo/testing: Aggregating env generators
base-library/1.0.0@demo/testing: Calling build()
base-library/1.0.0@demo/testing: 
base-library/1.0.0@demo/testing: ERROR: Package '4f2b14d304ab8e4391d162a6eb44110cc27a3faa' build failed
base-library/1.0.0@demo/testing: WARN: Build folder /home/developer/.conan/data/base-library/1.0.0/demo/testing/build/4f2b14d304ab8e4391d162a6eb44110cc27a3faa
ERROR: base-library/1.0.0@demo/testing: Error in build() method, line 74
        cmake = self._configure_cmake()
while calling '_configure_cmake', line 65
        self._cmake = CMake(self)
        ConanException: The file /home/developer/.conan/data/base-library/1.0.0/demo/testing/build/4f2b14d304ab8e4391d162a6eb44110cc27a3faa/conanbuild.conf does not exist. Please, make sure that it was not generated in another folder.

這里有什么問題,我該如何解決? 我找不到與此相關的任何內容?

from conans import ConanFile, CMake
...

def build(self):
    cmake = CMake(self)
    cmake.configure()
    cmake.build()
...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM