| Summary: | SDL-static needs a different name (on Win32 anyway) | ||
|---|---|---|---|
| Product: | SDL | Reporter: | peterlavalle |
| Component: | build | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | CC: | cseri9, tschwinger |
| Version: | 2.0.3 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 7 | ||
| Attachments: |
Fix by setting defaults
PLEASE READ THE FINE PRINT First one didn't quite cut it |
||
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! 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 !) 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. 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.
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.
Created attachment 2744 [details]
First one didn't quite cut it
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. This should be fixed by this commit: https://hg.libsdl.org/SDL/rev/c92070a96da5 |
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")