Skip to content

[gflags]: Fix targets gflags::* not being globally visible#20011

Merged
BillyONeal merged 4 commits intomicrosoft:masterfrom
JafarAbdi:pr-fix_gflags
Sep 16, 2021
Merged

[gflags]: Fix targets gflags::* not being globally visible#20011
BillyONeal merged 4 commits intomicrosoft:masterfrom
JafarAbdi:pr-fix_gflags

Conversation

@JafarAbdi
Copy link
Contributor

Describe the pull request

I'm getting the following error when calling find_package(gflags REQUIRED) in a cmake project

CMake Error at /home/jafar/workspaces/vcpkg/scripts/buildsystems/vcpkg.cmake:574 (_add_library):
  _add_library cannot create ALIAS target "gflags" because target
  "gflags::gflags" is imported but not globally visible.
Call Stack (most recent call first):
  /home/jafar/workspaces/vcpkg/installed/x64-linux/share/gflags/vcpkg-cmake-wrapper.cmake:7 (add_library)
  /home/jafar/workspaces/vcpkg/scripts/buildsystems/vcpkg.cmake:738 (include)
  CMakeLists.txt:4 (find_package)


CMake Error at /home/jafar/workspaces/vcpkg/scripts/buildsystems/vcpkg.cmake:574 (_add_library):
  _add_library cannot create ALIAS target "gflags_static" because target
  "gflags::gflags_static" is imported but not globally visible.
Call Stack (most recent call first):
  /home/jafar/workspaces/vcpkg/installed/x64-linux/share/gflags/vcpkg-cmake-wrapper.cmake:7 (add_library)
  /home/jafar/workspaces/vcpkg/scripts/buildsystems/vcpkg.cmake:738 (include)
  CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!
See also "/tmp/untitled/build/CMakeFiles/CMakeOutput.log".

after debugging it I think it happened after merging #18739 (I don't see the error when checking its parent commit), to fix it I used the solution described here

  • Which triplets are supported/not supported? Have you updated the CI baseline?

    linux, No

  • Does your PR follow the maintainer guide?

    Yes

  • If you have added/updated a port: Have you run ./vcpkg x-add-version --all and committed the result?

    Yes

If you are still working on the PR, open it as a Draft: https://github.blog/2019-02-14-introducing-draft-pull-requests/

Comment on lines 7 to 8
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably something like:

Suggested change
set_target_properties("gflags::${tgt}" PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(${tgt} ALIAS "gflags::${tgt}")
add_library(${tgt} INTERFACE IMPORTED UNKNOWN)
target_link_libraries(${tgt} INTERFACE "gflags::${tgt}")

is better since it does not require to make the targets global.

@PhoebeHui PhoebeHui added category:port-bug The issue is with a library, which is something the port should already support requires:author-response labels Sep 7, 2021
@PhoebeHui
Copy link
Contributor

@JafarAbdi, could you address the review suggestions?

@JafarAbdi
Copy link
Contributor Author

@JafarAbdi, could you address the review suggestions?

Done, but I'm not sure why the CI is failing I also see the main branch is failing could that be related .?

@BillyONeal
Copy link
Member

Done, but I'm not sure why the CI is failing I also see the main branch is failing could that be related .?

Yeah, sorry about that. We backed out the new check that caused a bunch of PRs to fail in the last 10 hours or so

Copy link
Contributor

@PhoebeHui PhoebeHui left a comment

Choose a reason for hiding this comment

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

Thanks for your updates!

@PhoebeHui PhoebeHui added the info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. label Sep 16, 2021
@BillyONeal BillyONeal merged commit b7aa438 into microsoft:master Sep 16, 2021
@BillyONeal
Copy link
Member

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:port-bug The issue is with a library, which is something the port should already support info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants