diff --git a/cmake/Modules/FindGME.cmake b/cmake/Modules/FindGME.cmake new file mode 100644 index 00000000..3b0c68de --- /dev/null +++ b/cmake/Modules/FindGME.cmake @@ -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) \ No newline at end of file diff --git a/cmake/Modules/FindSDL2_mixer.cmake b/cmake/Modules/FindSDL2_mixer.cmake new file mode 100644 index 00000000..59b4823e --- /dev/null +++ b/cmake/Modules/FindSDL2_mixer.cmake @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 442ddca6..2772ba8a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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.") set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL "Enable zlib support") -set(SRB2_CONFIG_HAVE_LIBGME ON CACHE BOOL +set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL "Enable GME support") set(SRB2_CONFIG_HWRENDER ON CACHE BOOL "Enable hardware rendering through OpenGL") set(SRB2_CONFIG_USEASM OFF CACHE BOOL "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}) add_definitions(-DHAVE_BLUA) @@ -291,8 +293,13 @@ if(${SRB2_CONFIG_HAVE_BLUA}) prepend_sources(SRB2_BLUA_HEADERS) 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() if(${SRB2_CONFIG_HAVE_ZLIB}) @@ -318,11 +325,16 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB}) endif() if(${SRB2_CONFIG_HWRENDER}) + add_definitions(-DHWRENDER) +endif() + +if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) find_package(OpenGL) if(${OPENGL_FOUND}) add_definitions(-DHWRENDER) + add_definitions(-DSTATIC_OPENGL) 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() diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index e445eb72..9996922f 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -3,7 +3,14 @@ set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound") if(${SRB2_CONFIG_SDL2_USEMIXER}) - set(SRB2_SDL2_SOUNDIMPL mixer_sound.c) + find_package(SDL2_MIXER) + if(${SDL2_MIXER_FOUND}) + set(SRB2_HAVE_MIXER ON) + 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() set(SRB2_SDL2_SOUNDIMPL sdl_sound.c) endif() @@ -55,7 +62,7 @@ if(${SDL2_FOUND}) ${SRB2_SDL2_HEADERS} ) - if(${SRB2_CONFIG_HWRENDER} AND ${OPENGL_FOUND}) + if(${SRB2_CONFIG_HWRENDER}) set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} ${SRB2_HWRENDER_SOURCES} ${SRB2_HWRENDER_HEADERS} @@ -76,6 +83,7 @@ if(${SDL2_FOUND}) if(${CMAKE_SYSTEM} MATCHES Windows) set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} ${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c + ${CMAKE_SOURCE_DIR}/src/string.c ) endif() @@ -93,6 +101,7 @@ if(${SDL2_FOUND}) add_executable(${SRB2_SDL2_EXE_NAME} MACOSX_BUNDLE ${SRB2_SDL2_TOTAL_SOURCES}) add_framework(CoreFoundation ${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 ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} @@ -103,6 +112,7 @@ if(${SDL2_FOUND}) target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE ${SDL2_LIBRARIES} + ${SDL2_MIXER_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${OPENGL_LIBRARIES} @@ -121,12 +131,16 @@ if(${SDL2_FOUND}) target_include_directories(${SRB2_SDL2_EXE_NAME} PRIVATE ${SDL2_INCLUDE_DIRS} - ${SDL2_MAIN_INCLUDE_DIRS} + ${SDL2_MIXER_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS} ${ZLIB_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 -DHAVE_SDL -DNDEBUG