cmake: rework static linking configuration

This commit is contained in:
Sebastian Krzyszkowiak 2019-05-17 17:35:07 +02:00
parent c6ef4a6199
commit 6758075511
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
2 changed files with 16 additions and 11 deletions

View file

@ -23,11 +23,11 @@ if (APPLE)
endif(APPLE)
install(TARGETS ${EXECUTABLE} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
if (BUILD_SHARED_LIBS)
add_library("lib${LIBSUPERDERPY_GAMENAME}" SHARED ${SHARED_SRC_LIST})
else(BUILD_SHARED_LIBS)
if (LIBSUPERDERPY_STATIC_COMMON)
add_library("lib${LIBSUPERDERPY_GAMENAME}" STATIC ${SHARED_SRC_LIST})
endif(BUILD_SHARED_LIBS)
else(LIBSUPERDERPY_STATIC_COMMON)
add_library("lib${LIBSUPERDERPY_GAMENAME}" SHARED ${SHARED_SRC_LIST})
endif(LIBSUPERDERPY_STATIC_COMMON)
set_target_properties("lib${LIBSUPERDERPY_GAMENAME}" PROPERTIES PREFIX "")
target_link_libraries("lib${LIBSUPERDERPY_GAMENAME}" libsuperderpy ${LIBSUPERDERPY_EXTRA_LIBS})

View file

@ -169,24 +169,29 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
endif()
endif()
option(BUILD_SHARED_LIBS "Use dynamic linking" ON)
option(BUILD_SHARED_LIBS "Build as dynamic libraries" ON)
option(LIBSUPERDERPY_STATIC "Compile and link libsuperderpy as a static library" OFF)
option(LIBSUPERDERPY_STATIC_COMMON "Compile and link common routines as a static library" OFF)
option(LIBSUPERDERPY_STATIC_GAMESTATES "Compile and link gamestates as static libraries" OFF)
if (NOT BUILD_SHARED_LIBS)
set(STATIC_DEFAULT ON)
else()
set(STATIC_DEFAULT OFF)
set(LIBSUPERDERPY_STATIC ON)
set(LIBSUPERDERPY_STATIC_COMMON ON)
set(LIBSUPERDERPY_STATIC_GAMESTATES ON)
endif()
option(LIBSUPERDERPY_STATIC "Compile and link libsuperderpy as a static library." ${STATIC_DEFAULT})
option(LIBSUPERDERPY_STATIC_GAMESTATES "Compile and link gamestates as static libraries" ${STATIC_DEFAULT})
if(LIBSUPERDERPY_STATIC_GAMESTATES)
add_definitions("-DLIBSUPERDERPY_STATIC_GAMESTATES")
endif(LIBSUPERDERPY_STATIC_GAMESTATES)
option(LIBSUPERDERPY_STATIC_DEPS "Link dependencies (e.g. Allegro) statically." ${STATIC_DEFAULT})
option(LIBSUPERDERPY_STATIC_DEPS "Link dependencies (e.g. Allegro) statically." OFF)
if(LIBSUPERDERPY_STATIC_DEPS)
SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a)
endif(LIBSUPERDERPY_STATIC_DEPS)
set(LIBSUPERDERPY_EXTRA_LIBS "${LIBSUPERDERPY_EXTRA_LIBS_INIT}" CACHE STRING "Additional platform libraries to link to")
if(MAEMO5)
add_definitions(-DMAEMO5=1)
add_definitions(-D_Noreturn=)