Commit Graph

140 Commits

Author SHA1 Message Date
Rafael Kitover fdc389c280 fix wx 2.8 compat, debug logging works everywhere
Fix backcompat with wx 2.8. This involved writing
wxPositiveDoubleValidator and rewiring the DrawingPanel inheritance tree
and event handling mechanisms (because 2.8 does not have ->Bind, only
->Connect which is less flexible.) As a result all the event handling
has been gathered into GameArea and the affected code is somewhat
cleaner. 2.8 support is untested on Mac because it requires 32 bit libs
and Carbon.

Add support for cross-compiling for windows using the Fedora MinGW
packages in ./installdeps.

Check for OpenGL support in the wx library being linked, this was
necessary because the Fedora MinGW wx library does not have OpenGL
support.

Remove vbamDebug() in favor of wxLogDebug(), and add an override for it
so that it works in non-debug builds of wx as well as on Windows. Turn
off buffering on stdout and stderr on startup so that debug logging
works in msys2/cygwin mintty as well.

On Windows, build a console binary for debug builds.

Update README.md to reflect Fedora MinGW support and debug logging
support.

Add -Wextra to cflags for debug builds.
2017-01-25 10:53:05 -08:00
Rafael Kitover 82d694df3a disable LTO on Win32 for now
Due to reports of segfaults etc. disabling LTO on Win32 for now.
2016-12-31 04:48:51 -08:00
DoctorWho11 57adfaf24e Add missing libiconv for enabling nls 2016-12-30 22:48:23 -05:00
Rafael Kitover d06e7afceb full support for cross-compiling to win32 with mxe
Fix all cmake issues related to building for win32 with mxe.

Add support for ./installdeps win32 on Debian/Ubuntu using the mxe apt
repository.

Details:

* default to ENABLE_LTO=OFF on mxe

* set SFML_STATIC_LIBRARIES=TRUE on mxe

* fix the libintl/gettext checking logic

* fix the git dependencies submodule checking logic, and check that it
  triggers for mxe

* revert FindSFML.cmake to upstream version, works fine with mxe

* make 'win32' an alias for the 'MinGW-w64-i686' target for
  ./installdeps, add support for mxe apt repository for Debian/Ubuntu

* change bin2c related cmake code to compile the tool on the host always
  even when cross-compiling

* copy src/win32/res/VBA.ico to src/wx/icons since src/win32 has been
  removed

TODO: generic mxe installer for other unix-likes
2016-12-21 13:02:55 -08:00
DoctorWho11 978d5b7991 Missed one other cmake instance of gvbam 2016-12-20 21:26:11 -05:00
DoctorWho11 a1bf0f3f82 Drop gtk and mfc interfaces. Things are changing and for the better. 2016-12-20 17:34:34 -05:00
Rafael Kitover 7b1b1ea236 only use gcc binutils wrappers when LTO is enabled
Use gcc wrappers like gcc-ar/gcc-nm/gcc-ranlib only when LTO is enabled.
2016-12-14 05:48:37 -08:00
Rafael Kitover c216528793 generalize ./installdeps + mac pkg mgrs support
Add a more general purpose ./installdeps script to replace
./installdeps-msys2 that handles: Debian Linux, Arch Linux, MSYS2+MinGW,
Mac Homebrew, MacPorts and Fink for Mac. More OSes and distributions
will be added in the future, and the script may be generalized for use
in other projects.

Move Mac package manager setup code into MacPackageManagers.cmake and
greatly improve it. Handles Homebrew, MacPorts and Fink correctly.

Minor tweaks for FindSDL2.cmake: better include dir searching that works
on cygwin, fix flags for MinGW, and quiet pkg-config program errors.

Add MinGW cross-compilation toolchain files, they can be specified on
the cmake command line with:

-DCMAKE_TOOLCHAIN_FILE=../CMakeScripts/Toolchain-cross-MinGW-w64-i686.cmake

or

-DCMAKE_TOOLCHAIN_FILE=../CMakeScripts/Toolchain-cross-MinGW-w64-x86_64.cmake

these work for Cygwin and should work for MinGW on Linux as well.
2016-12-10 23:41:32 -08:00
Mystro256 8baa415848 Add linux appdata and fixes
Desktop files aren't installed for linux by default
2016-12-10 19:05:30 -05:00
Mystro256 d6228254cf cmake fixes
-Whitespace fixes
-Binaries installation fixes
2016-12-10 18:27:18 -05:00
Mystro256 24d2521914 Manpage fixes 2016-12-10 17:56:04 -05:00
Jeremy Newton c7386503c4 Fix DSYSCONF_INSTALL_DIR
I'm not sure if this was changed in cmake recently, but "SYSCONFDIR" is incorrect. It should be SYSCONF_INSTALL_DIR.

As well CMAKE_INSTALL_PREFIX refers to /usr or /usr/local in linux, so installing it into ${CMAKE_INSTALL_PREFIX}/${SYSCONFDIR} would be incorrect. I've wrapped it in the existing IF( WIN32 ) to preserve the installation for windows, a window dev should fix that if it's incorrect.
2016-12-09 12:44:11 -05:00
Rafael Kitover 37518fc88b add LTO option, disable on GCC+AMD64+Win32
Add ENABLE_LTO cmake option that defaults to ON except on GCC building
for AMD64 on Win32.

Also set the cmake variables AMD64 or X86_32 when one of these
architectures is detected.
2016-11-27 15:37:24 -08:00
Rafael Kitover b468eddfa5 only use -flto=10 with gcc
gcc allows flto=<jobs> to parallelize linking, clang does not understand
this, use just -flto for clang and -flto=10 for gcc.
2016-11-23 03:13:33 -08:00
Rafael Kitover cdae078e42 pass all compile flags to link step
This makes -static-libgcc -static-libstdc++ actually work, and is
probably better for LTO as well.
2016-11-21 13:53:16 -08:00
Rafael Kitover 349bbd13bc add LTO support, fix libssp link, add -ggdb3 -Og
Add support for Link Time Optimization (LTO) on gcc and Clang.

Link libssp only when it is on the system, some toolchains like Ubuntu's
do not require explicitly linking to libssp. On Win32 try to link it
statically.

In debug builds with GCC, use -ggdb3 -Og, otherwise use -g .

Two new cmake modules were written for this:

* FindSSP.cmake -- this is for finding libssp on the system.

* UseGCCBinUtilsWrappers.cmake -- this is for using gcc binutils
wrappers such as gcc-ar, which is required for gcc LTO to work.

These will be distributed separately as well.
2016-11-21 12:37:21 -08:00
Rafael Kitover 55f6e17f0d compile/link flags improvements
* Bump minimum cmake required to 3.3.2, to make sure generator
  expressions work.

* Force CMAKE_BUILD_TYPE to "Release" if unset, not sure if this
  actually works.

* Merge the older compile flags block with the new one and use generator
  expressions to make sure the relevant flags apply only to C, C++ or
  nasm.

* Add -lssp to the end of the link commands for the -fstack-protector*
  options, this is only needed/done for gcc.

* Add -lversion and -limm32 to SDL2_LIBRARY (Zach asked for this.)

* Builds on msys2 again!
2016-11-20 11:11:52 -08:00
Rafael Kitover 1dd7ecfe0f set Zach's CXXFLAGS only on gcc/clang
Set the flags Zach gave me only when cmake detects gcc or clang, this
way other generators like Visual Studio will still work fine.
2016-11-20 06:15:27 -08:00
Rafael Kitover bbdc6ca577 make ENABLE_SDL default to OFF
Default building options now just build the Wx port.

Also set +x on ./installdeps-msys2 .
2016-11-20 05:46:24 -08:00
Rafael Kitover 180ee60c7a clean up APPLE block in main CMakeLists.txt
Remove some redundant nasm-related code and an outdated comment.

Objective-C++ code is now separated into an .mm file and nothing is done
to change the compiler invocation for it.
2016-11-19 17:13:49 -08:00
Rafael Kitover 40dcb2df7a add some compiler flags
These are the flags Zach wanted.

They work fine with gcc and clang, will test what happens with msvc as
well.
2016-11-19 17:07:30 -08:00
Rafael Kitover 902a7a7e0d fix 32bit build support
Make ASM_CORE, ASM_SCALERS and ENABLE_MMX the defaults for 32bit builds
on intel hosts (the host can be AMD64, as long as the target is 32bits.)

Move mac nasm search into the mac section of the cmake code and stop
defaulting to /usr/bin/nasm, this was screwing up the build on msys2.

Fix src/filters/2xSaImmx.asm to compile and link correctly.

Add nasm to list of mingw deps for ./installdeps-msys2 .

Tested that msys2-built Wx binary runs, including with 2xSaI.

Keyboard doesn't work yet on msys2 builds, but that's a completely
different issue.
2016-11-18 09:04:55 -08:00
Rafael Kitover 3c30d59aba msys2 build improvements
* Enable ffmpeg by default only on linux and msys2, it will be disabled
for normal windows builds and on mac.

* Set SFML_STATIC_LIBRARIES only for normal non-msys2 windows builds,
because msys2 does not currently have static versions of the SFML
sub-libraries, e.g. system, network, etc.. Dynamic linking works fine
for now.

* Fix quoting for -DLOCALEDIR, on windows spaces were causing errors in
make on msys2.

* Update to upstream FindSFML.cmake .

* Add an ./installdeps-msys2 script to install all necessary tools and
libraries on msys2 for building both 64 and 32 bit windows Wx binaries.

* Add the dependencies/mingw-xaudio/include directory to
INCLUDE_DIRECTORIES so that XAudio compiles on msys2, as mingw-w64 does
not currently have XAudio headers. Also check that the user pulled the
git submodule in the process (the ./installdeps-msys2 script does this
for you.)

TODO:

* Generalize ./installdeps to work on more platforms.

* Make console Wx app in debug mode so that debug prints will work.

* Fix game keyboard input for msys2 builds.

* Add HiDPI support for Windows.

* Fix the -D*DIR defines to have the correct paths on windows.
2016-11-14 10:56:50 -08:00
Adam Sampson 4bf4248985 SFML is required for link support. 2016-11-10 11:39:45 +00:00
Rafael Kitover 30f80ab22b fix wx GL viewport + build improvements
Add GetRealPixelClientSize() method to HiDPIAware and implement using
wx GetClientSize() in panel.cpp for the generic version, and using
convertSizeToBacking: in macsupport.mm .

Add an AdjustViewport() method to GLDrawingPanel that sets glViewport()
using GetRealPixelClientSize(), and call it for the SIZE event. Debug
print the viewport size here instead of in DrawingPanelInit().

Build improvements:

* default to Cairo off for all platforms, currently libcairo2-dev does
  not install on Ubuntu

* default to ON for ENABLE_LINK and ENABLE_FFMPEG (for game recording),
  this will allow for more fully-featured default builds

* do not set SFML_STATIC_LIBRARIES on Mac because this is currently
  broken

* fix the Mac bundling/linking script to deal with links in dependent
  libs that already use @rpath (very minor change.)
2016-11-08 04:51:26 -08:00
Rafael Kitover 981026dc80 fix Xcode project generation via cmake
Move Objective-C++ Mac code for Wx into macsupport.mm with stub methods
in panel.cpp, and stop compiling all C++ as Objective-C++.

cmake -G Xcode # now works fine
2016-11-06 14:09:50 -08:00
Rafael Kitover 2d9ec99c11 Mac build improvements
Move closer to allowing an "out of the box" distributable build for Mac:

* fix the icon for the .app

* link SDL2 statically, a PR has been sent to the original repo here:
  https://github.com/tcbrindle/sdl2-cmake-scripts/pull/9

* link SFML statically

TODO:

For a releasable build on OS X, system libs must be linked
dynamically while third party libs are linked statically or bundled. The
goal is to link them statically.

The two remaining libs that need static linking are PNG and wX.

For PNG a similar approach to the one used for SDL2 using pkg-config
should work fine and be simple to implement.

For wX things are more complicated. The default build of wX does not
include static libs, I will need to submit a PR for Homebrew to change
the default build to include both dynamic and static versions.
2016-10-26 16:58:21 -07:00
Rafael Kitover 2b45cc7662 fix typo in CMakeLists.txt from 7a7a72f
Fix typo in the default cpp flag when CMAKE_BUILD_TYPE is "Release"
from `-NDEBUG` to `-DNDEBUG`.
2016-10-24 13:12:40 -07:00
Rafael Kitover 7a7a72f2bd Mac OS X HiDPI fixes + other misc
Use a high-res surface on HiDPI (e.g. retina) Macs for the OpenGL
renderer, and scale window accordingly. Also fix fullscreen toggle not
working in HiDPI mode. And some other stuff.

Aside from the .app not being linked statically, the app is now fully
functional on Mac and ready to ship.

Full change details:

* add -DDEBUG or -DNDEBUG based on CMAKE_BUILD_TYPE (-DNDEBUG for
  Release and -DDEBUG for Debug)

* properly search for homebrew/macports/fink directories, and only add
  them if they exist

* fix building with wx debug support, when available

* use explicit OpenGL context on Mac too for new versions of wx

* add main_frame pointer in GameArea back to MainFrame, and a
  SetMainFrame(MainFrame* parent) public method to set it in guinit

* add full support for reading and writing double value config options
  (the GUI still needs to be updated for options that can take doubles,
  such as video_scale)

* change video_scale option (Display/Scale) to a double, putting a
  double value such as 3.6 in the config file works correctly

* add a HiDPIAware mixin class for GameArea and DrawingPanel, with the
  method HiDPIScaleFactor which returns the current window's
  backingScaleFactor

* change the GameArea sizing methods (DelBorder(), AdjustMinSize() and
  AdjustSize()) to divide the window size by the
  HiDPIAware::HiDPIScaleFactor so that the window is scaled properly

* change GameArea::ShowFullScreen to ignore fullscreen events for a
  maximized window on Mac, because maximized windows on OS X are
  actually native fullscreen windows

* change scale variables to double from int, and use std::ceil() to
  round scaled pixel or memory size values

* make a default base class DrawingPane::DrawingPanelInit() virtual
  method, call by all concrete class constructors based on the did_init
  flag

* call setWantsBestResolutionOpenGLSurface:YES on the view backing the
  wxGLCanvas for the OpenGL renderer (GLDrawingPanel) to get a high res
  OpenGL surface in HiDPI mode

* remove GLDrawingPanel::OnSize event, the OpenGL viewport resizes
  automatically without the need to call glViewport()

* do not hide the mouse pointer if the main frame has menus or dialogs
  open

* add variadic vbamDebug(const char* format, ...) function, active only
  #ifdef DEBUG, which sets the wx log target to STDERR and logs a
  message to it

* use full name of app "visualboyadvance-m" instead of "vbam" when
  getting configuration paths, this way the config is saved to
  ~/Library/Application Support/visualboyadvance-m rather than
  ~/Library/Application Support/vbam

* listen to the MENU_HIGHLIGHT_ALL event as well, as an extra way to
  check when the menus are open

* add public MainFrame::SetMenusOpened(bool state) method to force the
  main frame to change the internal menus_opened state, this is
  necessary because in HiDPI mode on Mac the keyboard accelerator for
  toggle fullscreen sends a menu open event, but not a menu close event,
  so on switch to fullscreen the state is changed to menus closed and
  the emu is unpaused

TODO:

* GUI option to change toggle fullscreen behavior between native and
  non-native fullscreen on Mac

* GUI support for double config values like Display/Scale

* add HiDPI support to simple renderer

* fix SDL sound, or disable the option

* fix Cairo suport on Mac, or disable the option

* use dynamic_cast<> to implement GetWindow() for DrawingPanel instead
  of pure virtual method, likewise for Delete()

* link .app statically by default so it can be shipped

* add Homebrew formula
2016-10-22 05:47:27 -07:00
EoD a513d3191e Add C++11 in cmake as default
Currently, the build is broken on Linux as fixed width integers (for
example uint32) are used via <cstdint> without a namespace. This is only
allowed in C++11 and later.

See http://en.cppreference.com/w/cpp/types/integer for details.
2016-07-31 01:03:40 +02:00
Dorian Wouters 31391e090c
Kill common/Types.h, replace its old typedefs w/ standard types
Fix includes in files using standard int types
Fix wxWidgets UI includes
Silence some unused variable warnings in GBA-arm.cpp macros
2016-07-29 11:07:11 +02:00
Markus Kitsinger (SwooshyCueb) 57c619ca13 Add some header and resource files to CMakeLists.txts (Core+WX)
This makes these files show up in generated CodeBlocks projects, which
makes life easier for folks who import into QtCreator.
2016-06-07 15:26:53 -05:00
Zach Bacon c8343267fc <wip> Migration to SDL2 made possible by galtgendo, gtk changes to follow. 2015-11-18 21:34:38 -05:00
Rafael Kitover 3d679c1469 more minor improvements for OS X build
Add Homebrew and MacPorts paths for findings headers and libraries.

Add -x objective-c++ to the C++ compile command so that conditionally
compiled ObjectiveC code for OS X can be supported.

Throw a fatal error if the user tries to enable ENABLE_ASM_CORE,
ENABLE_ASM_SCALERS or ENABLE_MMX on AMD64, as this is not supported yet.

If ENABLE_ASM_SCALERS is enabled, try to find a Homebrew or MacPorts
nasm before using the outdated XCode nasm.

For the future, if the user has only the old XCode nasm which does not
support 64 bit objects and the build is 64 bit, throw a fatal error.

For 32 bit builds with the old XCode nasm, use -f macho instead of -f
macho32, which is used if the version of nasm is > 2.0 .

Pass -DMACHO instead of -DELF and, on AMD64 (for the future) -D__AMD64__
for nasm on OS X.

Pass -D__AMD64__ to C++ compilation as well on AMD64, this will help
when we support AMD64 inline assembly.

Add support for automatically linking Homebrew keg-only gettext from
/usr/local/opt/gettext for ENABLE_NLS.

Fix copying Info.plist and vbam.icns to the .app bundle.

Add a key to the Info.plist to support sharp text on retina displays, as
per:
https://wiki.wxwidgets.org/WxMac-specific_topics#Retina_display_support

Set wxWidgets_USE_DEBUG to ON if CMAKE_BUILD_TYPE is "Debug". I'm not
sure this does anything or if I'm doing this correctly though.

Also set wxWidgets_USE_UNICODE to ON. Again, I'm not sure this does
anything or is in the right place.

Fix a bug in the config dir finding code in
wxvbamApp::GetConfigurationPath() updated in 8b8f2f7 to only use the
more top level dirs if there is a vbam.ini in them, not if they are
writable as well, and use the reverse order (starting with user local
dirs) to check for writable dirs and their writable parents. This fixes
a problem with the vbam.ini being written to the Plugins directory of
the .app bundle if it's writable instead of ~/Library/Application
Support/vbam as was intended.
2015-11-16 21:56:23 -05:00
DoctorWho11 1e1b1cc35c This should fix the issue of when users on linux run the install command and make not finding the proper binary. 2015-09-29 23:49:15 -04:00
skidau 023d28a9cc OSX build fix by Juha Laukkanen. This one works with wxWidgets 3.0 and Cairo 1.14.2. 2015-07-11 10:34:27 +10:00
DoctorWho11 3389ba5cd6 make cpack ignore the dep folder 2015-06-15 09:20:20 -04:00
DoctorWho11 65f7546798 rename exe and added more cpack stuff. 2015-06-15 09:00:47 -04:00
DoctorWho11 f5600cef71 setting the exe name and git hash 2015-06-15 08:21:44 -04:00
DoctorWho11 2717803745 added git support to cmakelists.txt 2015-06-12 08:04:26 -04:00
DoctorWho11 0064fe114f will need to start changing the version for git 2015-06-12 07:51:15 -04:00
DoctorWho11 f5c1dec56c pathing issues 2015-06-11 22:14:33 -04:00
wowzaman12 5a6ed061a4 removed the cmake toolchain file, modified the cmakelists files to include an additional library to properly link with sfml and for linking statically with libgcc and stdc++ libs via mingw 2015-05-28 15:12:31 +00:00
wowzaman12 09e485dcad some changes regarding static building via mingw 2015-05-21 18:42:02 +00:00
wowzaman12 ac3abd7bb3 so that xaudio2 can be enabled 2015-05-18 03:05:58 +00:00
wowzaman12 f8ccda09ac try and get mingw to force static gcc and libc++ 2015-05-18 03:04:34 +00:00
wowzaman12 62ce4aa50a You didn't see us change the version to 2.0.0 *waves hands mysteriously* 2015-05-18 02:41:21 +00:00
skidau 6605d4eb6d Installed man pages on unix-ish platforms. Patch by Mook. 2015-05-18 00:28:34 +00:00
wowzaman12 96788892c4 Fixed cmake to use find the proper xpm file in the xrc folder, also made the vbam core and fex library static to help with building on some platforms. 2015-05-10 22:54:19 +00:00
skidau df42b279ed Removed an extraneous include and added a SDL build check in the CMakeLists.txt 2015-05-09 14:09:29 +00:00