Add GME and SDL2_mixer

Also support dynamic/static opengl switching
This commit is contained in:
Ronald Kinard 2015-01-28 01:20:43 -06:00
parent 479ebc3f94
commit 495ea65cc5
4 changed files with 90 additions and 7 deletions

View file

@ -0,0 +1,23 @@
include(LibFindMacros)
libfind_pkg_check_modules(GME_PKGCONF GME)
find_path(GME_INCLUDE_DIR
NAMES gme.h
PATHS
${GME_PKGCONF_INCLUDE_DIRS}
/usr/include/gme
/usr/local/include/gme
)
find_library(GME_LIBRARY
NAMES gme
PATHS
${GME_PKGCONF_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
)
set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR)
set(GME_PROCESS_LIBS GME_LIBRARY)
libfind_process(GME)

View file

@ -0,0 +1,34 @@
# Find SDL2
# Once done, this will define
#
# SDL2_MIXER_FOUND - system has SDL2
# SDL2_MIXER_INCLUDE_DIRS - SDL2 include directories
# SDL2_MIXER_LIBRARIES - link libraries
include(LibFindMacros)
libfind_pkg_check_modules(SDL2_MIXER_PKGCONF SDL2_mixer)
# includes
find_path(SDL2_MIXER_INCLUDE_DIR
NAMES SDL_mixer.h
PATHS
${SDL2_MIXER_PKGCONF_INCLUDE_DIRS}
"/usr/include/SDL2"
"/usr/local/include/SDL2"
)
# library
find_library(SDL2_MIXER_LIBRARY
NAMES SDL2_mixer
PATHS
${SDL2_MIXER_PKGCONF_LIBRARY_DIRS}
"/usr/lib"
"/usr/local/lib"
)
# set include dir variables
set(SDL2_MIXER_PROCESS_INCLUDES SDL2_MIXER_INCLUDE_DIR)
set(SDL2_MIXER_PROCESS_LIBS SDL2_MIXER_LIBRARY)
libfind_process(SDL2_MIXER)

View file

@ -203,12 +203,14 @@ set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL
"Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.") "Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.")
set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL
"Enable zlib support") "Enable zlib support")
set(SRB2_CONFIG_HAVE_LIBGME ON CACHE BOOL set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
"Enable GME support") "Enable GME support")
set(SRB2_CONFIG_HWRENDER ON CACHE BOOL set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
"Enable hardware rendering through OpenGL") "Enable hardware rendering through OpenGL")
set(SRB2_CONFIG_USEASM OFF CACHE BOOL set(SRB2_CONFIG_USEASM OFF CACHE BOOL
"Enable nasm-implemented blit functions for moderate speedup") "Enable nasm-implemented blit functions for moderate speedup")
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
"Use statically linked OpenGL. NOT RECOMMENDED.")
if(${SRB2_CONFIG_HAVE_BLUA}) if(${SRB2_CONFIG_HAVE_BLUA})
add_definitions(-DHAVE_BLUA) add_definitions(-DHAVE_BLUA)
@ -291,8 +293,13 @@ if(${SRB2_CONFIG_HAVE_BLUA})
prepend_sources(SRB2_BLUA_HEADERS) prepend_sources(SRB2_BLUA_HEADERS)
endif() endif()
if(${SRB2_CONFIG_HAVE_LIBGME}) if(${SRB2_CONFIG_HAVE_GME})
# ??? find_package(GME)
if(${GME_FOUND})
set(SRB2_HAVE_GME ON)
else()
message(WARNING "You have specified that GME is available but it was not found.")
endif()
endif() endif()
if(${SRB2_CONFIG_HAVE_ZLIB}) if(${SRB2_CONFIG_HAVE_ZLIB})
@ -318,11 +325,16 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB})
endif() endif()
if(${SRB2_CONFIG_HWRENDER}) if(${SRB2_CONFIG_HWRENDER})
add_definitions(-DHWRENDER)
endif()
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
find_package(OpenGL) find_package(OpenGL)
if(${OPENGL_FOUND}) if(${OPENGL_FOUND})
add_definitions(-DHWRENDER) add_definitions(-DHWRENDER)
add_definitions(-DSTATIC_OPENGL)
else() else()
message(WARNING "You have specified HWRENDER but opengl was not found. Not setting HWRENDER.") message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.")
endif() endif()
endif() endif()

View file

@ -3,7 +3,14 @@
set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound") set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound")
if(${SRB2_CONFIG_SDL2_USEMIXER}) if(${SRB2_CONFIG_SDL2_USEMIXER})
find_package(SDL2_MIXER)
if(${SDL2_MIXER_FOUND})
set(SRB2_HAVE_MIXER ON)
set(SRB2_SDL2_SOUNDIMPL mixer_sound.c) set(SRB2_SDL2_SOUNDIMPL mixer_sound.c)
else()
message(WARNING "You specified that SDL2_mixer is available, but it was not found. Falling back to sdl sound.")
set(SRB2_SDL2_SOUNDIMPL sdl_sound.c)
endif()
else() else()
set(SRB2_SDL2_SOUNDIMPL sdl_sound.c) set(SRB2_SDL2_SOUNDIMPL sdl_sound.c)
endif() endif()
@ -55,7 +62,7 @@ if(${SDL2_FOUND})
${SRB2_SDL2_HEADERS} ${SRB2_SDL2_HEADERS}
) )
if(${SRB2_CONFIG_HWRENDER} AND ${OPENGL_FOUND}) if(${SRB2_CONFIG_HWRENDER})
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
${SRB2_HWRENDER_SOURCES} ${SRB2_HWRENDER_SOURCES}
${SRB2_HWRENDER_HEADERS} ${SRB2_HWRENDER_HEADERS}
@ -76,6 +83,7 @@ if(${SDL2_FOUND})
if(${CMAKE_SYSTEM} MATCHES Windows) if(${CMAKE_SYSTEM} MATCHES Windows)
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c ${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c
${CMAKE_SOURCE_DIR}/src/string.c
) )
endif() endif()
@ -93,6 +101,7 @@ if(${SDL2_FOUND})
add_executable(${SRB2_SDL2_EXE_NAME} MACOSX_BUNDLE ${SRB2_SDL2_TOTAL_SOURCES}) add_executable(${SRB2_SDL2_EXE_NAME} MACOSX_BUNDLE ${SRB2_SDL2_TOTAL_SOURCES})
add_framework(CoreFoundation ${SRB2_SDL2_EXE_NAME}) add_framework(CoreFoundation ${SRB2_SDL2_EXE_NAME})
add_framework(SDL2 ${SRB2_SDL2_EXE_NAME}) add_framework(SDL2 ${SRB2_SDL2_EXE_NAME})
add_framework(SDL2_mixer ${SRB2_SDL2_EXE_NAME})
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
${PNG_LIBRARIES} ${PNG_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
@ -103,6 +112,7 @@ if(${SDL2_FOUND})
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
${SDL2_LIBRARIES} ${SDL2_LIBRARIES}
${SDL2_MIXER_LIBRARIES}
${PNG_LIBRARIES} ${PNG_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
@ -121,12 +131,16 @@ if(${SDL2_FOUND})
target_include_directories(${SRB2_SDL2_EXE_NAME} PRIVATE target_include_directories(${SRB2_SDL2_EXE_NAME} PRIVATE
${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}
${SDL2_MAIN_INCLUDE_DIRS} ${SDL2_MIXER_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS}
) )
if(${SRB2_HAVE_MIXER})
target_compile_definitions(${SRB2_SDL2_EXE_NAME} PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
endif()
target_compile_definitions(${SRB2_SDL2_EXE_NAME} PRIVATE target_compile_definitions(${SRB2_SDL2_EXE_NAME} PRIVATE
-DHAVE_SDL -DHAVE_SDL
-DNDEBUG -DNDEBUG