-
Notifications
You must be signed in to change notification settings - Fork 988
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: add property "cmake_target_aliases" to create some CMake alias targets (CMakeDeps) #8533
Feature: add property "cmake_target_aliases" to create some CMake alias targets (CMakeDeps) #8533
Conversation
if someone has better ideas for UX, please share. right now it requires modifications in two methods:
it would be nice, if one tool invocation could set everything needed (e.g.
I am not sure if there is a nice way to break a vicious circle, and reduce the chance of mistake and amount of code needed. |
Up! |
Would like to know the feedback from @memsharded and @lasote about this issue. I am not sure, but I believe this use case is already considered in the new cpp_info model and doing this will not be necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try a different approach:
- Define a
cpp_info.set_property()
that defines this data - Have the
CMakeDeps
generator to honor this property and generate the necessary alias or cmake code to implement this - Recipes code should be just 1 line with the set_property definition
9409a5d
to
2545236
Compare
@memsharded I've spent some type to prototype something with better UX via
or for components alias:
pros:
we may add custom CMake variables a similar way |
I am sold on the idea! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice! but we cannot implement it in the cmake_find_package_multi
and not in the CMakeDeps
. It should be considered "the king" and "the king" goes first.
sure, I can implement it in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like this feature only in CMakeDeps.
It doesn't make much sense to provide it in the legacy, have some recipes update to support this in cmake_find_package_xxx
, then remove that generator for CMakeDeps
.
conans/test/functional/generators/cmake_find_package_multi_test.py
Outdated
Show resolved
Hide resolved
2545236
to
03d110c
Compare
@memsharded I finally had some time to revisit it, now I've changed code to your suggestions:
and a new UX, for global aliases:
for component aliases:
and I think only dict values make sense, as they are explicit and straightforward - alias target is always specified. |
If this property should supposedly be used for each component to create an alias, why does it need to be a dict?
I also find having 2 properties for global aliases and component aliases potentially confusing. |
if you ever want to create an alias to the target other than the current component? maybe it's useless, in that case, array would be enough.
yes, it knows the name of the original target. I am not sure if this extra flexibility is needed.
it is possible, but I think there are recipes that don't define any components, and there are recipes using components. |
I don't know the Conan implementation, but can't it detect it from the context?
versus
|
The only use I can think of would be to create an alias of a target of a dependency. But I haven't yet seen a need for this. |
@madebr I've added an automatic deduction of an alias target, now the UX is:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good. I was not convinced about the alias, not distingüising the namespace, but now I see is simpler this way.
conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py
Outdated
Show resolved
Hide resolved
conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py
Outdated
Show resolved
Hide resolved
conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py
Show resolved
Hide resolved
Signed-off-by: SSE4 <tomskside@gmail.com>
Signed-off-by: SSE4 <tomskside@gmail.com>
…ps_aliases.py Co-authored-by: Luis Martinez de Bartolome Izquierdo <lasote@gmail.com>
…ps_aliases.py Co-authored-by: Luis Martinez de Bartolome Izquierdo <lasote@gmail.com>
Signed-off-by: SSE4 <tomskside@gmail.com>
Signed-off-by: SSE4 <tomskside@gmail.com>
Signed-off-by: SSE4 <tomskside@gmail.com>
Signed-off-by: SSE4 <tomskside@gmail.com>
Signed-off-by: SSE4 <tomskside@gmail.com>
1e1a966
to
16556f3
Compare
* - CMakeDeps: add cmake_target_aliases property Signed-off-by: SSE4 <tomskside@gmail.com> * - automatically deduce an alias target Signed-off-by: SSE4 <tomskside@gmail.com> * Update conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py Co-authored-by: Luis Martinez de Bartolome Izquierdo <lasote@gmail.com> * Update conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py Co-authored-by: Luis Martinez de Bartolome Izquierdo <lasote@gmail.com> * - add comment Signed-off-by: SSE4 <tomskside@gmail.com> * - use cpp_info instead of new_cpp_info Signed-off-by: SSE4 <tomskside@gmail.com> * - remove useless checks Signed-off-by: SSE4 <tomskside@gmail.com> * - show a warning if target already exists Signed-off-by: SSE4 <tomskside@gmail.com> * - test case for cmake_target_name/cmake_target_namespace Signed-off-by: SSE4 <tomskside@gmail.com> Co-authored-by: Luis Martinez de Bartolome Izquierdo <lasote@gmail.com>
…st profile and win_bash (#9755) * tests that prove bad behavior * wip * workaround for win_bash for .bat files * wip * wip * removed printing traceback * fixing tests * fixing tests * fix test * try fix py27 * wip * wip * Update conan/tools/env/environment.py Co-authored-by: Luis Martinez de Bartolome Izquierdo <lasote@gmail.com> * Update conan/tools/microsoft/subsystems.py Co-authored-by: Luis Martinez de Bartolome Izquierdo <lasote@gmail.com> * Fix unsafe check of the compiler in the CMakeToolchain generator (#9801) The compiler variable here must not be a NoneType object to use `in`. This will result in an error when attempting to package a header-only library. This commit fixes this check. It first verifies the compiler is not None before checking it. * Fix typo where fPIC option is not templated, so it is always enabled (#9752) * Fix typo where fPIC option is not templated, so it is always enabled * Fix typo where fPIC option is not templated, so it is always enabled * Add name to contributors * Don't add fPIC functionality when it is not set * Add unit tests * Remove extra newlines * Use "ON" and "OFF" for fPIC value in CMake * Fix typos * Correctly setup options for ConanFile Mocks * Add missing fixture annotations * Initialize options and default options dictionaries and fix Windows test * Properly check if the OS is Windows * Fix more typos * Make sure to set OS as Windows for unit test ConanFiles * Revert "Properly check if the OS is Windows" This reverts commit 7eebbde. * rename ConanFileInterface.new_cpp_info (#9800) * rename ConanFileInterface.new_cpp_info * wip * wip * fix policy=never (#9817) * Feature: create alias targets (#8533) * - CMakeDeps: add cmake_target_aliases property Signed-off-by: SSE4 <tomskside@gmail.com> * - automatically deduce an alias target Signed-off-by: SSE4 <tomskside@gmail.com> * Update conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py Co-authored-by: Luis Martinez de Bartolome Izquierdo <lasote@gmail.com> * Update conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py Co-authored-by: Luis Martinez de Bartolome Izquierdo <lasote@gmail.com> * - add comment Signed-off-by: SSE4 <tomskside@gmail.com> * - use cpp_info instead of new_cpp_info Signed-off-by: SSE4 <tomskside@gmail.com> * - remove useless checks Signed-off-by: SSE4 <tomskside@gmail.com> * - show a warning if target already exists Signed-off-by: SSE4 <tomskside@gmail.com> * - test case for cmake_target_name/cmake_target_namespace Signed-off-by: SSE4 <tomskside@gmail.com> Co-authored-by: Luis Martinez de Bartolome Izquierdo <lasote@gmail.com> * Fix pkgconfig tests for Windows (#9833) * Fixed all the tests in Windows * Added mingw32-g++ tool for Windows * Get rid of mingw32-g++ specific tool * Changed appending symbol to overwriting one * renaming to scope * more scopes * fix test * Update conans/test/integration/toolchains/env/test_virtualenv_winbash.py Co-authored-by: Carlos Zoido <mrgalleta@gmail.com> Co-authored-by: Luis Martinez de Bartolome Izquierdo <lasote@gmail.com> Co-authored-by: Jordan Williams <jordan@jwillikers.com> Co-authored-by: SSE4 <tomskside@gmail.com> Co-authored-by: Francisco Ramírez <franchuti688@gmail.com> Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
@SSE4 is there any kind of documentation for this feature? I think it could be interesting to have a little explanation there, couldn't it? |
@memsharded Why? It prevents adoption of this new property in conan-center until conan v2, because it would break many downstream recipes or users (we can't know which generator is used by downstream). With this strategy, we have to keep ugly workarounds in CCI. |
I have also another comment, slightly off-topic: If |
my two cents, just a personal opinion
so |
From #10005 (comment), I understand that |
I totally agree, we shouldn't pollute the CMake scope with targets no one needs. |
@SpaceIm we have discussed an issue internally, and have the following proposal:
there are still details to be figured out, we're going to open new issue and invite you to the discussion hopefully, another wave of |
I like this new logic.
Ok, so it's urgent to do nothing in CCI, except go back to Question: What will be the name of the component when you call |
that's an interesting question, and probably will require some investigation.
is it possible that I do |
Changelog: Feature: Add property "cmake_target_aliases" to create some CMake alias targets using CMakeDeps.
Docs: omit
closes: #8360
develop
branch, documenting this one.Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.