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

[feature] Support for CMAKE_MODULE_LINKER_FLAGS #17539

Open
1 task done
tttapa opened this issue Dec 30, 2024 · 2 comments
Open
1 task done

[feature] Support for CMAKE_MODULE_LINKER_FLAGS #17539

tttapa opened this issue Dec 30, 2024 · 2 comments

Comments

@tttapa
Copy link

tttapa commented Dec 30, 2024

What is your suggestion?

Conan currently only supports CMAKE_SHARED_LINKER_FLAGS and CMAKE_EXE_LINKER_FLAGS, but lacks support for CMAKE_MODULE_LINKER_FLAGS. This causes issues when building e.g. Python extension modules and other plugins (any target created using add_library(tgt MODULE)). When a profile (or Conan itself) sets any shared linker flags, these are not applied to module targets.

In the short term, it may be easiest to just initialize the module linker flags to the same values as the shared linker flags in the CMakeToolchain generator, similar to what I've done here: a2a8d41
Longer-term, it would be nice to have a separate config option similar to tools.build:sharedlinkflags and tools.build:exelinkflags.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Dec 31, 2024
@memsharded memsharded added this to the 2.X milestone Dec 31, 2024
@memsharded
Copy link
Member

Hi @tttapa

Thanks for the feedback.

The thing is that MODULE package types are not explicitly defined in Conan yet.

I think it would make sense to add them to the model, though this is not a very straightforward thing, it needs to be done carefully, as it affects a lot of aspects in the traits propagation, computation of the package_id, etc.
Supporting CMAKE_MODULE_LINKER_FLAGS would come after the basic modeling is there, it is possible that defining new cpp_info.modulelinkerflags would also be necessary.

Lets try to start working on this, it might take some time to cover all the steps, but I think it would be a good feature for Conan.

@tttapa
Copy link
Author

tttapa commented Jan 1, 2025

Thanks! I'm currently using the workaround below (just to get the module to link correctly), but it would be nice to have plugin support in the Conan package model as you described.

[conf]
tools.cmake.cmaketoolchain:extra_variables*={"CMAKE_MODULE_LINKER_FLAGS_INIT": "${CMAKE_SHARED_LINKER_FLAGS_INIT}"}
tools.cmake.cmaketoolchain:extra_variables*={"CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT": "${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT}"}
tools.cmake.cmaketoolchain:extra_variables*={"CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT": "${CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT}"}
tools.cmake.cmaketoolchain:extra_variables*={"CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT": "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT}"}

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