-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add version suffix to DLL when compiling for MinGW target #5701
Conversation
Do we really need to perpetuate this specific behaviour of mingw support in autoconf ? If by default cmake doesn't add this suffix, maybe we shouldn't ? What's the impact of keeping things like they are currently ? |
From a packaging perspective, the suffix is really useful for generating versioned requires, i.e.
Versioned libraries from my experience (maintaining quite a large number of mingw packages for Fedora) are pretty common, indeed most coming from the autotools days and then being implemented also for cmake or other build systems. Meson actually also adds suffixes by default. |
Huh, fascinating. You're telling cmake to override the This does seem like a (design) bug in cmake's Windows support.
Part of the documented behavior contract, in fact. |
Googling a bit, I found https://gitlab.kitware.com/cmake/cmake/-/issues/21716 - looks like while being acknowledged as a reasonable request, it was not pursued further. |
@mwtoews it looks like the post install checks would need some tuning to accomodate for the libgdal-XY.dll pattern. Can you help with that ? But I'm not sure to understand what the goal of the check_ldd() function is exactly |
Sure, I can take a look. The As a side note, I've been meaning to eventually refresh GDAL's post-install tests to be more in-line with PROJ's tests. Not sure when, however. |
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.
A version suffix to DLLs doesn't hurt, but IMO it also contributes very little to actual usability. Import lib and static lib shouldn't carry such a suffix.
@@ -301,6 +301,10 @@ if (MSVC) | |||
CACHE STRING "Postfix to add to the GDAL dll name for debug builds") | |||
set_target_properties(${GDAL_LIB_TARGET_NAME} PROPERTIES DEBUG_POSTFIX "${GDAL_DEBUG_POSTFIX}") | |||
endif () | |||
if(MINGW) | |||
set_target_properties(${GDAL_LIB_TARGET_NAME} PROPERTIES SUFFIX "-${GDAL_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}") |
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.
Overriding SUFFIX
in this way breaks import lib (.dll.a
) and static lib (.a
).
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.
Uhm where do you see this? The suffix isn't added to the import library here from what I can see, and generally I've always seen it added only to the runtime library even in projects which build both static and shared libraries.
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.
I've reworked this to only set RUNTIME_OUTPUT_NAME
which should be safer - I've verified building with both BUILD_SHARED_LIBS=ON|OFF
that only the .dll
gets the suffix this way.
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.
Maybe I was wrong about the import lib but not about the static lib.
RUNTIME_OUTPUT_NAME
is an alternative. However, this will put the version before CMAKE_<CONFIG>_POSTFIX
...
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.
POSTFIXES like d
etc though are only used in the MSVC world? Alternatively I could go back to setting SUFFIX
, but conditionally on BUILD_SHARED_LIBS
, so that static libraries are not affected.
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.
POSTFIXES like
d
etc though are only used in the MSVC world?
Possibly yes, but it is a user option (passed to CMake at configuration time). And with the Ninja multi-config generator and exported config, there may be valid use cases outside the MSVC world.
This just illustrates the key conflict with re-implementing autotools features in CMake: It often works against CMake features (here: multi-config support, user/toolchain control). Most often I meet this conflict with simultaneous builds of static and shared.
To be clear, I'm not against adding the version suffix. I just want to make sure it doesn't cause trouble for other reasonable (CMake) use cases.
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.
Do you see any potential issues with overriding SUFFIX just for BUILD_SHARED_LIBS=TRUE?
@rouault here's a working fix (borrowed from here) which will match (e.g.) diff --git a/autotest/postinstall/test_pkg-config.sh b/autotest/postinstall/test_pkg-config.sh
index 5e0cd76d20..30417ac687 100755
--- a/autotest/postinstall/test_pkg-config.sh
+++ b/autotest/postinstall/test_pkg-config.sh
@@ -31,8 +31,7 @@ case "$UNAME,$2" in
export LD_LIBRARY_PATH=$prefix/lib
;;
MINGW*,)
- alias ldd="sh -c 'objdump -x \$1.exe' --"
- LDD_SUBSTR="DLL Name: libgdal.dll"
+ LDD_SUBSTR=$(cygpath -u "$prefix/bin/libgdal")
export PATH="$prefix/bin:$PATH"
;;
*,--static) |
Wait, you need |
@dg0yt it seems that |
@mwtoews a) I'm not convinced that the test's point is to verify the environment ( The minimal change which would fix the current issue is trivial: --- a/autotest/postinstall/test_pkg-config.sh
+++ b/autotest/postinstall/test_pkg-config.sh
@@ -32,7 +32,7 @@ case "$UNAME,$2" in
;;
MINGW*,)
alias ldd="sh -c 'objdump -x \$1.exe' --"
- LDD_SUBSTR="DLL Name: libgdal.dll"
+ LDD_SUBSTR="DLL Name: libgdal"
export PATH="$prefix/bin:$PATH"
;;
*,--static) |
@dg0yt sure, that simple fix will work too. |
This PR is stalled |
I've pushed an update overriding |
Autotools creates DLL with a version suffix. This PR makes also cmake add a version suffix to the DLL.