Commit Graph

163 Commits

Author SHA1 Message Date
Rafael Kitover 6af5525ac1 cmake: default to ENABLE_ASM_CORE=OFF #98 #54
The inline assembly in src/gba/GBA-thumb.cpp which is turned on with the
cmake ENABLE_ASM_CORES option, sometimes causes weird behavior on
windows (see: #54) and a crash on startup in linux (see: #98, confirmed
on both Fedora and Arch Linux.)

Previously the default for this option was ON for 32 bit builds, set the
default to OFF always for the time being, until it is either fixed or
replaced.
2017-03-18 19:04:39 -07:00
Rafael Kitover 2e8bee117d cmake: use add_compile_options for ssp-buffer-size
In 82c8a1e3 I made "--param ssp-buffer-size=4" one argument instead of
two because when added to CMAKE_REQUIRED_LIBRARIES the ssp-buffer-size=4
part was being recognized as a library, breaking the compile tests.

This broke the build on mac, which I fixed in 915e2d1e by using ssp
flags for gcc only and not clang.

Now apparently it is breaking mxe, so instead of adding this particular
parameter to the MY_C_FLAGS variable which is then added to
CMAKE_REQUIRED_* variables for compile tests, add it directly via
ADD_COMPILE_OPTIONS().

This should hopefully resolve any remaining issues with this compiler
flag.
2017-03-14 10:33:24 -07:00
Rafael Kitover 915e2d1ec2 activate libssp compiler flags for gcc only
In 82c8a1e3 I made "--param ssp-buffer-size=4" one argument instead of
two to fix another problem when passing compiler flags to
CMAKE_REQUIRED_LIBRARIES, clang cannot deal with this and this breaks
the build on mac.

Enable libssp related flags for gcc only, because clang does not support
them anyway. This fixes the build issue on mac.
2017-03-11 19:19:47 -08:00
Rafael Kitover 82c8a1e3fa fix linux build broken in 687c08a
Stop saving and restoring the CMAKE_REQUIRED_* variables for the compile
test, because the subsequent Wx header symbol tests need them set up for
Wx support as well.

Also --param foo=bar needs to be a single string in the list of compiler
flags, or cmake can misinterpret the second part as a library when it is
passed to libraries/link-options.
2017-03-10 06:38:50 -08:00
Rafael Kitover 7b0baadbaa fix 32bit intel detection for 32bit mxe target
mxe leaves CMAKE_SYSTEM_PROCESSOR empty, so detect if mxe is being used
and set the variable based on CMAKE_TOOLCHAIN_FILE, this allows the
32bit asm to compile under mxe.

Also if no toolchain file is being used and CMAKE_SYSTEM_PROCESSOR is
empty, fall back to CMAKE_HOST_SYSTEM_PROCESSOR.
2017-03-08 15:49:00 -08:00
Rafael Kitover 687c08a051 pass all compiler/linker flags for compile test
When determining gcc/clang flags, save resulting C flags as MY_C_FLAGS,
C++ flags as MY_CXX_FLAGS, and linker flags as MY_C_LINKER_FLAGS, then
use them in the Wx OpenGL compile test.

This fixes the test erroneously failing on git mxe on mac.

Also, don't use -fPIC on Win32, set Wx defines separately from the test,
and save all CMAKE_REQUIRED_* variables before the test and restore them
afterwards.
2017-03-07 16:15:02 -08:00
Rafael Kitover fef71439fc add ENABLE_ASM cmake option
Add the ENABLE_ASM flag for cmake which turns ON or OFF the
ENABLE_ASM_CORE, ENABLE_ASM_SCALERS and the ENABLE_MMX options at once.
2017-03-06 01:40:55 -08:00
Zach Bacon eb7dab6272 ws2_32 is needed for the SDL binary on windows 2017-03-05 20:06:22 -05:00
Rafael Kitover cf5f425b3a default to -DENABLE_FFMPEG=ON on Mac again
No particular reason to exclude ffmpeg support in Mac builds.
2017-02-24 06:44:26 -08:00
Rafael Kitover 99c6c4f938 Merge pull request #74 from Mystro256/gccwarnings
- fix C++ only flags being used for C

- check if cheats/patches files load correctly
2017-02-13 01:26:22 -08:00
Mystro256 611bbd6707 Re-add missing installed icons (for linux) 2017-02-12 06:50:54 -08:00
Rafael Kitover 289abcd7a2 use -fpermissive and -fexceptions with C++ only
Add -fpermissive and -fexceptions to CMAKE_CXX_COMPILE_OBJECT so that
they only affect C++. -std=gnu++11 was already there from b4ba9d9d, but
this is a cleaner method (which is also used for NASM) where we use
STRING(REGEX REPLACE ...) to append options after the <FLAGS>
placeholder in CMAKE_CXX_COMPILE_OBJECT.
2017-02-12 04:41:57 -08:00
Mystro256 28624ac01b fpermissive is only a C++ flag 2017-02-12 04:26:21 -08:00
Rafael Kitover 65dae0d0a1 support Ninja cmake generator on msys2
Add a hack to the root CMakeLists.txt to SET(MSYS ON) for the Ninja
generator when running under msys2, otherwise it cannot find libs.

The quoting fixes from #70 allow all of this to work.
2017-02-11 14:18:38 -08:00
Rafael Kitover c02c448f47 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.
2017-02-11 06:33:08 -08:00
Rafael Kitover d6c1b53653 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.
2017-02-11 05:52:42 -08:00
Rafael Kitover b4ba9d9d65 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.)
2017-02-11 05:33:10 -08:00
edorax f7186a6493 Move 'dependencies/msvc' inclusion to the CMakeLists.txt in top level. 2017-02-11 13:39:50 +08:00
Su Yong 4e096c127c Some fixes for MSVC. 2017-02-11 10:57:35 +08:00
Rafael Kitover fcc34394c1 fix build failure on OS X Lion with XCode 4.2
XCode 4.2 generates a broken binary if -fomit-frame-pointer and/or -flto
is used for compile and link flags.

Check for Clang version less than 4.3 on APPLE and remove these flags in
the compile options setting cmake code.
2017-02-03 12:39:10 -08:00
Rafael Kitover cb0bcfae6b fix msys2 build failure in 34e408cc
cmake automatically passes -std=gnu++11 in some cases, while we were
passing -std=c++11, and this was causing incompatibilites in name
mangling between different objects.

Fix this by using -std=gnu++11 for gcc.
2017-01-30 19:12:04 -08:00
Rafael Kitover f21178f6f7 fix nasm support broken in 34e408cc
The last commit removed generator expressions from ADD_COMPILE_OPTIONS()
which made C/C++ flags apply to nasm as well.

Fix this by removing <FLAGS> from CMAKE_ASM_NASM_COMPILE_OBJECT and
replacing it with the flags we want.
2017-01-30 18:14:33 -08:00
Rafael Kitover 34e408ccb7 fix Debian 8 Jessie and Ubuntu 14 Trusty compat
Fix some porting issues to make everything work on Debian 8 "Jessie"
and Ubuntu 14 "Trusty":

- set cmake minimum version to 2.8.12, this is the Ubuntu 14 version

- combine C and C++ flags and add all of them using
  ADD_COMPILE_OPTIONS() without using generator expressions, which is a
  cmake 3.2 or so feature

- add -fpermissive to force some non-const type casts to compile on
  older versions of gcc

- add -std=c++11 for gcc to enable support on older versions of gcc

- check that the compiler supports -fstack-protector-strong before
  adding it, older versions of gcc do not

- fix the debian section of ./installdeps to include libpng-dev instead
  of libpng16-dev and add gettext for msginit etc.

- fix compat checks in src/common/ffmpeg.cpp and src/wx/cmdevents.cpp to
  check for libavcodec >= 56 instead of > 56, the Debian Jessie version
  is exactly version 56 . With the one exception of
  AV_CODEC_FLAG_GLOBAL_HEADER which is defined in later versions.
2017-01-29 10:14:34 -08:00
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