Prevent variable overwriting in nested calls to dependency provider #587
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.
We can have nested calls to
find_package
, which will be handled byconan_provide_dependency
, which is a macro.Any variable that we set in
conan_provide_dependency
will be visible by nested calls - if nested calls use the same variable names further on, then the values are rewritten.As it turns out, this is only causing issues currently as reported here: #570 - note that this PR does not fix that issue.
This PR does not change behaviour - just stylistic changes that make things more evident.
In this PR:
unset()
some variables right after we're done using them - before any possible nested call tofind_package
- not that for these variables, everything was working correctly before this PR, but it was coincidence_find_args
variable name, but rather use a variable that is suffixed with the package name being requested - andunset()
it immediately after use. The behaviour before this PR was still correct (since the variable was not used after the call to find_package)CMAKE_MODULE_PATH
if we need to fall back to CMake default search behaviour - note that we're still affected by Setting CMAKE_MODULE_PATH before first find_package() does not restore value #570 and the variable is overwritten if we have two nested calls that end up in the fallback block. This will be soon addressed in https://github.com/conan-io/cmake-conan/pull/571/files#diff-d0a3014e65e75c3075c33559a7b0cccb2baaac5e2d2beb52c7884f5bc15bda5f