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

Fix find_package() from separate subdirs for <Package>Config.cmake files (#505) #506

Merged

Conversation

bartlettroscoe
Copy link
Member

This should fix the use case described in #505. I produced a TriBITS test that exposed the problem and updated the code to fix it. I think what is here now works as find_package() should from different subdirs for dependent packages but still avoid the scalability problem described in https://gitlab.kitware.com/cmake/cmake/-/issues/23685. This also updates the <tplName>Config.cmake files to act in a consistent way with CMake-generated imported targets (using export() command).

See the individual commit log messages for details.

TriBITSPub#505)

This fixes the test added in the last commit for calling find_package() for
related packages from different subdirs that was failing.

I belive the problem is that the targets created by the CMake export() command
don't have GLOBAL on them and only have directory scope.  Therefore, we can't
use include_guard(GLOBAL) because that will stop the creation of the imported
targets in a different subdir where they are not defined.
…Tpl>::all_libs) (TriBITSPub#505)

This change makes the IMPORTED targets produced by TriBITS for external
packages/TPLs equivalent to those created by CMake export() in that they are
**not** global but are just local to the directory where they are called.  But
to get ahead of the scalability problem, I added the guard:

  if (NOT TARGET <upstreamTpl>::all_libs)
    ...
  endif()

around the find_dependency(<upstreamTpl> ...) calls.
Copy link
Collaborator

@rabartlett1972 rabartlett1972 left a comment

Choose a reason for hiding this comment

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

I will approve without an initial review so this can be updated to SEACAS and address but #505.

Then we can do a post-merge review.

@bartlettroscoe
Copy link
Member Author

Hello @KyleFromKitware, can you please do a post-merge review of this PR? Thanks!

@KyleFromKitware
Copy link
Collaborator

LGTM +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants