From 4e096c127c172229d959def8a96699540b0bb13e Mon Sep 17 00:00:00 2001 From: Su Yong Date: Sat, 11 Feb 2017 10:57:35 +0800 Subject: [PATCH 1/9] Some fixes for MSVC. --- CMakeLists.txt | 24 +++++++++++++++++++++--- fex/CMakeLists.txt | 1 + src/common/ConfigManager.cpp | 24 +++++++++++++++++++++++- src/common/SoundDriver.h | 2 ++ src/common/memgzio.c | 3 ++- src/wx/CMakeLists.txt | 19 ++++++++++++++++--- src/wx/guiinit.cpp | 2 +- src/wx/panel.cpp | 1 + src/wx/sys.cpp | 2 +- src/wx/viewsupt.h | 14 ++++++++------ src/wx/widgets/wx/joyedit.h | 2 +- src/wx/widgets/wx/keyedit.h | 2 +- src/wx/widgets/wx/wxmisc.h | 2 +- src/wx/wxvbam.cpp | 1 - src/wx/wxvbam.h | 9 +++++---- 15 files changed, 84 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a583dd15..b7a195b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,10 @@ ENDIF() OPTION(ENABLE_LTO "Compile with Link Time Optimization (gcc and clang only)" ${LTO_DEFAULT}) +if(MSVC) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) +endif(MSVC) + option( ENABLE_GBA_LOGGING "Enable extended GBA logging" ON ) if( ENABLE_GBA_LOGGING ) ADD_DEFINITIONS (-DGBA_LOGGING ) @@ -191,8 +195,8 @@ IF( NOT SYSCONF_INSTALL_DIR ) ENDIF( NOT SYSCONF_INSTALL_DIR ) # C defines -ADD_DEFINITIONS (-DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DHAVE_ZLIB_H -DFINAL_VERSION -DSDL -DUSE_OPENGL -DSYSCONF_INSTALL_DIR='"${SYSCONF_INSTALL_DIR}"' -DWITH_LIRC='${WITHLIRC}') -ADD_DEFINITIONS (-DVERSION='"${VERSION}"' -DPKGDATADIR='"${PKGDATADIR}"' -DPACKAGE='') +ADD_DEFINITIONS (-DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DHAVE_ZLIB_H -DFINAL_VERSION -DSDL -DUSE_OPENGL -DSYSCONF_INSTALL_DIR=\\\""${SYSCONF_INSTALL_DIR}"\\\" -DWITH_LIRC=${WITHLIRC}) +ADD_DEFINITIONS (-DVERSION=\\\""${VERSION}"\\\" -DPKGDATADIR=\\\""${PKGDATADIR}"\\\" -DPACKAGE=) if( ENABLE_LINK ) # IPC linking code needs sem_timedwait which can be either in librt or pthreads @@ -233,7 +237,7 @@ ENDIF( NOT ENABLE_ASM_CORE ) if( ENABLE_NLS ) SET( LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale ) ADD_DEFINITIONS ( -DENABLE_NLS ) - ADD_DEFINITIONS ( -DLOCALEDIR='"${LOCALEDIR}"' ) + ADD_DEFINITIONS ( -DLOCALEDIR=\\\"${LOCALEDIR}\\\" ) # for now, only GBALink.cpp uses gettext() directly IF(APPLE) # use Homebrew gettext if available @@ -397,6 +401,10 @@ SET(SRC_MAIN src/common/SoundSDL.cpp ) +if(MSVC) + SET(SRC_MAIN ${SRC_MAIN} "dependencies/msvc/getopt.c") +endif(MSVC) + SET(HDR_MAIN src/AutoBuild.h src/System.h @@ -412,6 +420,10 @@ SET(HDR_MAIN src/common/SoundSDL.h ) +if(MSVC) + SET(HDR_MAIN ${HDR_MAIN} "dependencies/msvc/getopt.h") +endif(MSVC) + if(ENABLE_FFMPEG) SET(SRC_MAIN ${SRC_MAIN} src/common/ffmpeg.cpp) SET(HDR_MAIN ${HDR_MAIN} src/common/ffmpeg.h) @@ -613,6 +625,12 @@ IF( ENABLE_FFMPEG ) ) ENDIF( ENABLE_FFMPEG ) +if(MSVC) + INCLUDE_DIRECTORIES( + dependencies/msvc # for getopt.h + ) +endif() + ADD_LIBRARY ( vbamcore STATIC diff --git a/fex/CMakeLists.txt b/fex/CMakeLists.txt index 811d7485..f464a5eb 100644 --- a/fex/CMakeLists.txt +++ b/fex/CMakeLists.txt @@ -34,6 +34,7 @@ SET(SRC_FEX INCLUDE_DIRECTORIES( . + ${ZLIB_INCLUDE_DIRS} ) ADD_LIBRARY( diff --git a/src/common/ConfigManager.cpp b/src/common/ConfigManager.cpp index dafdb72b..0718a515 100644 --- a/src/common/ConfigManager.cpp +++ b/src/common/ConfigManager.cpp @@ -820,6 +820,28 @@ const char* ReadPrefString(const char* pref_key) return ReadPrefString(pref_key, ""); } +/*-------------------------------------------------------------------------*/ +/** + @brief Duplicate a string + @param s String to duplicate + @return Pointer to a newly allocated string, to be freed with free() + + This is a replacement for strdup(). This implementation is provided + for systems that do not have it. + */ +/*--------------------------------------------------------------------------*/ +static char *xstrdup(const char *s) +{ + char *t; + if (!s) + return NULL; + t = (char *)malloc(strlen(s) + 1); + if (t) { + strcpy(t, s); + } + return t; +} + int ReadOpts(int argc, char ** argv) { int op = -1; @@ -859,7 +881,7 @@ int ReadOpts(int argc, char ** argv) log("Missing BIOS file name\n"); break; } - biosFileNameGBA = strdup(optarg); + biosFileNameGBA = xstrdup(optarg); break; case 'c': { diff --git a/src/common/SoundDriver.h b/src/common/SoundDriver.h index f9639db3..afceef3e 100644 --- a/src/common/SoundDriver.h +++ b/src/common/SoundDriver.h @@ -18,6 +18,8 @@ #ifndef __VBA_SOUND_DRIVER_H__ #define __VBA_SOUND_DRIVER_H__ +#include // for uint16_t + /** * Sound driver abstract interface for the core to use to output sound. * Subclass this to implement a new sound driver. diff --git a/src/common/memgzio.c b/src/common/memgzio.c index 5184653d..f7c6aa13 100644 --- a/src/common/memgzio.c +++ b/src/common/memgzio.c @@ -717,8 +717,9 @@ int ZEXPORT memgzclose(file) gzFile file; long ZEXPORT memtell(file) gzFile file; { + mem_stream *s; do_flush(file, Z_FULL_FLUSH); // makes memtell to tell truth - mem_stream *s = (mem_stream *)file; + s = (mem_stream *)file; if (s == NULL) return Z_STREAM_ERROR; diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index 4b1189aa..fb78fcf9 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -1,6 +1,11 @@ #Do not use this file directly. Always use the top level CMakeLists.txt file # This build is much easier if we just do it here. -SET( CMAKE_CXX_FLAGS -std=gnu++11 ) + +cmake_policy(SET CMP0043 NEW) # for wxWidgets + +IF(CMAKE_COMPILER_IS_GNUCXX) + SET( CMAKE_CXX_FLAGS -std=gnu++11 ) +ENDIF(CMAKE_COMPILER_IS_GNUCXX) # not yet implemented SET(CAIRO_DEFAULT OFF) @@ -144,6 +149,10 @@ ENDIF(WIN32 AND ENABLE_DIRECTX) # contrib widgets include_directories(widgets) +IF(MSVC) + include_directories(../../dependencies/msvc) # for GL/glext.h +ENDIF(MSVC) + # for out-of-tree builds, grab includes from both target and source dirs include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) @@ -301,10 +310,14 @@ ENDIF(ENABLE_XAUDIO2) IF( WIN32 ) SET( SRC_WX ${SRC_WX} wxvbam.rc dsound.cpp ) - SET(DIRECTX_LIBRARIES -ldxguid -ldsound -lws2_32) + SET(DIRECTX_LIBRARIES dxguid dsound ws2_32) + IF(MSVC) + # workaround for some symbols needed by static SDL2.lib + SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} imm32 version) + ENDIF(MSVC) # not strictly directx, but win32-related IF(ENABLE_DEBUGGER) - SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} -lwsock32) + SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} wsock32) ENDIF(ENABLE_DEBUGGER) ENDIF( WIN32 ) diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp index 5d8cf1b3..9fe08f04 100644 --- a/src/wx/guiinit.cpp +++ b/src/wx/guiinit.cpp @@ -752,7 +752,7 @@ public: int count8, count16, count32; // number of aligned addresses in addrs wxString OnGetItemText(long item, long column) const; - DECLARE_DYNAMIC_CLASS() + DECLARE_DYNAMIC_CLASS(CheatListCtrl) }; IMPLEMENT_DYNAMIC_CLASS(CheatListCtrl, wxListCtrl); diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index 8b3da44d..757524fc 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1308,6 +1308,7 @@ DrawingPanelBase::DrawingPanelBase(int _width, int _height) : width(_width) , height(_height) , scale(1) + , did_init(false) , todraw(0) , pixbuf1(0) , pixbuf2(0) diff --git a/src/wx/sys.cpp b/src/wx/sys.cpp index 7f541ccb..4f2371a0 100644 --- a/src/wx/sys.cpp +++ b/src/wx/sys.cpp @@ -686,7 +686,7 @@ private: wxRect margins; int npw, nph; - DECLARE_CLASS() + DECLARE_CLASS(PrintDialog) }; IMPLEMENT_CLASS(PrintDialog, wxEvtHandler) diff --git a/src/wx/viewsupt.h b/src/wx/viewsupt.h index 893cc2eb..ea8deb10 100644 --- a/src/wx/viewsupt.h +++ b/src/wx/viewsupt.h @@ -14,6 +14,8 @@ #include #include +#include // for uint32_t + // avoid exporting too much stuff namespace Viewers { // common to all viewers: @@ -151,7 +153,7 @@ protected: uint32_t seladdr; bool issel; - DECLARE_DYNAMIC_CLASS() // for xrc + DECLARE_DYNAMIC_CLASS(DisList) // for xrc DECLARE_EVENT_TABLE() }; @@ -229,7 +231,7 @@ protected: bool isasc; void ShowCaret(); - DECLARE_DYNAMIC_CLASS() // for xrc + DECLARE_DYNAMIC_CLASS(MemView) // for xrc DECLARE_EVENT_TABLE() }; @@ -314,7 +316,7 @@ protected: int ox, oy, selx, sely; DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS() + DECLARE_DYNAMIC_CLASS(PixView) }; #define pixview(v, n, w, h, cv) \ do { \ @@ -348,7 +350,7 @@ protected: private: int selx, sely; - DECLARE_DYNAMIC_CLASS() + DECLARE_DYNAMIC_CLASS(GfxPanel) DECLARE_EVENT_TABLE() }; @@ -398,7 +400,7 @@ protected: // always generates a GFX_CLICK void SelPoint(wxMouseEvent& ev); void click(); - DECLARE_DYNAMIC_CLASS() + DECLARE_DYNAMIC_CLASS(PixViewEvt) }; // a display-only checkbox which does not look like it's disabled @@ -412,7 +414,7 @@ public: { } DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS() + DECLARE_DYNAMIC_CLASS(DispCheckBox) }; // standard widgets in graphical viewers diff --git a/src/wx/widgets/wx/joyedit.h b/src/wx/widgets/wx/joyedit.h index d0446f19..df34c96c 100644 --- a/src/wx/widgets/wx/joyedit.h +++ b/src/wx/widgets/wx/joyedit.h @@ -62,7 +62,7 @@ public: protected: void OnJoy(wxSDLJoyEvent&); - DECLARE_DYNAMIC_CLASS(); + DECLARE_DYNAMIC_CLASS(wxJoyKeyTextCtrl); DECLARE_EVENT_TABLE(); }; diff --git a/src/wx/widgets/wx/keyedit.h b/src/wx/widgets/wx/keyedit.h index 47aebff3..ff79e92e 100644 --- a/src/wx/widgets/wx/keyedit.h +++ b/src/wx/widgets/wx/keyedit.h @@ -74,7 +74,7 @@ protected: // the last keydown event received; this is processed on next keyup int lastmod, lastkey; - DECLARE_DYNAMIC_CLASS(); + DECLARE_DYNAMIC_CLASS(wxKeyTextCtrl); DECLARE_EVENT_TABLE(); }; diff --git a/src/wx/widgets/wx/wxmisc.h b/src/wx/widgets/wx/wxmisc.h index fedacfde..08589fa6 100644 --- a/src/wx/widgets/wx/wxmisc.h +++ b/src/wx/widgets/wx/wxmisc.h @@ -23,7 +23,7 @@ protected: void UpdatedValue(); void UpdateEvt(wxCommandEvent& ev); wxFarRadio* Next; - DECLARE_DYNAMIC_CLASS() + DECLARE_DYNAMIC_CLASS(wxFarRadio) DECLARE_EVENT_TABLE() }; diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 0777f84b..25d696ae 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -5,7 +5,6 @@ // create & display main frame #include "wxvbam.h" -#include #include #include #include diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index cb772537..330969a1 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -307,7 +307,7 @@ public: virtual bool DialogOpened() { return dialog_opened != 0; } // required for building from xrc - DECLARE_DYNAMIC_CLASS(); + DECLARE_DYNAMIC_CLASS(MainFrame); // required for event handling DECLARE_EVENT_TABLE(); @@ -364,12 +364,13 @@ private: // helper class to add HiDPI awareness (mostly for Mac OS X) class HiDPIAware { public: + HiDPIAware() { hidpi_scale_factor = 0; } virtual double HiDPIScaleFactor(); virtual void RequestHighResolutionOpenGLSurface(); virtual void GetRealPixelClientSize(int* x, int* y); virtual wxWindow* GetWindow() = 0; private: - double hidpi_scale_factor = 0; + double hidpi_scale_factor; }; // a helper class to avoid forgetting StopModal() @@ -624,7 +625,7 @@ protected: bool pointer_blanked; uint32_t mouse_active_time; - DECLARE_DYNAMIC_CLASS() + DECLARE_DYNAMIC_CLASS(GameArea) DECLARE_EVENT_TABLE() }; @@ -667,7 +668,7 @@ protected: int width, height; double scale; virtual void DrawingPanelInit(); - bool did_init = false; + bool did_init; uint8_t* todraw; uint8_t *pixbuf1, *pixbuf2; FilterThread* threads; From f7186a649335e43c8fa23b97cc756788540cdee9 Mon Sep 17 00:00:00 2001 From: edorax Date: Sat, 11 Feb 2017 13:39:50 +0800 Subject: [PATCH 2/9] Move 'dependencies/msvc' inclusion to the CMakeLists.txt in top level. --- CMakeLists.txt | 9 +++++++++ src/wx/CMakeLists.txt | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7a195b5..eecaca7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -277,6 +277,15 @@ IF(WIN32) INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include") ENDIF() +IF(MSVC) + SET(DEPS_MSVC "${CMAKE_SOURCE_DIR}/dependencies/msvc") + IF(NOT EXISTS "${DEPS_MSVC}" AND EXISTS "${CMAKE_SOURCE_DIR}/.git") + MESSAGE(FATAL_ERROR "Please pull in git submodules, e.g.\nrun: git submodule update --init --recursive") + ENDIF() + + INCLUDE_DIRECTORIES("${DEPS_MSVC}") # for GL/glext.h +ENDIF(MSVC) + # Compiler flags IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index fb78fcf9..5099a66e 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -149,10 +149,6 @@ ENDIF(WIN32 AND ENABLE_DIRECTX) # contrib widgets include_directories(widgets) -IF(MSVC) - include_directories(../../dependencies/msvc) # for GL/glext.h -ENDIF(MSVC) - # for out-of-tree builds, grab includes from both target and source dirs include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) From 95e1a35d4c9d40754dd759162784505cbe947067 Mon Sep 17 00:00:00 2001 From: edorax Date: Sat, 11 Feb 2017 14:55:45 +0800 Subject: [PATCH 3/9] Use cl(the MS C/C++ compiler) instead of cc for MSVC build. --- src/wx/CMakeLists.txt | 8 +++++++- src/wx/bin2c.c | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index 5099a66e..52663515 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -203,8 +203,14 @@ IF(CMAKE_HOST_WIN32) SET(BIN2C ${BIN2C}.exe) ENDIF() +IF(MSVC) + SET(NATIVE_CC cl) +ELSE(MSVC) + SET(NATIVE_CC cc) +ENDIF(MSVC) + ADD_CUSTOM_COMMAND(OUTPUT ${BIN2C} - COMMAND cc ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c -o ${BIN2C} + COMMAND ${NATIVE_CC} ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c -o ${BIN2C} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c) ADD_CUSTOM_COMMAND(OUTPUT wxvbam.xrs WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} diff --git a/src/wx/bin2c.c b/src/wx/bin2c.c index de2c3918..5c29737d 100644 --- a/src/wx/bin2c.c +++ b/src/wx/bin2c.c @@ -34,7 +34,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#ifndef _MSC_VER #include +#endif #include #define BUF_SIZE 4096 From 2dc673c753e29432e97b74099d0b280a67ded357 Mon Sep 17 00:00:00 2001 From: edorax Date: Sat, 11 Feb 2017 15:48:19 +0800 Subject: [PATCH 4/9] Fix the options of cl. --- src/wx/CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index 52663515..216efa15 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -204,14 +204,15 @@ IF(CMAKE_HOST_WIN32) ENDIF() IF(MSVC) - SET(NATIVE_CC cl) + ADD_CUSTOM_COMMAND(OUTPUT ${BIN2C} + COMMAND cl ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c /link "/out:${BIN2C}" + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c) ELSE(MSVC) - SET(NATIVE_CC cc) + ADD_CUSTOM_COMMAND(OUTPUT ${BIN2C} + COMMAND cc ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c -o ${BIN2C} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c) ENDIF(MSVC) -ADD_CUSTOM_COMMAND(OUTPUT ${BIN2C} - COMMAND ${NATIVE_CC} ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c -o ${BIN2C} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c) ADD_CUSTOM_COMMAND(OUTPUT wxvbam.xrs WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND wxrc ${XRC_SOURCES} -o wxvbam.xrs From b4ba9d9d657a41e344534773577ac72febcb52e8 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Sat, 11 Feb 2017 05:33:10 -0800 Subject: [PATCH 5/9] set -std=gnu++11 globally for C++ only Add -std=gnu+11 to CMAKE_CXX_COMPILE_OBJECT in the main CMakeLists.txt to force the option for all C++ sources. The right way to do this is to use a generator expression with ADD_COMPILE_OPTIONS, but this is only available in cmake 3.3 and we must maintain 2.8.12 compatibility to support Ubuntu 14. This fixes the mac build (clang.) --- CMakeLists.txt | 9 +++++---- src/wx/CMakeLists.txt | 4 ---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eecaca7a..5e4df8af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,10 +330,6 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) ENDIF() ENDIF() - IF(CMAKE_COMPILER_IS_GNUCXX) - SET(MY_C_FLAGS ${MY_C_FLAGS} -std=gnu++11) - ENDIF() - IF(MINGW) SET(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++) ENDIF(MINGW) @@ -348,6 +344,11 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) ADD_COMPILE_OPTIONS(${C_COMPILE_FLAG}) ENDFOREACH() + # This one must be set for C++ only, and we can't use generator expressions + # in ADD_COMPILE_OPTIONS because that's a cmake 3.3 feature and we need + # 2.8.12 compat for Ubuntu 14. + SET(CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT} -std=gnu++11") + # make a string of compile options to add to link flags UNSET(C_COMPILE_FLAGS_STR) diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index 216efa15..f67cbec6 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_policy(SET CMP0043 NEW) # for wxWidgets -IF(CMAKE_COMPILER_IS_GNUCXX) - SET( CMAKE_CXX_FLAGS -std=gnu++11 ) -ENDIF(CMAKE_COMPILER_IS_GNUCXX) - # not yet implemented SET(CAIRO_DEFAULT OFF) From d6c1b53653c9633af0af406f83e7d490f2ce6758 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Sat, 11 Feb 2017 05:52:42 -0800 Subject: [PATCH 6/9] add one missed cmake windows quoting fix Also quote LOCALEDIR with as \\\""${LOCALEDIR}"\\\", just like the other defs are quoted. This fixes the build on msys2. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e4df8af..a5bf5f64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,7 +237,7 @@ ENDIF( NOT ENABLE_ASM_CORE ) if( ENABLE_NLS ) SET( LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale ) ADD_DEFINITIONS ( -DENABLE_NLS ) - ADD_DEFINITIONS ( -DLOCALEDIR=\\\"${LOCALEDIR}\\\" ) + ADD_DEFINITIONS ( -DLOCALEDIR=\\\""${LOCALEDIR}"\\\" ) # for now, only GBALink.cpp uses gettext() directly IF(APPLE) # use Homebrew gettext if available From c02c448f47812f581dafd5ed1d1ea950b2939310 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Sat, 11 Feb 2017 06:33:08 -0800 Subject: [PATCH 7/9] clean up dependencies/msvc inclusion cmake code Move the check for dependencies/msvc into the previous IF(WIN32) block adding an IF(MSVC) level. Remove duplicate call to INCLUDE_DIRECTORIES(dependencies/msvc) from later on in the main CMakeLists.txt. --- CMakeLists.txt | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5bf5f64..bb5b770b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,16 +275,12 @@ IF(WIN32) ENDIF() INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include") -ENDIF() -IF(MSVC) - SET(DEPS_MSVC "${CMAKE_SOURCE_DIR}/dependencies/msvc") - IF(NOT EXISTS "${DEPS_MSVC}" AND EXISTS "${CMAKE_SOURCE_DIR}/.git") - MESSAGE(FATAL_ERROR "Please pull in git submodules, e.g.\nrun: git submodule update --init --recursive") + IF(MSVC) + SET(DEPS_MSVC "${CMAKE_SOURCE_DIR}/dependencies/msvc") + INCLUDE_DIRECTORIES("${DEPS_MSVC}") # for GL/glext.h and getopt.h ENDIF() - - INCLUDE_DIRECTORIES("${DEPS_MSVC}") # for GL/glext.h -ENDIF(MSVC) +ENDIF() # Compiler flags @@ -635,12 +631,6 @@ IF( ENABLE_FFMPEG ) ) ENDIF( ENABLE_FFMPEG ) -if(MSVC) - INCLUDE_DIRECTORIES( - dependencies/msvc # for getopt.h - ) -endif() - ADD_LIBRARY ( vbamcore STATIC From fee89f1967ee0de4dbe158bef00246402947c22d Mon Sep 17 00:00:00 2001 From: edorax Date: Sat, 11 Feb 2017 23:11:32 +0800 Subject: [PATCH 8/9] Fix build for MSVC. --- src/wx/dsound.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wx/dsound.cpp b/src/wx/dsound.cpp index 0c11dceb..a6fb1831 100644 --- a/src/wx/dsound.cpp +++ b/src/wx/dsound.cpp @@ -192,7 +192,8 @@ bool DirectSound::init(long sampleRate) void DirectSound::pause() { - for (auto buf : {dsbPrimary, dsbSecondary}) { + LPDIRECTSOUNDBUFFER bufs[] = {dsbPrimary, dsbSecondary}; + for (auto buf : bufs) { if (buf == NULL) continue; @@ -216,7 +217,8 @@ void DirectSound::reset() void DirectSound::resume() { - for (auto buf : {dsbPrimary, dsbSecondary}) { + LPDIRECTSOUNDBUFFER bufs[] = {dsbPrimary, dsbSecondary}; + for (auto buf : bufs) { if (buf == NULL) return; From 0791236a8f72526af8834e50e19c3e22c67da640 Mon Sep 17 00:00:00 2001 From: edorax Date: Sat, 11 Feb 2017 23:48:11 +0800 Subject: [PATCH 9/9] Improve the method to find SDL2. --- CMakeScripts/FindSDL2.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeScripts/FindSDL2.cmake b/CMakeScripts/FindSDL2.cmake index 5a25af08..63da103d 100644 --- a/CMakeScripts/FindSDL2.cmake +++ b/CMakeScripts/FindSDL2.cmake @@ -89,7 +89,8 @@ SET(SDL2_SEARCH_PATHS /opt/local # MacPorts /opt/csw # OpenCSW (Solaris) /opt - ${SDL2_PATH} + ${SDL2_PATH}/include + ${SDL2_PATH}/lib ) FIND_PATH(SDL2_INCLUDE_DIR SDL.h