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] How to require a build requirement #26444

Open
elvisdukaj opened this issue Jan 22, 2025 · 0 comments
Open

[question] How to require a build requirement #26444

elvisdukaj opened this issue Jan 22, 2025 · 0 comments
Labels
question Further information is requested

Comments

@elvisdukaj
Copy link
Contributor

What is your question?

I have the following tool packages my-toolchain and some binary utilities tool-1, tool-2. Then I have a library my-lib that needs the toolchain in otder to build. my-lib is also containging some cmake files that is using these tools.

my-lib is having something similar to the following snippet in the package_info:

    def package_info(self):
       # ...

        # extra cmake modules to be included when using find_package
        build_modules = [
            os.path.join(self._cmake_install_base_path, "tool-1.cmake"),
            os.path.join(self._cmake_install_base_path, "tool-2.cmake"),
            os.path.join(self._cmake_install_base_path, "tool-3.cmake"),
        ]
        self.cpp_info.set_property("cmake_build_modules", build_modules)

My issue is that is that these tools are not really required to build my-library but are more for who is linking agains the library. Ideally the client code should just do something like:

[requires]
my-library/version

[generators]
CMakeDeps
CMakeToolchain

[layout]
cmake_layout

And in the CMakeFiles:

# the following line makes the tools visible in the PATH and pulls the tool-*.cmake files
find_package(my-library::my-library CONFIG REQUIRED) 

I don't know how to achieve this with CMake. What I was trying is to expose from my-lib the tool requirements, which is not a good practice, but I don't know how to do this better.

As a workaround I put some error message in the cmake files that are added by my-lib to include the proper tool_requires and added this tool_requires in the profile. But I don't like this approach because the my-lib and the tool require connection is hidden and it's hard to make more explicit.

As alternative I could put self.tool_require("tool-1/version", visible=True) but this was not recomended. What are other options to accomplish this?

@elvisdukaj elvisdukaj added the question Further information is requested label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant