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

[bug] default_options ignored for dependencies #13449

Closed
friendlyanon opened this issue Mar 15, 2023 · 2 comments
Closed

[bug] default_options ignored for dependencies #13449

friendlyanon opened this issue Mar 15, 2023 · 2 comments
Assignees

Comments

@friendlyanon
Copy link
Contributor

Environment details

  • Operating System+version: Windows 10 2H22 (19045.2728)
  • Compiler+version: Microsoft (R) C/C++ Optimizing Compiler Version 19.35.32215 for x64
  • Conan version: 2.0.2
  • Python version: 3.10.8

Steps to reproduce

Given the conanfile.py:

from conan import ConanFile


class Recipe(ConanFile):
    settings = "os", "compiler", "build_type", "arch"
    generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
    default_options = {
        "catch2/*: with_main": True, # space before with_main doesn't matter
    }

    def layout(self):
        self.folders.generators = "conan"

    def requirements(self):
        self.requires("hedley/15")
        self.requires("json-c/0.16")

    def build_requirements(self):
        self.test_requires("catch2/2.13.9")

Running conan install . -b missing will produce a Catch2 CMake package that does not have the target Catch2::Catch2WithMain despite the option requiring it.

Logs

$ cmake ...
...
-- Conan: Target declared 'Catch2::Catch2'
...
CMake Error at test/CMakeLists.txt:15 (target_link_libraries):
  Target "proj_test" links to:

    Catch2::Catch2WithMain

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.
...
@memsharded memsharded self-assigned this Mar 15, 2023
@memsharded
Copy link
Member

Hi @friendlyanon

this is a known issue at the moment, we are having a look
You need to define the options in the self.tool_requires(..., options = {}) to define them. The default_options only target "host" requirements at the moment. We don't know if this will change or not, but the self.tool_requires(... ,options={}) would be guaranteed to work now and in the future.

@memsharded
Copy link
Member

This would be a duplicate of #13414, closing this one, follow the previous one please. Thanks for reporting!

@memsharded memsharded closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2023
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

2 participants