cmake: add ability to build an embedded, static copy of Allegro

This commit is contained in:
Sebastian Krzyszkowiak 2019-09-07 01:13:52 +02:00
parent 09c8506b37
commit aa1c864811
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
4 changed files with 56 additions and 12 deletions

3
.gitmodules vendored
View file

@ -4,3 +4,6 @@
[submodule "src/3rdparty/dlfcn-win32"] [submodule "src/3rdparty/dlfcn-win32"]
path = src/3rdparty/dlfcn-win32 path = src/3rdparty/dlfcn-win32
url = https://gitlab.com/dosowisko.net/dlfcn-win32.git url = https://gitlab.com/dosowisko.net/dlfcn-win32.git
[submodule "src/3rdparty/allegro5"]
path = src/3rdparty/allegro5
url = https://gitlab.com/dosowisko.net/allegro5.git

View file

@ -9,6 +9,7 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
if (EXISTS "${CMAKE_SOURCE_DIR}/libsuperderpy") if (EXISTS "${CMAKE_SOURCE_DIR}/libsuperderpy")
set(LIBSUPERDERPY_DIR "${CMAKE_SOURCE_DIR}/libsuperderpy") set(LIBSUPERDERPY_DIR "${CMAKE_SOURCE_DIR}/libsuperderpy")
set(LIBSUPERDERPY_BINARY_DIR "${CMAKE_BINARY_DIR}/libsuperderpy")
if(NOT DEFINED LIBSUPERDERPY_NO_GAME_GIT_REV) if(NOT DEFINED LIBSUPERDERPY_NO_GAME_GIT_REV)
execute_process( execute_process(
@ -24,6 +25,7 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
else (EXISTS "${CMAKE_SOURCE_DIR}/libsuperderpy") else (EXISTS "${CMAKE_SOURCE_DIR}/libsuperderpy")
set(LIBSUPERDERPY_DIR ${CMAKE_SOURCE_DIR}) set(LIBSUPERDERPY_DIR ${CMAKE_SOURCE_DIR})
set(LIBSUPERDERPY_BINARY_DIR ${CMAKE_BINARY_DIR})
endif (EXISTS "${CMAKE_SOURCE_DIR}/libsuperderpy") endif (EXISTS "${CMAKE_SOURCE_DIR}/libsuperderpy")
@ -288,6 +290,28 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
add_definitions(-DLIBSUPERDERPY_SINGLE_THREAD) add_definitions(-DLIBSUPERDERPY_SINGLE_THREAD)
endif() endif()
if (LIBSUPERDERPY_EMBEDDED_ALLEGRO)
set(ALLEGRO5_LIBRARIES "allegro")
set(ALLEGRO5_FONT_LIBRARIES "allegro_font")
set(ALLEGRO5_TTF_LIBRARIES "allegro_ttf")
set(ALLEGRO5_PRIMITIVES_LIBRARIES "allegro_primitives")
set(ALLEGRO5_AUDIO_LIBRARIES "allegro_audio")
set(ALLEGRO5_ACODEC_LIBRARIES "allegro_acodec")
set(ALLEGRO5_IMAGE_LIBRARIES "allegro_image")
set(ALLEGRO5_COLOR_LIBRARIES "allegro_color")
set(ALLEGRO5_VIDEO_LIBRARIES "allegro_video")
set(ALLEGRO5_MAIN_LIBRARIES "allegro_main")
include_directories("${LIBSUPERDERPY_DIR}/src/3rdparty/allegro5/include")
include_directories("${LIBSUPERDERPY_DIR}/src/3rdparty/allegro5/addons/font")
include_directories("${LIBSUPERDERPY_DIR}/src/3rdparty/allegro5/addons/ttf")
include_directories("${LIBSUPERDERPY_DIR}/src/3rdparty/allegro5/addons/primitives")
include_directories("${LIBSUPERDERPY_DIR}/src/3rdparty/allegro5/addons/audio")
include_directories("${LIBSUPERDERPY_DIR}/src/3rdparty/allegro5/addons/acodec")
include_directories("${LIBSUPERDERPY_DIR}/src/3rdparty/allegro5/addons/image")
include_directories("${LIBSUPERDERPY_DIR}/src/3rdparty/allegro5/addons/color")
include_directories("${LIBSUPERDERPY_DIR}/src/3rdparty/allegro5/addons/video")
include_directories("${LIBSUPERDERPY_BINARY_DIR}/src/3rdparty/allegro5/include")
else (LIBSUPERDERPY_EMBEDDED_ALLEGRO)
find_package(Allegro5 REQUIRED) find_package(Allegro5 REQUIRED)
find_package(Allegro5Font REQUIRED) find_package(Allegro5Font REQUIRED)
find_package(Allegro5TTF REQUIRED) find_package(Allegro5TTF REQUIRED)
@ -300,6 +324,7 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
if(APPLE) if(APPLE)
find_package(Allegro5Main) find_package(Allegro5Main)
endif(APPLE) endif(APPLE)
endif()
include_directories(${ALLEGRO5_INCLUDE_DIR} ${ALLEGRO5_FONT_INCLUDE_DIR} ${ALLEGRO5_TTF_INCLUDE_DIR} ${ALLEGRO5_PRIMITIVES_INCLUDE_DIR} ${ALLEGRO5_AUDIO_INCLUDE_DIR} ${ALLEGRO5_ACODEC_INCLUDE_DIR} ${ALLEGRO5_VIDEO_INCLUDE_DIR} ${ALLEGRO5_IMAGE_INCLUDE_DIR} ${ALLEGRO5_COLOR_INCLUDE_DIR}) include_directories(${ALLEGRO5_INCLUDE_DIR} ${ALLEGRO5_FONT_INCLUDE_DIR} ${ALLEGRO5_TTF_INCLUDE_DIR} ${ALLEGRO5_PRIMITIVES_INCLUDE_DIR} ${ALLEGRO5_AUDIO_INCLUDE_DIR} ${ALLEGRO5_ACODEC_INCLUDE_DIR} ${ALLEGRO5_VIDEO_INCLUDE_DIR} ${ALLEGRO5_IMAGE_INCLUDE_DIR} ${ALLEGRO5_COLOR_INCLUDE_DIR})

1
src/3rdparty/allegro5 vendored Submodule

@ -0,0 +1 @@
Subproject commit 48262b6bb6e30a33687c18c761f05633c7255dc9

View file

@ -16,6 +16,21 @@ if (EMSCRIPTEN)
list(APPEND SRC_LIST emscripten-audio-stream.c) list(APPEND SRC_LIST emscripten-audio-stream.c)
endif() endif()
if (LIBSUPERDERPY_EMBEDDED_ALLEGRO)
set(SHARED OFF) # Allegro doesn't namespace this...
add_subdirectory("3rdparty/allegro5" EXCLUDE_FROM_ALL)
set_property(TARGET "allegro" PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET "allegro_font" PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET "allegro_ttf" PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET "allegro_primitives" PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET "allegro_audio" PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET "allegro_acodec" PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET "allegro_image" PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET "allegro_color" PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET "allegro_video" PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET "allegro_main" PROPERTY POSITION_INDEPENDENT_CODE ON)
endif (LIBSUPERDERPY_EMBEDDED_ALLEGRO)
if (LIBSUPERDERPY_IMGUI) if (LIBSUPERDERPY_IMGUI)
set(IMGUI_STATIC ON CACHE STRING "" FORCE) set(IMGUI_STATIC ON CACHE STRING "" FORCE)
add_subdirectory(3rdparty/cimgui EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/cimgui EXCLUDE_FROM_ALL)