apache / celix

Apache Celix is a framework for C and C++14 to develop dynamic modular software applications using component and in-process service-oriented programming.
https://celix.apache.org/
Apache License 2.0
160 stars 85 forks source link

Conan V2 CMake dependencies #642

Closed SkyWhiteEagle closed 10 months ago

SkyWhiteEagle commented 10 months ago

Hi,

I am trying to make a project using Celix. I am using Conan V2 and CMake to build the project.

I locally exported the Conan recipe from the master branch (e1d7fc1b544bc2c43cbcdb6b76f1b66fffccad96, as far as I can tell, the previous release is not Conan V2 compatible) and required it in my consumer recipe. I set the following options:

    default_options = {
        "celix/*:build_framework": True,
        "celix/*:build_shell_tui": True,
        "celix/*:build_shell_wui": True,
    }

I have the following generators:

    def generate(self):
        # This generates "conan_toolchain.cmake" in self.generators_folder
        tc = CMakeToolchain(self)
        tc.generate()

        # This generates "foo-config.cmake" and "bar-config.cmake" in self.generators_folder
        deps = CMakeDeps(self)
        deps.generate()

In my CMake I have:

find_package(Celix)

add_celix_container(TestCelixContainer CXX
    BUNDLES
        Celix::ShellCxx
        Celix::shell_tui
)

Running CMake, I get the warning following warning, but the build files are written nonetheless.

CMake Warning at build/Debug/generators/libuuidTargets.cmake:25 (message):
  Target name 'LibUUID::LibUUID' already exists.

I then proceed to build and get warning: libzip.so.5, needed by followed by undefined from libzip.

Manually adding the following to the CMake fixes the issue:

find_package(libzip)

target_link_libraries(TestCelixContainer
    PRIVATE
        libzip::zip
)

I don't think this is the intended behavior, is there maybe a way for the Celix recipe or helper function to add the missing link?

PengZheng commented 10 months ago

It is a known Conan bug: https://github.com/conan-io/conan/issues/7192 Note that libzip::zip is a private dependency of Celix::utils.

We also encountered this in Celix, so a workaround is adopted: https://github.com/apache/celix/blob/master/conanfile.py#L424-L428 This workaround only ignores this particular link time error. At runtime, dynamic loader should be able to find all dependencies.

PengZheng commented 10 months ago

I'll close it now. If the issue remains, feel free to reopen it.

SkyWhiteEagle commented 10 months ago

Thanks, not sure where GitHub notifications are going.

I think I'll keep the explicit link workaround for now since I understand it better. I looked around the documents file, seeing if I could add note just to find I had missed the already existing section. Sorry.