2015-01-28 05:46:39 +00:00
|
|
|
# Declare SDL2 interface sources
|
|
|
|
|
|
|
|
set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound")
|
|
|
|
|
|
|
|
if(${SRB2_CONFIG_SDL2_USEMIXER})
|
2015-01-28 20:15:24 +00:00
|
|
|
find_package(SDL2_mixer)
|
2015-01-28 07:20:43 +00:00
|
|
|
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()
|
2015-01-28 05:46:39 +00:00
|
|
|
else()
|
|
|
|
set(SRB2_SDL2_SOUNDIMPL sdl_sound.c)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(SRB2_SDL2_SOURCES
|
|
|
|
dosstr.c
|
|
|
|
endtxt.c
|
|
|
|
hwsym_sdl.c
|
|
|
|
i_cdmus.c
|
|
|
|
i_main.c
|
|
|
|
i_net.c
|
|
|
|
i_system.c
|
|
|
|
i_ttf.c
|
|
|
|
i_video.c
|
|
|
|
#IMG_xpm.c
|
|
|
|
ogl_sdl.c
|
|
|
|
|
|
|
|
${SRB2_SDL2_SOUNDIMPL}
|
|
|
|
)
|
|
|
|
|
|
|
|
set(SRB2_SDL2_HEADERS
|
|
|
|
endtxt.h
|
|
|
|
hwsym_sdl.h
|
|
|
|
i_ttf.h
|
|
|
|
ogl_sdl.h
|
|
|
|
sdlmain.h
|
|
|
|
)
|
|
|
|
|
|
|
|
prepend_sources(SRB2_SDL2_SOURCES)
|
|
|
|
prepend_sources(SRB2_SDL2_HEADERS)
|
|
|
|
|
|
|
|
# Dependency
|
|
|
|
find_package(SDL2)
|
|
|
|
|
|
|
|
if(${SDL2_FOUND})
|
|
|
|
set(SRB2_SDL2_TOTAL_SOURCES
|
|
|
|
${SRB2_CORE_SOURCES}
|
|
|
|
${SRB2_CORE_HEADERS}
|
|
|
|
${SRB2_SDL2_SOURCES}
|
|
|
|
${SRB2_SDL2_HEADERS}
|
|
|
|
)
|
|
|
|
|
2015-01-28 07:20:43 +00:00
|
|
|
if(${SRB2_CONFIG_HWRENDER})
|
2015-01-28 05:46:39 +00:00
|
|
|
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
|
|
|
${SRB2_HWRENDER_SOURCES}
|
|
|
|
${SRB2_HWRENDER_HEADERS}
|
|
|
|
${SRB2_R_OPENGL_SOURCES}
|
|
|
|
${SRB2_R_OPENGL_HEADERS}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${SRB2_CONFIG_HAVE_BLUA})
|
|
|
|
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
|
|
|
${SRB2_LUA_SOURCES}
|
|
|
|
${SRB2_LUA_HEADERS}
|
|
|
|
${SRB2_BLUA_SOURCES}
|
|
|
|
${SRB2_BLUA_HEADERS}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM} MATCHES Windows)
|
|
|
|
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
|
|
|
${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c
|
2015-01-28 08:12:14 +00:00
|
|
|
${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc
|
2015-01-28 20:15:24 +00:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
if(NOT CLANG)
|
|
|
|
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
2015-01-28 07:20:43 +00:00
|
|
|
${CMAKE_SOURCE_DIR}/src/string.c
|
2015-01-28 05:46:39 +00:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-01-28 06:58:30 +00:00
|
|
|
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
|
|
|
set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns)
|
|
|
|
set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
|
|
|
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
|
|
|
macosx/mac_alert.c
|
|
|
|
macosx/mac_alert.h
|
2015-01-29 05:02:18 +00:00
|
|
|
macosx/mac_resources.c
|
|
|
|
macosx/mac_resources.h
|
2015-01-28 06:58:30 +00:00
|
|
|
macosx/Srb2mac.icns
|
|
|
|
)
|
|
|
|
endif()
|
2015-01-28 05:46:39 +00:00
|
|
|
|
2015-01-28 06:58:30 +00:00
|
|
|
if(CLANG)
|
|
|
|
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})
|
2015-01-28 07:20:43 +00:00
|
|
|
add_framework(SDL2_mixer ${SRB2_SDL2_EXE_NAME})
|
2015-01-28 06:58:30 +00:00
|
|
|
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
|
|
|
${PNG_LIBRARIES}
|
|
|
|
${ZLIB_LIBRARIES}
|
|
|
|
${OPENGL_LIBRARIES}
|
|
|
|
)
|
2015-01-29 01:29:16 +00:00
|
|
|
set_target_properties(${SRB2_SDL2_EXE_NAME} PROPERTIES OUTPUT_NAME "Sonic Robo Blast 2")
|
2015-01-28 06:58:30 +00:00
|
|
|
else()
|
|
|
|
add_executable(${SRB2_SDL2_EXE_NAME} WIN32 ${SRB2_SDL2_TOTAL_SOURCES})
|
|
|
|
|
|
|
|
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
|
|
|
${SDL2_LIBRARIES}
|
2015-01-28 07:20:43 +00:00
|
|
|
${SDL2_MIXER_LIBRARIES}
|
2015-01-28 06:58:30 +00:00
|
|
|
${PNG_LIBRARIES}
|
|
|
|
${ZLIB_LIBRARIES}
|
|
|
|
${OPENGL_LIBRARIES}
|
|
|
|
)
|
|
|
|
|
2015-01-29 05:20:21 +00:00
|
|
|
if(${CMAKE_SYSTEM} MATCHES Linux)
|
|
|
|
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
|
|
|
m
|
|
|
|
rt
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-01-28 06:58:30 +00:00
|
|
|
endif()
|
2015-01-28 05:46:39 +00:00
|
|
|
|
2015-01-29 01:29:16 +00:00
|
|
|
set_target_properties(${SRB2_SDL2_EXE_NAME} PROPERTIES VERSION ${SRB2_VERSION})
|
|
|
|
|
2015-01-28 05:46:39 +00:00
|
|
|
if(${CMAKE_SYSTEM} MATCHES Windows)
|
|
|
|
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
|
|
|
ws2_32
|
|
|
|
)
|
|
|
|
target_compile_options(${SRB2_SDL2_EXE_NAME} PRIVATE
|
|
|
|
-U_WINDOWS
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-01-28 08:09:03 +00:00
|
|
|
if(MSVC)
|
2015-01-28 21:33:29 +00:00
|
|
|
find_package(SDL2_MAIN REQUIRED)
|
2015-01-28 08:09:03 +00:00
|
|
|
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
|
|
|
${SDL2_MAIN_LIBRARIES}
|
|
|
|
)
|
|
|
|
target_compile_options(${SRB2_SDL2_EXE_NAME} PRIVATE
|
|
|
|
/Umain
|
|
|
|
/D_CRT_SECURE_NO_WARNINGS # something about string functions.
|
|
|
|
/D_CRT_NONSTDC_NO_DEPRECATE
|
|
|
|
/DSDLMAIN
|
|
|
|
/D_WINSOCK_DEPRECATED_NO_WARNINGS # Don't care
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-01-28 05:46:39 +00:00
|
|
|
target_include_directories(${SRB2_SDL2_EXE_NAME} PRIVATE
|
|
|
|
${SDL2_INCLUDE_DIRS}
|
2015-01-28 07:20:43 +00:00
|
|
|
${SDL2_MIXER_INCLUDE_DIRS}
|
2015-01-28 05:46:39 +00:00
|
|
|
${PNG_INCLUDE_DIRS}
|
|
|
|
${ZLIB_INCLUDE_DIRS}
|
|
|
|
${OPENGL_INCLUDE_DIRS}
|
|
|
|
)
|
|
|
|
|
2015-01-28 07:20:43 +00:00
|
|
|
if(${SRB2_HAVE_MIXER})
|
|
|
|
target_compile_definitions(${SRB2_SDL2_EXE_NAME} PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
|
|
|
|
endif()
|
|
|
|
|
2015-01-28 05:46:39 +00:00
|
|
|
target_compile_definitions(${SRB2_SDL2_EXE_NAME} PRIVATE
|
|
|
|
-DHAVE_SDL
|
|
|
|
)
|
2015-01-28 22:42:05 +00:00
|
|
|
|
|
|
|
#### Installation ####
|
2015-01-29 01:29:16 +00:00
|
|
|
if (CLANG)
|
|
|
|
install(TARGETS ${SRB2_SDL2_EXE_NAME}
|
|
|
|
BUNDLE DESTINATION .
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
install(TARGETS ${SRB2_SDL2_EXE_NAME} ${SRB2_SDL2_EXE_NAME}
|
|
|
|
RUNTIME DESTINATION .
|
|
|
|
)
|
|
|
|
endif()
|
2015-01-28 22:42:05 +00:00
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM} MATCHES Windows)
|
2015-02-01 04:40:36 +00:00
|
|
|
set(win_extra_dll_list "")
|
|
|
|
macro(getwinlib dllname defaultname)
|
|
|
|
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}")
|
|
|
|
list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}})
|
|
|
|
endmacro()
|
|
|
|
getwinlib(SDL2 "SDL2.dll")
|
2015-01-28 22:42:05 +00:00
|
|
|
if(${SRB2_CONFIG_SDL2_USEMIXER})
|
2015-02-01 04:40:36 +00:00
|
|
|
getwinlib(SDL2_mixer "SDL2_mixer.dll")
|
|
|
|
getwinlib(libmikmod-2 "libmikmod-2.dll")
|
|
|
|
getwinlib(libogg_0 "libogg-0.dll")
|
|
|
|
getwinlib(libvorbis_0 "libvorbis-0.dll")
|
|
|
|
getwinlib(libvorbisfile_3 "libvorbisfile-3.dll")
|
|
|
|
getwinlib(smpeg2 "smpeg2.dll")
|
2015-01-28 22:42:05 +00:00
|
|
|
endif()
|
|
|
|
if(${SRB2_CONFIG_HAVE_GME})
|
2015-02-01 04:40:36 +00:00
|
|
|
getwinlib(libgme "libgme.dll")
|
2015-01-28 22:42:05 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
install(PROGRAMS
|
2015-02-01 04:40:36 +00:00
|
|
|
${win_extra_dll_list}
|
2015-01-28 22:42:05 +00:00
|
|
|
DESTINATION .
|
|
|
|
)
|
2015-02-01 04:40:36 +00:00
|
|
|
|
|
|
|
# We also want to copy those DLLs to build directories on MSVC.
|
|
|
|
# So we'll add a post_build step.
|
|
|
|
copy_files_to_build_dir(${SRB2_SDL2_EXE_NAME} win_extra_dll_list)
|
2015-01-28 22:42:05 +00:00
|
|
|
endif()
|
2015-01-29 05:02:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Mac bundle fixup
|
|
|
|
if(CLANG)
|
|
|
|
install(CODE "
|
|
|
|
include(BundleUtilities)
|
|
|
|
fixup_bundle(\"${CMAKE_INSTALL_PREFIX}/Sonic Robo Blast 2.app\"
|
|
|
|
\"\"
|
|
|
|
/Library/Frameworks
|
|
|
|
)"
|
|
|
|
)
|
|
|
|
endif()
|
2015-01-28 05:46:39 +00:00
|
|
|
else()
|
|
|
|
message(WARNING "SDL2 wasn't found, so ${SRB2_SDL2_EXE_NAME} won't be available")
|
|
|
|
endif()
|