diff --git a/.gitattributes b/.gitattributes index 777bf189..d4562091 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13,20 +13,6 @@ *.manifest -crlf -whitespace # Patches /tools/SDL-1.2.14-gc/SDL-1.2.14-gc.patch -whitespace -# LibPNG -/libs/libpng-src/CMakeLists.txt -whitespace -/libs/libpng-src/libpng-1.2.*.txt -whitespace -/libs/libpng-src/libpng.3 -whitespace -/libs/libpng-src/*.c -whitespace -# Zlib -/libs/zlib/contrib/amd64/amd64-match.S -whitespace -/libs/zlib/contrib/delphi/zlibd32.mak -crlf -whitespace -/libs/zlib/contrib/gcc_gvmat64/gvmat64.S -whitespace -/libs/zlib/contrib/minizip/MiniZip64_Changes.txt -whitespace -/libs/zlib/contrib/minizip/MiniZip64_info.txt -whitespace -/libs/zlib/contrib/pascal/zlibd32.mak -whitespace -/libs/zlib/nintendods/Makefile -whitespace -/libs/zlib/nintendods/README -whitespace -/libs/zlib/watcom/watcom_f.mak -crlf -whitespace -/libs/zlib/watcom/watcom_l.mak -crlf -whitespace +#Appveyor +/appveyor.yml -crlf -whitespace # Other diff --git a/.gitignore b/.gitignore index 567fecd8..7b2304ec 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,8 @@ Win32_LIB_ASM_Release *.dgb *.debug *.debug.txt +/bin/VC10/ +/objs/VC10/ +*.user +*.db +*.opendb diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cffa367..cb93d22f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,173 +1,127 @@ -# -# Simple CMakeLists for Sonic Robo Blast 2 -# -PROJECT(SRB2) +cmake_minimum_required(VERSION 3.0) +project(SRB2 + VERSION 2.1.14 + LANGUAGES C) -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) + message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") +endif() -# -# Dependencies -# -FIND_PACKAGE(SDL) -FIND_PACKAGE(SDL_mixer) -FIND_PACKAGE(PNG) +# Set up CMAKE path +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") -# -# Common stuff -# +### Useful functions -# not added defines: -# -DHAVE_PNG - does not build (incorrect use of PNG_EXPORT etc.) -ADD_DEFINITIONS(-DDIRECTFULLSCREEN -DSDL -DHAVE_MIXER -DNOHW -DHW3SOUND -DHAVE_BLUA -DNOASM) +# Prepend sources with current source directory +function(prepend_sources SOURCE_FILES) + foreach(SOURCE_FILE ${${SOURCE_FILES}}) + set(MODIFIED ${MODIFIED} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE}) + endforeach() + set(${SOURCE_FILES} ${MODIFIED} PARENT_SCOPE) +endfunction() -SET(SDL_DIR sdl) # may be set to SDL2 optionally +# Macro to add OSX framework +macro(add_framework fwname appname) + find_library(FRAMEWORK_${fwname} + NAMES ${fwname} + PATHS ${CMAKE_OSX_SYSROOT}/System/Library + ${CMAKE_OSX_SYSROOT}/Library + /System/Library + /Library + ATH_SUFFIXES Frameworks + NO_DEFAULT_PATH) + if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND) + MESSAGE(ERROR ": Framework ${fwname} not found") + else() + TARGET_LINK_LIBRARIES(${appname} PRIVATE "${FRAMEWORK_${fwname}}/${fwname}") + MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}") + endif() +endmacro() -SET(COMMON_SRCS - src/${SDL_DIR}/dosstr.c - src/${SDL_DIR}/endtxt.c - src/${SDL_DIR}/hwsym_sdl.c - src/${SDL_DIR}/i_cdmus.c - src/${SDL_DIR}/i_main.c - src/${SDL_DIR}/i_net.c - src/${SDL_DIR}/i_system.c - src/${SDL_DIR}/i_video.c - src/${SDL_DIR}/mixer_sound.c - src/am_map.c - src/b_bot.c - src/blua/lapi.c - src/blua/lauxlib.c - src/blua/lbaselib.c - src/blua/lcode.c - src/blua/ldebug.c - src/blua/ldo.c - src/blua/ldump.c - src/blua/lfunc.c - src/blua/lgc.c - src/blua/linit.c - src/blua/llex.c - src/blua/lmem.c - src/blua/lobject.c - src/blua/lopcodes.c - src/blua/lparser.c - src/blua/lstate.c - src/blua/lstring.c - src/blua/lstrlib.c - src/blua/ltable.c - src/blua/ltablib.c - src/blua/ltm.c - src/blua/lundump.c - src/blua/lvm.c - src/blua/lzio.c - src/command.c - src/comptime.c - src/console.c - src/d_clisrv.c - src/d_main.c - src/d_net.c - src/d_netcmd.c - src/d_netfil.c - src/dehacked.c - src/f_finale.c - src/f_wipe.c - src/filesrch.c - src/g_game.c - src/g_input.c - src/hardware/hw3sound.c - src/hu_stuff.c - src/i_tcp.c - src/info.c - src/lua_baselib.c - src/lua_consolelib.c - src/lua_hooklib.c - src/lua_hudlib.c - src/lua_infolib.c - src/lua_maplib.c - src/lua_mathlib.c - src/lua_mobjlib.c - src/lua_playerlib.c - src/lua_script.c - src/lua_skinlib.c - src/lua_thinkerlib.c - src/lzf.c - src/m_anigif.c - src/m_argv.c - src/m_bbox.c - src/m_cheat.c - src/m_cond.c - src/m_fixed.c - src/m_menu.c - src/m_misc.c - src/m_queue.c - src/m_random.c - src/md5.c - src/mserv.c - src/p_ceilng.c - src/p_enemy.c - src/p_fab.c - src/p_floor.c - src/p_inter.c - src/p_lights.c - src/p_map.c - src/p_maputl.c - src/p_mobj.c - src/p_polyobj.c - src/p_saveg.c - src/p_setup.c - src/p_sight.c - src/p_spec.c - src/p_telept.c - src/p_tick.c - src/p_user.c - src/r_bsp.c - src/r_data.c - src/r_draw.c - src/r_main.c - src/r_plane.c - src/r_segs.c - src/r_sky.c - src/r_splats.c - src/r_things.c - src/s_sound.c - src/screen.c - src/sounds.c - src/st_stuff.c - src/string.c - src/tables.c - src/v_video.c - src/w_wad.c - src/y_inter.c - src/z_zone.c -) +# Macro to copy Windows DLLs to Debug/Release folder for easy debugging +# Note: this is general purpose, we could copy anything. Just using for DLLs on MSVC though +macro(copy_files_to_build_dir target dlllist_var) + if(MSVC) + # http://stackoverflow.com/a/26983405/3064195 + foreach(dlllist_item ${${dlllist_var}}) + get_filename_component(dllname ${dlllist_item} NAME) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${dlllist_item} + $/${dllname} + ) + endforeach() + endif() +endmacro() -# -# Platform-specific stuff -# +# 64-bit check +if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + message(STATUS "Target is 64-bit") + set(SRB2_SYSTEM_BITS 64) +else() + set(SRB2_SYSTEM_BITS 32) +endif() -MACRO(EXTRALIB NAME) - FIND_LIBRARY(${NAME}_LIBRARY NAMES ${NAME}) - IF(${NAME}_LIBRARY) - MESSAGE(STATUS "Found lib${NAME}: ${${NAME}_LIBRARY}") - SET(EXTRA_LIBRARIES ${EXTRA_LIBRARIES} ${${NAME}_LIBRARY}) - ELSE(${NAME}_LIBRARY) - MESSAGE(FATAL_ERROR "Could not find lib${NAME}!") - ENDIF(${NAME}_LIBRARY) -ENDMACRO(EXTRALIB) +# OS macros +if (UNIX) + add_definitions(-DUNIXCOMMON) +endif() -IF(${CMAKE_SYSTEM} MATCHES "FreeBSD") - ADD_DEFINITIONS(-DUNIXCOMMON -DLINUX -DFREEBSD) - EXTRALIB(kvm) -ELSEIF(${CMAKE_SYSTEM} MATCHES "Linux") - ADD_DEFINITIONS(-DUNIXCOMMON -DLINUX) - EXTRALIB(m) - EXTRALIB(rt) -ELSE(${CMAKE_SYSTEM} MATCHES "FreeBSD") - ADD_DEFINITIONS(-DUNIXCOMMON -DLINUX) - MESSAGE(WARNING "No specific settings for you system, it may be not supported!") -ENDIF(${CMAKE_SYSTEM} MATCHES "FreeBSD") +if(CMAKE_COMPILER_IS_GNUCC) + find_program(OBJCOPY objcopy) +endif() -# -# Targets -# -INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIRS} ${SDL_INCLUDE_DIR} ${SDL_MIXER_INCLUDE_DIRS}) -ADD_EXECUTABLE(SRB2 ${COMMON_SRCS}) -TARGET_LINK_LIBRARIES(SRB2 ${SDL_LIBRARY} ${SDL_MIXER_LIBRARIES} ${EXTRA_LIBRARIES}) +if(${CMAKE_SYSTEM} MATCHES "Linux") + add_definitions(-DLINUX) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + add_definitions(-DLINUX64) + endif() +endif() + +if(${CMAKE_SYSTEM} MATCHES "Darwin") + add_definitions(-DMACOSX) +endif() + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") +set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + +# Set EXE names so the assets CMakeLists can refer to its target +set(SRB2_SDL2_EXE_NAME srb2) +set(SRB2_WIN_EXE_NAME srb2dd) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) + +add_subdirectory(src) +add_subdirectory(assets) + + +## config.h generation +set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") +include(GitUtilities) +git_describe(SRB2_GIT_DESCRIBE "${CMAKE_SOURCE_DIR}") +git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}") +set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}") +set(SRB2_COMP_REVISION "${SRB2_GIT_DESCRIBE}") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h) + +##### PACKAGE CONFIGURATION ##### + +if(${CMAKE_SYSTEM} MATCHES "Windows") + set(CPACK_GENERATOR "ZIP") +endif() +if(${CMAKE_SYSTEM} MATCHES "Linux") + set(CPACK_GENERATOR "TGZ") +endif() +if(${CMAKE_SYSTEM} MATCHES "Darwin") + set(CPACK_GENERATOR "DragNDrop") +endif() + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2") +set(CPACK_PACKAGE_VENDOR "Sonic Team Jr.") +#set(CPACK_PACKAGE_DESCRIPTION_FILE ) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH}) +set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}") +include(CPack) diff --git a/SRB2.cbp b/SRB2.cbp index 4834563e..43696ee2 100644 --- a/SRB2.cbp +++ b/SRB2.cbp @@ -154,8 +154,8 @@ HW3SOUND for 3D hardware sound support - - + + @@ -200,8 +200,8 @@ HW3SOUND for 3D hardware sound support - - + + @@ -3293,23 +3293,6 @@ HW3SOUND for 3D hardware sound support