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

Improved conan configuration (settings/options) approach [2.0] #3524

Closed
memsharded opened this issue Sep 11, 2018 · 7 comments
Closed

Improved conan configuration (settings/options) approach [2.0] #3524

memsharded opened this issue Sep 11, 2018 · 7 comments

Comments

@memsharded
Copy link
Member

There are several things that might require reviewing in conan 2.0:

  • Wildcard settings: -s *:build_type=Release -s build_type=Debug.
  • Access of upstream settings from conan recipes: self.settings["MyDep"].build_type
  • Conditional definition of default_options: How to set default_option based on some setting? #3519
  • Default values defined with config= for empty string
@DoDoENT
Copy link
Contributor

DoDoENT commented Sep 12, 2018

I think it would be good to have some method to check the current version of Conan being used so that during the transition it would be possible to write recipes that are both compatible with 1.x and 2.0.

Also, it would be nice to specify in the recipe the minimum required version of Conan, something like cmake_minimum_required( VERSION ) within CMake. Thus, it would be possible to restrict some recipes to only Conan 1.7+ or Conan 2.0+.

@DoDoENT
Copy link
Contributor

DoDoENT commented Sep 24, 2018

I am not sure if this is the main thread tracking all wishes for Conan v2.0, but if it is, I would also like to add Issue #3573.

@Lawrencemm
Copy link

I think I might need conditional setting of default options for my requirements: conan-community/community#168

@DoDoENT
Copy link
Contributor

DoDoENT commented Mar 21, 2019

@Lawrencemm, you can do that even in conan v1.x (see #3519):

consider this package:

class SomethingConan(ConanFile):
    ...
    options = { use_some_feature: [True, False] }

    def config_options(self):
        if self.options.use_some_feature == None:  # i.e. not specified on the command line
            if self.settings.os == 'Android':
                self.options.use_some_feature = True
            else:
                self.options.use_some_feature = False

It works with all kind of options (string options, enum options, boolean options). I use that pattern in my projects all over the place.

Just note that you must compare with == None and not with is None as some linters suggest. Checking with is will not work, as the option actually exists in the dictionary, but is not set yet (it's current value is None).

@DoDoENT
Copy link
Contributor

DoDoENT commented Mar 21, 2019

Also adding #4038 to the wishlist for Conan v2.0 (although I argue it should be possible to implement that feature even in v1.x, without breaking, as I described in the issue description).

@lasote lasote added the whiteboard Put in common label Apr 2, 2019
@lasote
Copy link
Contributor

lasote commented Apr 2, 2019

@memsharded I would like you to put in common these topics. This sounds like something we could start doing before 2.0 (if we consider it).

@memsharded
Copy link
Member Author

I think this concerns have been addressed in 2.0 betas:

Wildcard settings: -s *:build_type=Release -s build_type=Debug.

Doable, and the pattern matching has been improved, with better priority based on cli (or profile) order argument

Access of upstream settings from conan recipes: self.settings["MyDep"].build_type

It is already possible with self.dependencies["mydep"].settings

Conditional definition of default_options: #3519

Already changed the priority, so defining values conditionally on recipe configure methods works fine without invalidating profile priority

Default values defined with config= for empty string

The above linked PR shows this is already possible and works fine.

Lets close this issue, if there is something pending or not clear, please report.

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

No branches or pull requests

4 participants