We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2576 - SDL-static needs a different name (on Win32 anyway)
Summary: SDL-static needs a different name (on Win32 anyway)
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: 2.0.3
Hardware: x86_64 Windows 7
: P2 major
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-08 00:16 UTC by peterlavalle
Modified: 2017-08-10 02:04 UTC (History)
2 users (show)

See Also:


Attachments
Fix by setting defaults (1.37 KB, patch)
2017-05-14 21:18 UTC, tschwinger
Details | Diff
PLEASE READ THE FINE PRINT (943 bytes, patch)
2017-05-14 23:45 UTC, tschwinger
Details | Diff
First one didn't quite cut it (1.57 KB, patch)
2017-05-21 14:22 UTC, tschwinger
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description peterlavalle 2014-06-08 00:16:40 UTC
When building SDL 2.0.3 on Win32 using CMake I get the SDL-static lib (which is named SDL.lib) then the DLL builds and SDL.dll's companion SDL.lib overwrites my beloved SDL.lib.

This is noted in the CMakeLists areound line 1270
The solution is that SDL-static shouldn't be named SDL.lib.
Please remove line 1263 from CMakeLists to solve the problem.

REMOVE;
$ set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")

... once removed; SDL-static build and isn't overwritten. This is "more-better" AFAIK


Below is a patch to do this (please inform me if there's a more-better way to submit this)

diff -r bc5ec1b6904c CMakeLists.txt
--- a/CMakeLists.txt	Sat Jun 07 11:36:08 2014 -0700
+++ b/CMakeLists.txt	Sun Jun 08 01:15:46 2014 +0100
@@ -1261,7 +1261,7 @@
 if(SDL_STATIC)
   set (BUILD_SHARED_LIBS FALSE)
   add_library(SDL2-static STATIC ${SOURCE_FILES})
-  set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
+  
   if(MSVC)
     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
Comment 1 Ryan C. Gordon 2015-02-19 06:32:13 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry
if you got a lot of email from this. This is to help me sort through some bugs
in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4,
though!
Comment 2 cseri 2015-07-31 20:55:59 UTC
I ran into the exact same issue!

(Also, disabling the build of the shared library in 2.0.3 resulted in a CMake error but that is fixed in https://bugzilla.libsdl.org/show_bug.cgi?id=2474 !)
Comment 3 tschwinger 2017-05-14 17:51:03 UTC
This one really isn't pretty: Right now, there are conflicting output files for the import library and the static build, in the general cross platform / cross generator case. That is, it may work by coincidence for some generators, but it's actually way too broken to stay open for years.

One possible fix would be to just go with the default functionality respecting `BUILD_SHARED_LIBS` (as considered in a comment in `CMakeLists.txt`) and build EITHER static OR dynamic libs. Less can be more, however, that might not be the greatest of all ideas in terms of backward compatibility.

Another would be to configure different output directories (e.g. `libstatic`). Obviously this would have to happen for both build and install trees.

Yet another, maybe the simplest, is to configure the `IMPORT_LIBRARY_SUFFIX` to `.dll.lib` or something like that. This can also be done "from the outside" (via command line options while invoking CMake) to serve as a workaround. Pulling this variable into the cache with a reasonable default would solve the issue with two lines of code (counting a second for `mark_as_advanced`).

Another variable to default in a similar fashion would be `CMAKE_DEBUG_POSTFIX`; setting it to "d" will e.g. give you "SDLd.dll" indicating a debug build, and thus allows the client to install both debug and release builds to the same location without fuzz.
Comment 4 tschwinger 2017-05-14 21:18:55 UTC
Created attachment 2736 [details]
Fix by setting defaults

OK, it took me some additional LOC to please the fairly old minimum/target version of CMake...

Also contains my other suggestion that allows conflict-free installation of debug builds, as both are just about setting some meaningful defaults.
Comment 5 tschwinger 2017-05-14 23:45:21 UTC
Created attachment 2741 [details]
PLEASE READ THE FINE PRINT

Since I increased the minimum required patch level of CMake in another commit, here is the one that would come after it to remove the code supporting the ancient version.

It requires at least CMake 2.8.9 and current on `tip` is 2.8.5.
My other commit on #3572 increases the version to 2.8.11.
Comment 6 tschwinger 2017-05-21 14:22:21 UTC
Created attachment 2744 [details]
First one didn't quite cut it
Comment 7 tschwinger 2017-05-21 14:36:36 UTC
Increasing the importance level, because the race condition caused by the same OUTPUT_NAMEs (see 2nd fixup patch) cannot be worked around by passing command line parameters to CMake.
Comment 8 Sam Lantinga 2017-08-10 02:04:35 UTC
This should be fixed by this commit:
https://hg.libsdl.org/SDL/rev/c92070a96da5