-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[giflib] Add export CMake #26869
[giflib] Add export CMake #26869
Conversation
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.
Wrong approach to fix #26833.
Another unofficial config doesn't resolve the problem of CMake's FindGIF.cmake
needing help, i.e. needing a wrapper.
The config is not used by any downstream port without patching.
_find_package(unofficial-giflib CONFIG REQUIRED) | ||
add_library(GIF::GIF ALIAS unofficial::giflib::gif) | ||
|
||
get_filename_component(GIF_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}" PATH) | ||
get_filename_component(GIF_INCLUDE_DIRS "${LUA_INCLUDE_DIR}" PATH) | ||
|
||
set(GIF_FOUND TRUE) | ||
set(GIF_INCLUDE_DIRS ${_IMPORT_PREFIX}/include) | ||
set(GIF_LIBRARIES unofficial::giflib::gif) | ||
set(GIF_VERSION @GIFLIB_VERSION@) | ||
|
||
unset(_IMPORT_PREFIX) |
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.
So many error in a short file!
And I repeat that you don't need exported config. Cf. zlib.
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.
@dg0yt I think this should be okay. what are you worried about?
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.
This is really hard...
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.
And again, do not implement this with imported config. It is just a simple lib without dependencies.
@@ -0,0 +1,12 @@ | |||
_find_package(unofficial-giflib CONFIG REQUIRED) | |||
add_library(GIF::GIF ALIAS unofficial::giflib::gif) |
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.
This must be guarded by if(NOT TARGET GIF::GIF)
.
You must not use ALIAS here.
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.
This must be guarded by
if(NOT TARGET GIF::GIF)
.
Agreed.
You must not use ALIAS here.
Why?
Our goal is to be fully compatible with FindGIF.cmake
, so we should provide all the targets and macros that cmake provides in FindGIF
.
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.
ALIAS
is for internal use in a CMake project. But this is exported config. You can use Given the vendored INTERFACE
libraries.CMakeLists.txt
, you can just directly export GIF::GIF
.
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.
ALIAS
is for internal use in a CMake project. But this is exported config.You can useGiven the vendoredINTERFACE
libraries.CMakeLists.txt
, you can just directly exportGIF::GIF
.
I think not, GIF::GIF
is provided by cmake, not by giflib officially.
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.
FindGIF.cmake
from CMake is defining the official interface of find_package(GIF)
. So yes, just export GIF::GIF
directly, "to be fully compatible with FindGIF.cmake
".
Or don't export anything, and use plain find_library
and select_library_configurations
, as we do in other ports.
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.
You must not use ALIAS here.
Why?
And CMake 3.7.2 even doesn't allow this alias:
CMake Error at /Users/vagrant/Data/work/1/s/scripts/buildsystems/vcpkg.cmake:618 (_add_library):
add_library cannot create ALIAS target "GIF::GIF" because target
"unofficial::giflib::gif" is IMPORTED.
Hint: You can build test port cmake-user
locally before pushing the next update.
@@ -26,9 +26,10 @@ if(HAVE_REALLOCARRAY) | |||
add_definitions(-DHAVE_REALLOCARRAY) | |||
endif() | |||
|
|||
add_library(gif ${GIFLIB_SOURCES}) | |||
add_library(GIF ${GIFLIB_SOURCES}) |
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.
We need to set the OUTPUT_NAME
to lower-case gif
now. Then x64-linux will be happy.
Why not to set |
Any chance this might be completed? |
I will continue to fix this in the next week. |
Closed as duplicate of #27369. |
Describe the pull request
What does your PR fix?
Fixes [giflib] Debug library linked in release configuration #26833, add export CMake and fix Release mode depends on Debug lib.Usage have test pass.