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

[bug] CMake can't resolve libraries of conan editable packages with subprojects #13982

Closed
zubrailx opened this issue May 27, 2023 · 2 comments · Fixed by #13983
Closed

[bug] CMake can't resolve libraries of conan editable packages with subprojects #13982

zubrailx opened this issue May 27, 2023 · 2 comments · Fixed by #13983
Assignees
Milestone

Comments

@zubrailx
Copy link

zubrailx commented May 27, 2023

Environment details

  • Operating System+version: Linux host 6.1.19-gentoo-x86_64
  • Compiler+version: gcc (Gentoo 12.2.1_p20230428-r1 p2) 12.2.1
  • Conan version: Conan version 2.0.6
  • Python version: Python 3.11.3

Steps to reproduce

Description

I tried to rewrite example examples2/tutorial/developing_packages/editable_packages using submodules hello and say, but when I did it CMake stopped resolving libraries frommodules on which it depends (from say module in case of cmake cache generation for hello).

Configuration

say/conanfile.py:

from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout

class SayConan(ConanFile):
    name = "say"
    version = "1.0"

    # Binary configuration
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False], "fPIC": [True, False]}
    default_options = {"shared": False, "fPIC": True}

    # Sources are located in the same place as this recipe, copy them to the recipe
    exports_sources = "CMakeLists.txt", "src/*", "include/*"

    _folders_rel_root = ".."
    _folders_rel_sub = "say"

    def config_options(self):
        if self.settings.os == "Windows":
            del self.options.fPIC

    def layout(self):
        self.folders.root = self._folders_rel_root
        self.folders.subproject = self._folders_rel_sub
        cmake_layout(self)

    def generate(self):
        tc = CMakeToolchain(self)
        tc.generate()

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

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

    def package_info(self):
        self.cpp_info.libs = ["say"]

hello/conanfile.py:

from conan import ConanFile
from conan.tools.cmake import cmake_layout

class HelloConan(ConanFile):
    name = "hello"
    version = "1.0"

    settings = "os", "compiler", "build_type", "arch"

    generators = "CMakeToolchain", "CMakeDeps"
    requires = "say/1.0"

    _folders_rel_root = ".."
    _folders_rel_sub = "hello"

    def layout(self):
        self.folders.root = self._folders_rel_root
        self.folders.subproject = self._folders_rel_sub
        cmake_layout(self)

Steps

  1. Go to root of current example
  2. Add say to editable conan editable add say
  3. Execute in order for say:
cd say
conan install .
cmake --preset conan-release
cmake --build --preset conan-release
cd ..
  1. Now try the same for hello:
cd hello
conan install .
cmake --preset conan-release # <- cmake error

Logs

(conan) nikit@host hello % cmake --preset conan-release
Preset CMake variables:

  CMAKE_BUILD_TYPE="Release"
  CMAKE_POLICY_DEFAULT_CMP0091="NEW"
  CMAKE_TOOLCHAIN_FILE:FILEPATH="/home/nikit/Workspaces/research/conan/simple/examples2/tutorial/developing_packages/editable_packages/hello/build/Release/generators/conan_toolchain.cmake"

-- Using Conan toolchain: /home/nikit/Workspaces/research/conan/simple/examples2/tutorial/developing_packages/editable_packages/hello/build/Release/generators/conan_toolchain.cmake
-- Conan toolchain: C++ Standard 20 with extensions OFF
-- Conan: Target declared 'say::say'
CMake Error at build/Release/generators/cmakedeps_macros.cmake:64 (message):
  Library 'say' not found in package.  If 'say' is a system library, declare
  it with 'cpp_info.system_libs' property
Call Stack (most recent call first):
  build/Release/generators/say-Target-release.cmake:24 (conan_package_library_targets)
  build/Release/generators/sayTargets.cmake:26 (include)
  build/Release/generators/say-config.cmake:16 (include)
  CMakeLists.txt:5 (find_package)
@memsharded
Copy link
Member

Hi @zubrailx

Thanks for reporting and for the detailed and minimal repro case, it really helps to investigate.
Indeed it seems a gap in editable packages I am exploring a solution in #13983, I still need to add tests, etc, but it seemed it solved your repro case.

Adding this to the next 2.0.7 release.

@memsharded
Copy link
Member

Fixed in #13983 for next 2.0.7

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

Successfully merging a pull request may close this issue.

2 participants