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

Set some CMakeDeps properties from consumer #12609

Merged
merged 13 commits into from
Nov 29, 2022

Conversation

czoido
Copy link
Contributor

@czoido czoido commented Nov 25, 2022

Changelog: Feature: Provide the ability to set CMakeDeps properties from consumer side.
Docs: conan-io/docs#2827

Gives you the possibility to overwrite some properties set in dependencies in CMakeDeps: cmake_file_name, cmake_target_name, cmake_find_mode, cmake_module_file_name and cmake_module_target_name

The interface is:

def generate(self):
    deps = CMakeDeps(self)
    deps.set_property("<dep>", "cmake_find_mode", "module")
    deps.set_property("<dep>::<component>",  "cmake_target_name", "mycompname")
    deps.generate()

for the cases with build_context_activated:

def generate(self):
    ...
    deps = CMakeDeps(self)
    deps.set_property("<dep>", "cmake_find_mode", "module", build_context=True)
    deps.set_property("<dep>::<component>",  "cmake_target_name", "mycompname", build_context=True)
    deps.generate()
    ...

You can also invalidate from consumer the properties set upstream assigning a None:

def generate(self):
    ...
    deps.set_property("<dep>", "cmake_module_target_name",  None)

Closes: #12534
Close #7118

@czoido czoido added this to the 1.55 milestone Nov 25, 2022
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

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

Looks good, clean and promising to deliver something useful.
A couple minor things to discuss, good job.

conan/tools/cmake/cmakedeps/cmakedeps.py Outdated Show resolved Hide resolved
conan/tools/cmake/cmakedeps/cmakedeps.py Show resolved Hide resolved
conan/tools/cmake/cmakedeps/cmakedeps.py Outdated Show resolved Hide resolved
@czoido czoido marked this pull request as ready for review November 28, 2022 13:19
@SpaceIm
Copy link
Contributor

SpaceIm commented Nov 28, 2022

Looks very promising for conan-center as well, to avoid breakage in recipes when their dependencies break these properties (for example when suddenly a new version of a library implements a CMake config file, we have to update these names in this recipe, but it can break downstream recipes which were relying on default values <recipeName>-config.cmake & target <recipeName>::<recipeName>).

conan/tools/cmake/cmakedeps/cmakedeps.py Outdated Show resolved Hide resolved
conan/tools/cmake/cmakedeps/cmakedeps.py Outdated Show resolved Hide resolved
Copy link
Contributor

@franramirez688 franramirez688 left a comment

Choose a reason for hiding this comment

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

It looks great! 👏

Copy link
Contributor

@jcar87 jcar87 left a comment

Choose a reason for hiding this comment

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

This is amazing!!!

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