cmake: Fixes to allow MSVC to compile

running is another story
This commit is contained in:
Ronald Kinard 2015-01-28 02:09:03 -06:00
parent 495ea65cc5
commit 2f1367aab6
8 changed files with 40 additions and 8 deletions

View file

@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(SRB2 project(SRB2
VERSION 2.1.14) VERSION 2.1.14
LANGUAGES C)
# Set up CMAKE path # Set up CMAKE path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
@ -41,9 +42,8 @@ else()
set(SRB2_SYSTEM_BITS 32) set(SRB2_SYSTEM_BITS 32)
endif() endif()
# DO NOT ALLOW MSVC!
if(MSVC) if(MSVC)
message(FATAL_ERROR "MSVC is not supported!") message(WARNING "!! MSVC BUILDS OF SRB2 CANNOT PLAY MULTIPLAYER !! You're more than welcome to try and fix this!")
endif() endif()
# OS macros # OS macros

View file

@ -27,8 +27,19 @@ find_library(SDL2_LIBRARY
"/usr/local/lib" "/usr/local/lib"
) )
find_library(SDL2_MAIN_LIBRARY
NAMES SDL2_main
PATHS
${SDL2_PKGCONF_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
)
# set include dir variables # set include dir variables
set(SDL2_PROCESS_INCLUDES SDL2_INCLUDE_DIR) set(SDL2_PROCESS_INCLUDES SDL2_INCLUDE_DIR)
set(SDL2_PROCESS_LIBS SDL2_LIBRARY) set(SDL2_PROCESS_LIBS SDL2_LIBRARY)
set(SDL2_MAIN_PROCESS_INCLUDES SDL2_INCLUDE_DIR)
set(SDL2_MAIN_PROCESS_LIBS SDL2_MAIN_LIBRARY)
libfind_process(SDL2) libfind_process(SDL2)
libfind_process(SDL2_MAIN)

View file

@ -354,7 +354,7 @@ endif()
# Compatibility flag with later versions of GCC # Compatibility flag with later versions of GCC
# We should really fix our code to not need this # We should really fix our code to not need this
if(NOT CLANG) if(NOT CLANG AND NOT MSVC)
add_compile_options(-mno-ms-bitfields) add_compile_options(-mno-ms-bitfields)
endif() endif()

View file

@ -146,6 +146,7 @@ extern FILE *logstream;
#define VERSION 201 // Game version #define VERSION 201 // Game version
#define SUBVERSION 14 // more precise version number #define SUBVERSION 14 // more precise version number
#define VERSIONSTRING "v2.1.14" #define VERSIONSTRING "v2.1.14"
#define VERSIONSTRINGW L"v2.1.14"
// Hey! If you change this, add 1 to the MODVERSION below! // Hey! If you change this, add 1 to the MODVERSION below!
// Otherwise we can't force updates! // Otherwise we can't force updates!
#endif #endif

View file

@ -210,8 +210,8 @@ static void F_DoWipe(fademask_t *fademask)
UINT32 draw_linestogo, draw_rowstogo; UINT32 draw_linestogo, draw_rowstogo;
// rectangle coordinates, etc. // rectangle coordinates, etc.
UINT16 scrxpos[fademask->width + 1]; UINT16* scrxpos = (UINT16*)malloc(fademask->width + 1); //[fademask->width + 1];
UINT16 scrypos[fademask->height + 1]; UINT16* scrypos = (UINT16*)malloc(fademask->height + 1);// [fademask->height + 1];
UINT16 maskx, masky; UINT16 maskx, masky;
UINT32 relativepos; UINT32 relativepos;
@ -263,6 +263,9 @@ static void F_DoWipe(fademask_t *fademask)
if (++maskx >= fademask->width) if (++maskx >= fademask->width)
++masky, maskx = 0; ++masky, maskx = 0;
} while (++mask < maskend); } while (++mask < maskend);
free(scrxpos);
free(scrypos);
} }
} }
#endif #endif

View file

@ -129,6 +129,19 @@ if(${SDL2_FOUND})
) )
endif() endif()
if(MSVC)
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()
target_include_directories(${SRB2_SDL2_EXE_NAME} PRIVATE target_include_directories(${SRB2_SDL2_EXE_NAME} PRIVATE
${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}
${SDL2_MIXER_INCLUDE_DIRS} ${SDL2_MIXER_INCLUDE_DIRS}

View file

@ -1661,7 +1661,7 @@ void I_UpdateMumble(const mobj_t *mobj, const listener_t listener)
return; return;
if(mumble->uiVersion != 2) { if(mumble->uiVersion != 2) {
wcsncpy(mumble->name, L"SRB2 "VERSIONSTRING, 256); wcsncpy(mumble->name, L"SRB2 "VERSIONSTRINGW, 256);
wcsncpy(mumble->description, L"Sonic Robo Blast 2 with integrated Mumble Link support.", 2048); wcsncpy(mumble->description, L"Sonic Robo Blast 2 with integrated Mumble Link support.", 2048);
mumble->uiVersion = 2; mumble->uiVersion = 2;
} }

View file

@ -25,7 +25,11 @@ extern SDL_bool framebuffer;
#include "../m_fixed.h" #include "../m_fixed.h"
// SDL2 stub macro // SDL2 stub macro
#define SDL2STUB(name) CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__) #ifdef _MSC_VER
#define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __FUNCTION__, __LINE__)
#else
#define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__)
#endif
/** \brief The JoyInfo_s struct /** \brief The JoyInfo_s struct