mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 02:56:43 +01:00
cmake: add an option to build libsuperderpy as a static library
Might be useful when packaging games for distribution repositories.
This commit is contained in:
parent
ded00145ed
commit
e12bc10840
2 changed files with 15 additions and 4 deletions
|
@ -26,6 +26,8 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
set(LIBSUPERDERPY_STATIC "no" CACHE STRING "Compile and link libsuperderpy as a static library." )
|
||||
|
||||
set(LIBSUPERDERPY_STATIC_DEPS "no" CACHE STRING "Link dependencies (e.g. Allegro) statically." )
|
||||
if(LIBSUPERDERPY_STATIC_DEPS)
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a)
|
||||
|
@ -141,10 +143,14 @@ endif()
|
|||
set_target_properties("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" PROPERTIES PREFIX "")
|
||||
|
||||
if (NOT EMSCRIPTEN)
|
||||
target_link_libraries("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_VIDEO_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} ${ALLEGRO5_COLOR_LIBRARIES} m libsuperderpy)
|
||||
target_link_libraries("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_VIDEO_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} ${ALLEGRO5_COLOR_LIBRARIES} m)
|
||||
|
||||
if (TARGET libsuperderpy-${LIBSUPERDERPY_GAMENAME})
|
||||
target_link_libraries("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" libsuperderpy-${LIBSUPERDERPY_GAMENAME})
|
||||
else (TARGET libsuperderpy-${LIBSUPERDERPY_GAMENAME})
|
||||
if (NOT LIBSUPERDERPY_STATIC)
|
||||
target_link_libraries("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" libsuperderpy)
|
||||
endif (NOT LIBSUPERDERPY_STATIC)
|
||||
endif(TARGET libsuperderpy-${LIBSUPERDERPY_GAMENAME})
|
||||
endif (NOT EMSCRIPTEN)
|
||||
|
||||
|
@ -166,9 +172,9 @@ endif()
|
|||
|
||||
MACRO(libsuperderpy_copy EXECUTABLE)
|
||||
|
||||
if (NOT APPLE AND NOT ANDROID)
|
||||
if (NOT APPLE AND NOT ANDROID AND NOT LIBSUPERDERPY_STATIC)
|
||||
add_custom_command(TARGET "${EXECUTABLE}" PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "../libsuperderpy/src/libsuperderpy${CMAKE_SHARED_LIBRARY_SUFFIX}" $<TARGET_FILE_DIR:${EXECUTABLE}>)
|
||||
endif (NOT APPLE AND NOT ANDROID)
|
||||
endif (NOT APPLE AND NOT ANDROID AND NOT LIBSUPERDERPY_STATIC)
|
||||
|
||||
ENDMACRO()
|
||||
|
||||
|
|
|
@ -15,7 +15,12 @@ if (EMSCRIPTEN)
|
|||
list(APPEND SRC_LIST emscripten-audio-stream.c)
|
||||
endif()
|
||||
|
||||
add_library("libsuperderpy" SHARED ${SRC_LIST})
|
||||
if (LIBSUPERDERPY_STATIC)
|
||||
add_library("libsuperderpy" STATIC ${SRC_LIST})
|
||||
set_property(TARGET libsuperderpy PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
else (LIBSUPERDERPY_STATIC)
|
||||
add_library("libsuperderpy" SHARED ${SRC_LIST})
|
||||
endif (LIBSUPERDERPY_STATIC)
|
||||
|
||||
SET_TARGET_PROPERTIES("libsuperderpy" PROPERTIES PREFIX "")
|
||||
|
||||
|
|
Loading…
Reference in a new issue