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 make a single tool package for debug and release builds in Conan 2.0 #14894

Closed
1 task done
rconde01 opened this issue Oct 8, 2023 · 4 comments
Closed
1 task done

Comments

@rconde01
Copy link

rconde01 commented Oct 8, 2023

What is your question?

I have a package which builds a tool. I always want a release build of this tool despite what the consumer is using. I am using CMakeToolchain and CMake classes. I think I can force CMAKE_BUILD_TYPE in CMakeToolchain, but CMake is insisting the package needs a build_type setting - which would mean I need to duplicate the package for debug/release. Is there a way to accomplish what I want?

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@rconde01
Copy link
Author

rconde01 commented Oct 8, 2023

My workaround here was just to use cmake via command line...is that the recommended approach?

@fschoenm
Copy link

fschoenm commented Oct 9, 2023

What I did is exclude the build_type from the package ID. You'll still have to specify the build_type when creating the package but you'll only have one package:

    def package_id(self):
        self.info.settings.rm_safe("build_type")

Not sure if that's the recommended approach though. There's also some documentation about this: https://docs.conan.io/2/tutorial/creating_packages/other_types_of_packages/tool_requires_packages.html#removing-settings-in-package-id

@memsharded
Copy link
Member

Hi @rconde01

Thanks for your question.
Note that there could be different strategies for this:

I have a package which builds a tool. I always want a release build of this tool despite what the consumer is using.

For tool_requires note that these tool-requires are always in the "build" context, and always receive the "build" profile. And the "build" profile should typically be build_type=Release, using the tools in Debug mode does not make sense in most cases. And if there are some cases that some tool-require wants to be debugged, then it is great that the build_type=Debug is possible.

So a perfectly valid and very simple strategy is to do nothing, and just rely on the build_type=Release of the build profile.

In any case, I think the use case that you are exposing should be easier to implement with the CMake integration once this PR is merged: #14780, please have a look to the test, which in short:

  • Removes the build_type setting
  • Forces the build_type=Release in the recipe.

@memsharded
Copy link
Member

Closing as responded by the last comment.

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

3 participants