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

Unset package_LIBRARIES cache variable in gz_pkg_check_modules_quiet #337

Merged
merged 2 commits into from
Feb 6, 2023

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Feb 4, 2023

Signed-off-by: Ian Chen [email protected]

🦟 Bug fix

Summary

The value of package_LIBRARIES var may persist after callinggz_pkg_check_modules_quiet, and this causes an issue with subsequent calls to look for the same package.

The issue happens for me on macOS (cmake version 3.25.2) when building gz-physics from source, see comment gazebosim/gz-sim#1362 (comment). TINYXML2 is searched twice, once when cmake tries to find sdformat and again when finding DART. This results in incorrect library paths being set and linked to by DART:

ld: library not found for -lTINYXML2_LIBRARY_/opt/homebrew/Cellar/tinyxml2/9.0.0/lib/libtinyxml2.dylib-NOTFOUND
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@github-actions github-actions bot added the 🌱 garden Ignition Garden label Feb 4, 2023
@scpeters
Copy link
Member

scpeters commented Feb 6, 2023

sounds reasonable. are there any other variables we should unset while we're at it?

@iche033
Copy link
Contributor Author

iche033 commented Feb 6, 2023

sounds reasonable. are there any other variables we should unset while we're at it?

There're also a few variables set by pkg_check_modules. The ones that are used internally later in our code are:

  • package_FOUND
  • package_LIBRARIES
  • package_LIBRARY_DIRS
  • package_INCLUDE_DIRS

When I tried to printout these values between two pkg_check_modules calls, I see that the package_LIBRARIES is the only one whose value came out different after the second call if its previous value is not empty. I think unsetting other values maybe be fine but I left them untouched to minimize the chance of breaking things since I'm not very familiar with the implementation details of this function.

@scpeters
Copy link
Member

scpeters commented Feb 6, 2023

sounds reasonable. are there any other variables we should unset while we're at it?

There're also a few variables set by pkg_check_modules. The ones that are used internally later in our code are:

  • package_FOUND
  • package_LIBRARIES
  • package_LIBRARY_DIRS
  • package_INCLUDE_DIRS

When I tried to printout these values between two pkg_check_modules calls, I see that the package_LIBRARIES is the only one whose value came out different after the second call if its previous value is not empty. I think unsetting other values maybe be fine but I left them untouched to minimize the chance of breaking things since I'm not very familiar with the implementation details of this function.

sounds good! I approve

@scpeters scpeters merged commit 218d15f into gz-cmake3 Feb 6, 2023
@scpeters scpeters deleted the unset_lib_var branch February 6, 2023 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants