Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Browse files Browse the repository at this point in the history
David Gow

As discussed on the list, the autotools build backend uses libtool's "release" option, giving us the SONAME libSDL2-2.0.so.0, whereas CMake doesn't, giving us libSDL2.so.0

While libSDL2.so.0 has some small advantages (being simpler and matching the names on some other OSes better), many products have already been developed expecting libSDL2-2.0.so.0, which better matches SDL 1.2's SONAME. It seems clear, therefore, that most developers prefer this name.

This patch emulates libtool's functionality, making libSDL2-2.0.so.0 the name of the shared library, while leaving libSDL2.a as the filename of the static library. Unlike with libtool, no libSDL2.so symlink is yet made. I also haven't tested this on anything but Linux, so it might break other platforms. :/
  • Loading branch information
slouken committed Jul 27, 2013
1 parent 6d09ee9 commit 55b782f
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions CMakeLists.txt
Expand Up @@ -38,6 +38,8 @@ set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}"
math(EXPR LT_CURRENT "${SDL_MICRO_VERSION} - ${SDL_INTERFACE_AGE}")
math(EXPR LT_AGE "${SDL_BINARY_AGE} - ${SDL_INTERFACE_AGE}")
set(LT_REVISION "${SDL_INTERFACE_AGE}")
set(LT_RELEASE "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}")
set(LT_VERSION "${LT_CURRENT}.${LT_REVISION}.${LT_AGE}")

# General settings & flags
set(LIBRARY_OUTPUT_DIRECTORY "build")
Expand Down Expand Up @@ -1144,9 +1146,17 @@ set(_INSTALL_LIBS "SDL2main")

if(SDL_SHARED)
add_library(SDL2 SHARED ${SOURCE_FILES})
set_target_properties(SDL2 PROPERTIES
VERSION ${SDL_VERSION}
SOVERSION ${LT_CURRENT})
if(UNIX)
set_target_properties(SDL2 PROPERTIES
VERSION ${LT_VERSION}
SOVERSION ${LT_CURRENT}
OUTPUT_NAME "SDL2-${LT_RELEASE}")
else(UNIX)
set_target_properties(SDL2 PROPERTIES
VERSION ${SDL_VERSION}
SOVERSION ${LT_CURRENT}
OUTPUT_NAME "SDL2")
endif(UNIX)
set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
endif(SDL_SHARED)
Expand Down Expand Up @@ -1174,6 +1184,13 @@ endforeach()
list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES})
install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2)

if(SDL_SHARED)
install(CODE "
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
\"libSDL2-2.0.so\" \"libSDL2.so\")")
install(FILES ${SDL2_BINARY_DIR}/libSDL2.so DESTINATION "lib${LIB_SUFFIX}")
endif(SDL_SHARED)

if(NOT WINDOWS OR CYGWIN)
if(FREEBSD)
# FreeBSD uses ${PREFIX}/libdata/pkgconfig
Expand Down

0 comments on commit 55b782f

Please sign in to comment.