Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Can't find package configuration file for pre-build binary package #17148

Open
1 task done
dwswingle opened this issue Oct 10, 2024 · 3 comments
Open
1 task done
Assignees

Comments

@dwswingle
Copy link

dwswingle commented Oct 10, 2024

What is your question?

Hello,

I am trying to create a pre-built binary package and have it be consumed by a C++ CMake project. I'm currently getting the following error:

CMake Error at CMakeLists.txt:15 (find_package): Could not find a package configuration file provided by testme" with any of the following names: testmeConfig.cmake testme-config.cmake Add the installation prefix of "testme" to CMAKE_PREFIX_PATH or set "testme_DIR" to a directory containing one of the above files. If "testme" provides a separate development package or SDK, be sure it has been installed.

Here is my current conanfile.py below. What am I missing? I'm not sure how to add the CMake generation items in this:

import_ os
from conan.tools.files import get, copy
from conan import ConanFile

class helloRecipe(ConanFile):
    name = "testme"
    settings = "os", "arch"

    def set_version(self):
        self.version = os.environ['generated_version_tag']

    def build(self):
        get(self, "https://artifactory.test.com/artifactory/generic-sandbox/testme/testme-Linux_2.6_x86_64_gcc85-Release.tgz")        

    def package(self):
        copy(self, "*.h*", self.build_folder, os.path.join(self.package_folder, "include"))
        copy(self, "*.a", self.build_folder, os.path.join(self.package_folder, "lib"))
        copy(self, "*.so*", self.build_folder, os.path.join(self.package_folder, "lib"))
        copy(self, "*.lic", self.build_folder, os.path.join(self.package_folder, "licenses"))

    def package_info(self):
        self.cpp_info.libs = ["testme_cf",
                "testme_cxx",
                "testme_xml",
                "testme_provider",
                "testme_dyntype",
                "testme_dyntype_xml" ]
        self.cpp_info.includedirs = [ "include/testme/target/include",
                "include/testme/target/include/dds_cxx" ]
        self.cpp_info.libdirs = [ "lib/testme/target/Linux_2.6_x86_64_gcc85/lib" ]

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Oct 11, 2024
@memsharded
Copy link
Member

memsharded commented Oct 11, 2024

Hi @dwswingle

Thanks for your question.

The usage from the consumer side is as important as having the right recipe: which generators are you using, which commands...
If you can please report:

  • The conanfile you are using for consuming the package
  • The commands that you are executing
  • The full output of the commands

That might help to understand what could be missing.

Some extra tips:

  • This testing of a package you create is automatically done by test_package functionality: https://docs.conan.io/2/tutorial/creating_packages/test_conan_packages.html
  • In general the includedirs = ["include"] or something simple. Having "include/testme/target/include" is a little suspicious. The recommendation is that consumers should use #include "testme/path/to/include.h" with the testme explicit there to avoid collisions (if testme had a utils.h, which could also exist in another package)
  • Same for lib/testme/target/Linux_2.6_x86_64_gcc85/lib, typically you wan to have libdirs = ["lib"]. Conan will manage the variability of binaries, no need to have something like Linux_2.6_x86_64_gcc85 in that path. You can make the package() method to put things in the right place
  • os.environ['generated_version_tag'] you might better use the --version=myversion argument in command line, env-vars might be a bit problematic as being more global.

@dwswingle
Copy link
Author

dwswingle commented Oct 11, 2024

conanfile I'm using to consume the package:

from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.build import check_min_cppstd
from os import environ, path

class CoreRecipe(ConanFile):
    name = "core"
    package_type = "shared-library"
    exports_sources = "cmake/*", "example/*", "interface_builder/*", "cyclone_interface/*", "CMakeLists.txt"
    
    settings = "os", "compiler", "build_type", "arch"

    def requirements(self):
        self.requires("cyclonedds/0.10.4", transitive_libs=True, transitive_headers=True)
        self.requires("cyclonedds-cxx/0.10.4", transitive_libs=True, transitive_headers=True)
        self.requires("testme/v0.0.1")

        self.tool_requires("ninja/1.12.1")
        self.tool_requires("cmake/3.29.5")

    def set_version(self):
        self.version = environ['generated_version_tag']

    def validate(self):
        check_min_cppstd(self, "17")

    def layout(self):
        cmake_layout(self, generator="Ninja")

    def generate(self):
        deps = CMakeDeps(self)
        deps.generate()
        tc = CMakeToolchain(self, generator="Ninja")
        tc.variables["USING_CONAN"] = True
        tc.user_presets_path = 'ConanPresets.json'
        tc.generate()

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

    def package(self):
        cmake = CMake(self)
        cmake.install()

    def package_info(self):

        cmake_modules = list()
        cmake_modules.append(path.join("cmake/modules", "generated_dds_dependencies.cmake"))
        cmake_modules.append(path.join("cmake/modules", "generated_dds_interface.cmake"))
        cmake_modules.append(path.join("cmake/modules", "idl_rules.cmake"))
        self.cpp_info.set_property("cmake_build_modules", cmake_modules)

        self.cpp_info.components["CMakeScripts"].includedirs= ["cmake/modules"]
        self.cpp_info.components["InterfaceBuilder"].includedirs= ["scripts/InterfaceBuilder"]

commands executing:

conan install . -pr:b default-abi11 -pr:h default-abi11 -b missing -s build_type=Release
source build/Release/generators/conanbuild.sh
cmake --preset conan-Release
cmake --build --preset conan-Release
conan export-pkg . -pr:b default-abi11 -pr:h default-abi11 -s build_type=Release

fails on the build step:

CMake Error at example/CMakeLists.txt:15 (find_package):
  Could not find a package configuration file provided by "testme" with
  any of the following names:

    testmeConfig.cmake
    testme-config.cmake

  Add the installation prefix of "testme" to CMAKE_PREFIX_PATH or set
  "testme_DIR" to a directory containing one of the above files.  If
  "testme" provides a separate development package or SDK, be sure it
  has been installed.


-- Configuring incomplete, errors occurred!

I do have a test package that passes, but maybe I implemented it incorrect. Let me review that. Will also review the additional tips. thank you!

@memsharded
Copy link
Member

Thanks for sharing those details!

fails on the build step:

It seems you are using your own presets that include the Conan generated ones.
Can you post the full output of the cmake --preset conan-Release command?

One thing that could be related, though I am not sure if it would fix, is that you package (the exported-pkg one, not the consumer one) is missing a package_type. If it is a shared library, it should probably be package_type = "shared-library".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants