conan-io / docs

conan.io reStructuredText documentation
http://docs.conan.io
MIT License
104 stars 356 forks source link

[question] What does "auto_shared_fpic" manage? #3782

Open andrey-zherikov opened 3 months ago

andrey-zherikov commented 3 months ago

What is your question?

This doc says:

"auto_shared_fpic": automatically manages fPIC and shared options

This says:

Options automatically managed:
- fPIC (True, False).
- shared (True, False).
- header_only (True, False).

And this one says:

Options automatically managed:
- fPIC (True, False).

What does auto_shared_fpic actually do?

Have you read the CONTRIBUTING guide?

andrey-zherikov commented 3 months ago

Note that if I don't have shared in options, conan 2.4.1 errors out:

ERROR: mylib/1.0: Package type is 'library', but no 'shared' option declared
memsharded commented 3 months ago

Hi @andrey-zherikov

Thanks for your question.

This is the injected code:

# injected in ``config_options()`` method
def auto_shared_fpic_config_options(conanfile):
    if conanfile.settings.get_safe("os") == "Windows":
        conanfile.options.rm_safe("fPIC")

# injected in ``configure()`` method
def auto_shared_fpic_configure(conanfile):
    if conanfile.options.get_safe("header_only"):
        conanfile.options.rm_safe("fPIC")
        conanfile.options.rm_safe("shared")
    elif conanfile.options.get_safe("shared"):
        conanfile.options.rm_safe("fPIC")

Note that if I don't have shared in options, conan 2.4.1 errors out:

Yes, this is expected. Defining package_type = "library" means that a shared option must be defined.

Please let me know if this clarifies the issue. Thanks!

andrey-zherikov commented 3 months ago

@memsharded Thanks for the clarification! Could you please make documentation clearer and consistent?

memsharded commented 3 months ago

Sure, moving this to the docs repo. As you can see, the docs is also an open source Git repo, improvements and contributions are also welcomed.