-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add cmake_extra_file_names property for CMakeConfigDeps
#18821
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
Open
AbrilRBS
wants to merge
5
commits into
conan-io:develop2
Choose a base branch
from
AbrilRBS:ar/cmake-extra-file-names
base: develop2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
63a6359
Extra file names sketch
AbrilRBS 3ad27b1
Improve test
AbrilRBS 3043460
Merge branch 'develop2' into ar/cmake-extra-file-names
AbrilRBS c19480f
make unexpected target check a FATAL_ERROR
AbrilRBS 376e0f9
Merge branch 'ar/cmake-extra-file-names' of github.com:AbrilRBS/conan…
AbrilRBS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are we sure the
find_dependency()approach is the best one?Why not:
include(config.filename)?config.content()in each file?I am a bit concerned the extra
find_dependency()might have corner cases, it might kind of change the actual dependency graph of cmake files?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.
cc @jcar87 who suggested this approach
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 theres' a few conflicting use cases.
Currently we have a gap between
foobar-config.cmakeand the ability to locate it viafind_package().The CMake documentation for
find_packagestates that:That is, if the package is called
FooBar, FOOBAR,FooBARFOOBar, CMake will find it correctly viafoobar-config.cmake`, example:all of the above are all satisfied by
foobar-config.cmake, and CMake sets<name-you-searched-for>_FOUND)to `True.However, that is does NOT currently work with
CMakeConfigDeps, as we don't place the file in the search path, but define<name>_DIRinstead.The advantage of this approach is that we avoid the search altogether, so we minimise the risk of finding the wrong config file (e.g. when crossbuilding in some instances), the disadvantage is that we lose the ability to use names with different upper/lower case letters than the generated filename.
An example of this is
libxml2-config.cmake(generated by the upstream project) which happily works withfind_package(LibXml2)(using the name of the legacy built-in module), but does not work withCMakeConfigDeps(yet).So a possible way to support this, would be for
cmake_extra_file_namesto ensure that every "alternative" name has axxx_DIRentry inconan_cmakedeps_paths.cmake.That would eliminate the need of generating additional files, on the condition that the file generated is all lowercase (
<lowercaseName>-config.cmake) and the extra filenames are all variations that match the name but with alternative upper/lower case combinations. I would personally consider always generating the filenames with lower case but we do need to know the intended package name.if we want to support generating files with different names altogether, that is,
GTestandGoogleTestor similar - then yes, we would need to either:or
I think in the past there were some cases in Conan Center where generating alternative names would have been convenient - however I'm not 100% sure this is justified unless it is to mirror what upstream does (and it is very unlikely that upstream generates the same package with different names) - so I wouldn't consider this unless we had very well motivated use cases. Having 2 different names for the same package is what caused most of the corner case headaches in CMakeDeps.