Skip to content

Conversation

perseoGI
Copy link
Contributor

@perseoGI perseoGI commented Sep 5, 2024

Summary

Changes to recipe: gsl-lite/all

Motivation

In this very old PR #5521, user request to have the possibility of not defining a concrete on_contract_violation policy. Instead, let downstream decide.

Details

Close #5521


@@ -24,7 +24,7 @@ class GslLiteConan(ConanFile):
# 3. GSL_UNENFORCED_ON_CONTRACT_VIOLATION: nothing happens
#
options = {
"on_contract_violation": ["terminate", "throw", "unenforced"]
"on_contract_violation": ["terminate", "throw", "unenforced", "None"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None is not a good name in this case, it gets too close to options being able to not be defined

@conan-center-bot
Copy link
Contributor

Conan v1 pipeline ✔️

All green in build 1 (ff011a875c933556760e792faf360e4d9d9077b6):

  • gsl-lite/0.41.0:
    All packages built successfully! (All logs)

  • gsl-lite/0.40.0:
    All packages built successfully! (All logs)

  • gsl-lite/0.38.1:
    All packages built successfully! (All logs)

  • gsl-lite/0.39.0:
    All packages built successfully! (All logs)

  • gsl-lite/0.38.0:
    All packages built successfully! (All logs)

  • gsl-lite/0.37.0:
    All packages built successfully! (All logs)


Conan v2 pipeline ✔️

Note: Conan v2 builds are now mandatory. Please read our discussion about it.

All green in build 1 (ff011a875c933556760e792faf360e4d9d9077b6):

  • gsl-lite/0.41.0:
    All packages built successfully! (All logs)

  • gsl-lite/0.37.0:
    All packages built successfully! (All logs)

  • gsl-lite/0.40.0:
    All packages built successfully! (All logs)

  • gsl-lite/0.39.0:
    All packages built successfully! (All logs)

  • gsl-lite/0.38.1:
    All packages built successfully! (All logs)

  • gsl-lite/0.38.0:
    All packages built successfully! (All logs)

@jcar87 jcar87 self-assigned this Sep 6, 2024
@jcar87
Copy link
Contributor

jcar87 commented Sep 6, 2024

In terms of implementation, easiest in these cases, rather than have None as a valid value, is to simply remove it from the default_options, and then access it with get_safe - it will remain undefined unless it is done explicitly. Has the same effect but it's less code (and arguably, a better reflection of the situation).

secondary to this, changing the behaviour of a default option will impact users that may already be relying on the previous default behaviour. we may break them or cause their own apps to behave differently. We need to evaluate the risk in this case (and any cases where we change a default). I would try and determine that before merging this PR.

And more generally - we should re-evalaute the pattern in Conan Center for header only libraries to propagate compiler flags to consumer via Conan options. The typical use outside of Conan would be for the consumers to do a #define before doing an #include. I would only consider the "option" approach if the upstream project is able to generate targets in the -config.cmake files where the imported targets propagate it as a compiler flag, and if this is configurable at build time. So reflect how the library may be used outside of Conan Center, rather than invent a new pattern.

@perseoGI perseoGI force-pushed the pgi/gsl-lite-none-contract-violation branch from ff011a8 to e1ab9f8 Compare July 18, 2025 08:45
@jcar87 jcar87 merged commit 78839d3 into conan-io:master Jul 21, 2025
7 checks passed
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

Successfully merging this pull request may close these issues.

[package] gsl-lite/0.38.1: Contract violation usability issue
4 participants