Commit Graph

83 Commits

Author SHA1 Message Date
Rafael Kitover 6307348cbc build: support MSVC arm64 cross build on x86
Adjust cmake code to support building a Windows arm64 binary on a
Windows x86/x64 host.

Add /EHsc to MSVC compiler flags for exception unwind support.

Check VCPKG_TARGET_TRIPLET in Architecture.cmake to set the appropriate
cmake variables for cross-compiling for arm64.

Add MSVC_x86_Host_Compile.cmake script, used from HostCompile.cmake, to
adjust the path of the cl.exe compiler and ENV{LIB} to build a C program
for x86 when cross-compiling, necessary for the bin2c utility.

Use wxrc from dependencies submodule when cross-compiling, because the
cross wxrc executable cannot be run on the host.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-12-29 20:29:53 -08:00
Fabrice de Gans 3c41b68d51 Fix the Windows ARM64 build
* Remove arch constraints in a CMake block.
* Convert some tab identation to spaces.
2022-12-27 21:59:33 +00:00
Rafael Kitover a42e166e94
build: fix syntax and rm dbg prints from 2a65e92d
Remove two debug messages and add a missing paren to the cmake source.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-11-28 18:34:48 +00:00
Rafael Kitover 2a65e92da2
build: remove StrawberryPerl from ENV{PATH}
On Windows, StrawberryPerl tools and libraries exposed in the PATH
environment variable can pollute and break the build, remove any such
entries for WIN32 as a startup cmake action.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-11-28 10:27:06 -08:00
Rafael Kitover 6d8ca723d0
build: restrict MSVC static libs to .lib only
The MSVC linker can now apparently link MinGW .a static libs too, and
StrawberryPerl pollutes the build with its own.

Set CMAKE_FIND_LIBRARY_SUFFIXES to .lib only when MSVC is true for
static builds.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-11-28 10:23:33 -08:00
Rafael Kitover 5807376fba
build: fix finding SDL2 on vcpkg (again)
Sometimes vcpkg calls the SDL2 library SDL2-static for static toolchains
and sometimes it doesn't, change FindSDL2.cmake to search some possible
library names in order of priority.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-11-27 19:34:29 +00:00
Fabrice de Gans 0483524870 [build] Add VS Code integration
* Infer the VCPKG triplet for MSVC-like environments.
* Add recommended VS Code settings.
* Add instructions for using clangd.
2022-11-12 13:26:23 +00:00
Rafael Kitover 61b503ada4 builder: update core dists and macOS build
cmake:

Add cmake option `DISABLE_MACOS_PACKAGE_MANAGERS` to disable
automatically using macOS Homebrew, MacPorts or Fink.

Use `-Ofast` instead of `-O2` for default compiler optimization flags,
which enables `-ffast-math` among a few other tweaks. There is a lot of
controversy about this, but in our testing on MSVC with `/fp:fast` the
performance increase for this specific app is dramatic.

Update version regexps on the SFML headers in `FindSFML.cmake` to allow
for a variable number of spaces between the macro and its definition.

Update the version of the Sparkle update checker framework for macOS
from 1.23.0 to 2.3.0-beta.2, and add a command to the cmake commands for
copying the framework to the `.app` to delete it first if already
copied.

Builder dist changes:

Updates:

dist                    old v                   new v
==============================================================
xz                      5.2.4                   5.2.6
openssl                 1.1.1f                  1.1.1g
curl                    7.65.3                  7.85.0
ccache                  3.4.3                   4.6.3
cmake                   3.19.4                  3.24.1
autoconf                2.69                    2.71
autoconf-archive        2017.09.28              2022.09.03
libtool                 2.4.6                   2.4.7
help2man                1.47.5                  1.49.2
libiconv                1.16                    1.17
gsed                    4.4                     4.8
bison                   3.0.5                   3.8.2
texinfo                 6.5                     6.8
flex                    e7d45afc                ea6493d9
libicu                  65_1                    71_1
nasm                    2.14.02                 2.15.05
pcre                    8.41                    8.45
libffi                  3.2.1                   3.4.2
libxml2                 2.9.12                  2.10.2
libxslt                 1.1.33-rc2              1.1.37
XML-SAX                 0.99                    1.02
expat                   2.2.4                   2.4.8
libjpeg-turbo           2.0.4                   2.1.4
libtiff                 4.1.0                   4.4.0
freetype                2.10.0                  2.12.1
libgd                   2.2.5                   2.3.3
liberation              2.0.1                   2.1.5
urw                     91edd6ec                20200910
graphviz                4bf0ec9b                5.0.1
python2                 2.7.15                  2.7.18
python3                 3.9.1                   3.10.6
swig                    3.0.12                  4.0.2
doxygen                 1.8.14                  1.9.5
bakefile                33c270a5                7a218d89
XML-Parser              2.44                    2.46
ninja                   1.9.0                   1.11.1
meson                   0.51.2                  0.63.2
glib                    2.62.2                  51251940
libgpg-error            1.41                    1.45
libgcrypt               1.8.5                   1.10.1
libsecret               0.19.1                  0.20.5
sdl2                    2.0.10                  2.24.0
flac                    1.3.3                   1.3.4
libogg                  1.3.4                   1.3.5
libvorbis               1.3.6                   1.3.7
harfbuzz                1.7.5                   5.1.0
sfml                    03375688                2.5.1
shared-mime-info        1.9                     2.2
wxwidgets               9cc0c9a0                31720e1e
graphite2               ce0e793f                425da3d0
xvidcore                1.3.5                   1.3.7
fribidi                 1.0.1                   1.0.12
libgsm                  1.0.18                  1.0.22
libmodplug              5a39f591                d1b97ed0
libopencore-amrnb       0.1.5                   0.1.6
snappy                  1.1.7                   af720f9a
speex                   1.2.0                   1.2.1
vidstab                 1.1.0                   90c76aca
libvo-amrwbenc          0.1.3                   3b3fcd0d
libass                  0.14.0                  0.16.0
libbluray               1.1.2                   1.3.2
libvpx                  1.8.1                   1.12.0
libx264                 20190913-2245           f7074e12
libxavs                 distrotech-xavs-git     8300fbf4
libzmq                  4.2.2                   4.3.4
ffmpeg                  4.3.1                   5.1.1

Removed dists:

dist            ver
=========================
zlib            1.2.11
pkgconfig       0.29.2
docbook5.0      5.0
libwavpack      5.1.0

Added dists:

dist            ver
========================
zlib-ng         ce01b1e4
zstd            1.5.2
hiredis         1.0.2
pkgconf         1.9.3
pcre2           10.40
docbook5.0.1    5.0.1
docbook5.1      5.1

Changes:

Update all non-working dist URLs.

Replace zlib 1.2.11 with a recent zlib-ng built with `--zlib-compat`.

Add zstd and hiredis, new deps of ccache.

Replace pkgconfig with pkgconf.

Use both pcre1 and pcre2.

Remove the libxml2-python dist alias and rebuild libxml2 `--with-python`
and `--with-python3` after python 2 and 3 have built.

Remove libwavpack as ffmpeg 5 no longer uses it as a dependency.

Builder core:

Rename some of the directories and files to be a bit nicer.

Add `-Ofast -march=core2 -mtune=generic -pipe` to the global
`{C,CXX,OBJC,LD}FLAGS`. These are the optimization settings used by
default in the project as well, while `-pipe` significantly reduces
build time by making the compiler use pipes internally.

Add `-DFLOAT_APPROX` to the global `{CPP,C,CXX,OBJC}FLAGS` because we
are now using `-Ofast` and consequently, `-ffast-math`.

Set the `LIBRARY_PATH` variable in the global environment.

Make some adjustments for the new dist versions and make some other
improvements.

macOS builder fixes (tested on High Sierra 10.13 and Catalina 10.15):

Add support for predefined BUILD_ROOT and append BUILD_ROOT_SUFFIX.

Allow pre-defined CHECKOUT directory for building the project sources.

Sanitize `PATH` before build to remove `/usr/local` etc., use
/usr/local/bin/brew explicitly for deps instead.

If llvm and clang is installed from nix or brew, prepend the path of the
highest version found to `PATH`.

Remove `-lm` from build environment as macOS has never had an `m` math
library and this causes problems in some config checks.

Add LLVM `libunwind` from the LLVM archive.

Add a patch for `glib`'s `meson.build` to statically link
`gettext`/`libintl`, adds `-liconv -framework CoreFoundation`.

Add an extra location to check for `stdint.h` in XCode.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-11-12 13:23:54 +00:00
Fabrice de Gans 95337da558 [build] Add basic clang-cl support
XAudio2 is disabled because the included header needs to be updated to
be parseable by clang.
2022-10-15 22:25:34 +00:00
Rafael Kitover 8f27869715
build: fix finding static vcpkg SDL2
The static lib is now called `SDL2-static.lib` and the debug version is
called `SDL2-staticd.lib`.

Adjust our `cmake/FindSDL2.cmake` for the new vcpkg naming convention.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-10-09 04:00:26 +00:00
Rafael Kitover 796dfe78f9
Fix Wx OpenGL and ABI checks for MSYS2 CLANG64.
Probably fixes this in other environments as well, or breaks it.

Move the wxWidgets_LIBRARIES paths conversion to the already existing
normalize_wx_paths() function that was using a different method that no
longer works. This converts the variable to the right format before the
tests run, fixing the Wx OpenGL test.

For the ABI checks, wrap the function pointers for the minhook
trampoline API in reinterpret_cast<LPVOID>(&fp), why this is necessary I
don't know, and it may break on other compilers. The trampoline is used
to catch message boxes opened by Wx for fatal errors.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-02-05 01:00:25 +00:00
Rafael Kitover 87e41300f1
Speedup wx-config search on MSYS2.
Search for wx-config-static for static builds first, and wx-config
otherwise, before trying any config and version suffixes.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-02-04 04:45:07 +00:00
Rafael Kitover 4af78f6482
Fix MSVC VCPKG build and Debug build type checks.
Use jpeg.lib instead of jpegd.lib for jpeg debug lib, it no longer has
the "d" suffix.

Fix all CMAKE_BUILD_TYPE checks for debug builds to either also check
for RelWithDebInfo or match "Debug" exactly.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-02-03 00:18:08 +00:00
Rafael Kitover 7d454e054a
Fix MSVC compiler/linker flags.
Turn off ccache for vcpkg builds (this is only relevant to MSVC, where
ccache does not work yet.)

Throw an error if CMAKE_BUILD_TYPE is not valid or does not match case
exactly (to make comparisons simple.)

Add SetCompilerLinkerFlags.cmake lib with the functions:

add_compiler_flags()

For each flag passed in, add it to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS if
not already present. Also clears all build-specific flag variables on
every call, if using this functions you must set build-specific flags
yourself.

add_linker_flags()

For each flag passed in, add it to
CMAKE_(EXE|SHARED|MODULE|STATIC)_LINKER_FLAGS if not already present.

Add remove_dupes() function to VbamFunctions.cmake from:

https://stackoverflow.com/a/41416298/262458

This is used to remove duplicate flags in SetCompilerLinkerFlags.cmake
described above.

Use the new functions to set compiler and linker flags for MSVC.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-02-02 22:27:39 +00:00
Rafael Kitover fa56242669
Add MSYS2 CLANG64/32 support.
Update installdeps to support CLANG64/CLANG32 MSYS2 targets.

cmake:

Set POLICY CMP0060 to NEW to not convert full lib paths, this is the
default.
Stop disabling ffmpeg on WIN32+i686.
On MSYS2+clang add windows import libs to CMAKE_PREFIX_PATH.
For static builds on MSYS2 append full paths for static libs for tiff,
jbig and lzma to FFMPEG_LIBRARIES.
Add -Wno-unused-command-line-argument to all CFLAGS/CXXFLAGS so that
clang does not warn about gcc-specific options.
Enable -march/-mtune optimizations by default instead of only for
UPSTREAM_RELEASE.
Update find_wx_util() to search suffixes for WIN32 and add the "static"
suffix for static builds.
Remove all linker flags from wxWidgets_LIBRARIES and translate all wx*
libs as well as jpeg, tiff, jbig lzma and expat to full .a paths for
static builds.
Disable strutil tests on MSYS2+clang, currently does not build.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-01-31 03:26:52 +00:00
Rafael Kitover 414cacbf28
Suffix zip files with arch + minor cmake fixes.
Instead of suffixing release zip files with 32bit or 64bit, add an
architecture suffix, which would be one of:

x86_32
x86_64
arm32
arm64

Allow codesign to fail on mac without aborting.

Disable the interactive pause for gpg signing because there is no
passphrase anymore.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2021-10-31 08:55:48 -07:00
Rafael Kitover c9595c3668
Fix checking for `wx-config` first on Gentoo.
Followup on 98b2fb6e.

To make a one element of empty string list in cmake, you have to set the
variable to `";"`.

If it is set to `""`, a subsequent `list(APPEND ...)` will consider the
variable unset.

With this fix, `/usr/bin/wx-config` is tried first on Gentoo, as was
intended in 98b2fb6e.

The rationale for this is that on Gentoo, app-eselect/eselect-wxwidgets
links `/usr/bin/wx-config` to the user's preferred version of wxWidgets,
while on other distributions such as Arch, we want to check for the 3.x
gtk3 variant explicitly first.

Also add a modeline to `VbamFunctions.cmake`.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-12-05 11:37:40 +00:00
Rafael Kitover 98b2fb6ebb
Fix finding wxWidgets on Gentoo.
Prefer the `wx-config` from PATH on Gentoo, because that points to the
eselected wxWidgets build.

This is already done for Win32 builds.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-09-24 01:33:45 +00:00
Rafael Kitover a305f550e1
Replace Catch2 with doctest for unit tests.
Pretty much the same usage and functionality.

Add `tests.hpp` to configure doctest.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-28 05:14:22 +00:00
Rafael Kitover 22a3524c66
Fix linking on Msys2.
Do not link `SDL2main` on any WIN32, not just MSVC.

Define `WIN32_CONSOLE_APP` for Debug mode builds on any WIN32, not just
MSVC.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-28 05:09:58 +00:00
Rafael Kitover 5081ae44e5
Vcpkg fixes.
Fix vcpkg upgrades to work with the current vcpkg master.

When upgrading zlib, remove all optional deps first, because everything
depends on zlib and this can overrun the appveyor 1hr time limit.

Make SFML an optional dep too, like ffmpeg.

Reduce the vcpkg install time limit to 20 minutes, otherwise it may try
to build wxWidgets and ffmpeg and overrun the 1hr time limit.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-26 10:07:04 +00:00
Rafael Kitover f07a838883
Another hack to work-around broken vcpkg upgrades.
Add a function to check if libogg is installed but libvorbis isn't, this
means it failed to upgrade libvorbis because libogg wasn't upgraded to
the newest port revision supporting pkg-config, see:

https://github.com/microsoft/vcpkg/issues/13037

In this case, remove libogg recursively and allow the install action to
reinstall SFML and all deps.

This will also fix building link support on appveyor for the time being.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-22 21:31:12 +00:00
Rafael Kitover dcaa18aae4
Fix optional deps in vcpkg script.
Before installing optional deps, check that the associated variable is
either unset or true.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-19 09:59:29 +00:00
Rafael Kitover 375daf99cb
Only build ffmpeg with vcpkg if installs < 30m.
Fix the problem with vcpkg installs including both wxWidgets and ffmpeg
overrunning the one hour time limit, by making ffmpeg optional and only
building it if the other builds are under 30 minutes.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-17 18:38:58 +00:00
Rafael Kitover b23d463652
Use vcpkg installed wxrc, support mingw triplet.
Use the vcpkg installed wxrc, from a tools subdirectory, instead of
copying it out of the build tree.

Except when running on appveyor, for some reason the vcpkg wxrc does not
work there, so use our own from the dependencies submodule.

Support vcpkg mingw triplets, they don't work yet however.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-08-14 13:16:37 +00:00
Rafael Kitover 9495dc84f8
Prefer upgrading zlib before other vcpkg deps.
Just a hack to fix a problem with vcpkg upgrades, in this case the
version of the zlib port being too old breaks another upgrade, so we
will check if zlib is in the list of packages to upgrade and upgrade it
before anything else.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-07-31 09:32:42 +00:00
Rafael Kitover 81c88227fa Add Catch2 unit testing framework + some tests.
Add the Catch2 headers to third_party/include/catch2.

Add Catch.cmake and CatchAddTests.cmake to cmake/.

Add unit tests src/wx/tests/strutils.cpp using Catch2 to test
src/wx/strutils.cpp.

Make some code changes to strutils.cpp to make the tests pass.

See src/wx/tests/CMakeLists.txt for how to set up unit test files; they
plug into the normal CTest mechanism in cmake.

The test binaries are written to the tests/ subdirectory of the build
directory.

Building the tests and enabling the CTest support can be turned off by
passing -DBUILD_TESTING=OFF to cmake, the default is ON, this is the
standard mechanism.

Start running ctest on travis and appveyor.

Move stb to third_party/include where Catch2 is now as well.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-07-10 13:43:48 +00:00
Edênis Freindorfer Azevedo 07064c8714
[Windows,MacOS] Auto-updater refactoring. (#639)
Create and enable auto-updater for MacOS using `Sparkle=1.23`. We need
to sign our app using an `Apple Developer Key` for it to work properly,
since we are not going to sign updates with the Sparkle key.

Add all auto-updater files to `gettext`'s pot.

Use `str_split` to always get related stable version. We do not want
to check for nightly builds.

For Windows, we create the flag `-DHTTPS` to select between using an
HTTPS or HTTP URL for the auto-updater checks. We use this to keep
support for Windows XP (HTTP only) while all others should be HTTPS.

Also, use `::FreeLibrary` to allow us to remove the temporary file
that stores the `WinSparkle.dll`. Previously, we could not get it to
work with `wine`.
2020-05-07 23:06:00 -03:00
Rafael Kitover 8024c87832
Fix vcpkg upgrades.
We upgrade only the first listed package to upgrade for vcpkg to not
overrun the CI time limit.

Sometimes these packages are up-to-date but are listed for rebuild due
to depending on other packages that would be upgraded.

Find the first package in the upgrade list that is not up-to-date and
use that as the package to upgrade.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-05-07 01:11:18 +00:00
Rafael Kitover 229bf815e0
Revert f1abbc5f, vcpkg upgrade is fixed.
vcpkg upgrade is fixed via:

f6d52648ec

Use upgrade --no-dry-run again to install the first package to upgrade.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-02-25 20:40:22 +00:00
Rafael Kitover 9475474ee6
cmake: Add UPDATE_APPCAST script for appcast.xml.
Add the -DUPDATE_APPCAST=TRUE option to invoke the UpdateAppcast.cmake
script, which clones the github pages repo and sets the version in the
appcast.xml to the last tag, presumably made with -DTAG_RELEASE.

The script prints out a final set of instructions to actually push the
change to git.

If the option -DUPDATE_APPCAST=UNDO is used, the clone is removed and no
changes are made.

Also use the correct method of splitting the tag list output into
multiple lines.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-02-08 22:53:53 +00:00
Rafael Kitover f1abbc5f83
cmake: Use vcpkg remove/install instead of upgrade.
vcpkg upgrade is currently broken, see:

https://github.com/microsoft/vcpkg/issues/9916

Use remove followed by install, which does practically the same thing,
as a workaround.

Hopefully fix current appveyor build failures.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-02-05 17:56:05 +00:00
Rafael Kitover 213f47ec96
builder: minor fixes for mingw.
Search the lib-prefixed names of intl/iconv/charset libraries first to
avoid dlls being linked.

Update toolchain files to include the common source by full path, fixes
using them as toolchains for other projects broken in 3edd9ba7.

Update URL for nasm, use newer jpeg-turbo, tiff and wx.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-02-02 03:35:26 +00:00
Rafael Kitover 3edd9ba756
cmake: Fix fedora mingw build + misc improvements.
Use the 3.x wxwidgets mingw package in installdeps.

Add the win64 alias to installdeps for 64 bit mingw builds, like the
win32 alias for 32 bit mingw builds.

Check CROSS_ARCH in Architecture.cmake, set by our mingw toolchains.

Disable LTO by default for all mingw builds, not just amd64, because it
is unfortunately broken on i686 as well now.

Search for heuristically the most appropriate wx-config and set
wxWidgets_CONFIG_EXECUTABLE accordingly in the mingw toolchains.

Refactor the mingw toolchains somewhat, put common code into a common
file, add static toolchains.

For static toolchains, also search for a static zlib and set ZLIB_ROOT.

Change installdeps instructions to use ninja instead of make. Add ninja
to all target dependencies where it was missing, this may be incorrect
in a couple of the rarely used targets, if this is the case the affected
users are free to open an issue.

Also start using ninja on travis instead of make, except for libretro
which uses a GNU Makefile.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-02-01 16:43:08 +00:00
Rafael Kitover ba9c10d566
cmake: Make FileIterator more correct, add eg..
Add macro fi_check_done() to set fi_done if leftover contents is empty,
use it in both fi_open_file() and fi_get_next_line().

This fixes the behavior when the opened file is empty and makes the code
cleaner.

Add a usage example to top comment.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-01-26 23:35:09 +00:00
Rafael Kitover 8ce60e1745
cmake: Fix ffmpeg regression on Windows.
Remove LDFLAGS from list of required variables for finding ffmpeg to
succeed. Both main and component LDFLAGS.

Added by f7f424ea.

This is necessary because of platforms lacking pkg-config, like vcpkg +
Visual Studio, no LDFLAGS are found.

Fixes finding ffmpeg in the vcpkg + Visual Studio configuration.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-01-23 01:49:44 +00:00
Rafael Kitover 5de47935cf
cmake: Followup on release commit automation.
This is a followup on 93f906e2.

Simplify the FileIterator interface by doing the eof check in
fi_get_next_line().

Add rollback instructions to final instructions message.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-01-22 18:15:21 +00:00
Rafael Kitover 93f906e2db
cmake: Automate release commit and tag.
Add a TAG_RELEASE cmake variable which engages a cmake script to
generate a signed release commit with changelog entries from git and
signed tag.

The value can be ON/TRUE/1 or a specific next version number, or UNDO to
rollback changes just made with this script.

The script tries to make sure all the preliminaries are in the right
state to do a release, the source is a git clone, on branch master, with
a clean working tree and gpg is available.

Also add a utility script FileIterator.cmake which is an OO-like line
iterator interface for text files, used by the release commit script.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-01-22 03:14:26 +00:00
Rafael Kitover 5cc1fd28b4
cmake: Wrap vcpkg code in a function.
Wrap the main body of code in Set-Toolchain-vcpkg.cmake in the
vcpkg_set_toolchain() function to not pollute the global variable
namespace with helper variables.

VCPKG_ROOT and toolchain variables are set in the cache.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-01-17 21:55:26 +00:00
Rafael Kitover 47880ff9c6
cmake: Limit vcpkg upgrades to one port per run.
In order to not overrun the appveyor time limit of one hour, limit vcpkg
port upgrades to only the first port. This way the cache will be rebuilt
gradually instead of all at once, and the job won't fail due to
overrunning the time limit.

Also do a bit of refactoring and code improvements for
Set-Toolchain-vcpkg.cmake.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-01-17 19:47:09 +00:00
Rafael Kitover d3397e6a1a
cmake: Release automation followup.
Followup on e98d8931.

Set the BITS variable in Architecture.cmake even if
CMAKE_SYSTEM_PROCESSOR is not set, and it often isn't. This allows for
generating the right release zip for 32 bit MinGW builds.

When invoking zip to make the translations.zip, use `.` instead of `*`
as the argument, with the correct WORKING_DIRECTORY, so as not to rely
on shell globbing of any sort. This broke for the 32 bit MinGW cross
build.

Fix the keychain unlock command on mac, the keychain must be unlocked to
use the codesigning certificate.

Fix the translations.zip.asc signature overwrite prompt on Windows.

For the mac builder, automatically use Xcode 9 for 32 bit builds if
installed, this is necessary on 10.14 (Mojave) and later.

Add interactive-pause.cmake script to wait for the user to press enter
before continuing, invoke it before gpg commands so that waiting for the
passphrase does not time out. It will not run if ENV{CI} is set or
ENV{VBAM_NO_PAUSE} is set, this is so that later we can set up automated
builds.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-25 23:14:45 +00:00
Rafael Kitover f7f424ea1b
cmake: Find FFMPEG_LDFLAGS in FindFFmpeg.cmake.
Add support for setting the <component>_LDFLAGS and FFMPEG_LDFLAGS cmake
variables based on pkg-config in FindFFmpeg.cmake.

The LDFLAGS can be necessary when linking FFmpeg statically, as is the
case for the mac builder script.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-25 07:59:56 -08:00
Rafael Kitover e98d89310e
cmake: Add some release automation steps.
Use ENV{MSYSTEM_PREFIX} instead of ENV{MSYSTEM} to check for msys2 as
that is more reliable.

Generate the translations.zip when building for Windows from the
generated .gmo files.

Add the UPSTREAM_RELEASE option to perform some additional release
automation steps:

- Codesign for Windows with either the Visual Studio signtool or
  osslsigncode when using MinGW.

- On Windows zip up the .exe into the appropriate zip file for release.

- Generate the gpg signature .asc files for the translations zip and the
  .exe zip on Windows.

- On Mac codesign the app, zip it and sign the zip.

- On all platforms try to strip the binary.

Remove the release automation steps from the builder script as they are
now in cmake.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-24 06:32:01 +00:00
Rafael Kitover 939a88ab4a
cmake: No default ffmpeg on 32 bit Windows.
Only check for ffmpeg if it's not explicitly turned off and the target
is not 32 bit Windows.

This is done because Windows XP does not have bcrypt.dll which ffmpeg
requires and the 32 bit builds are more likely to be used on older
systems which would also benefit from the smaller binary size.

Also add the X86 and X64 cmake architecture variable flags.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-18 14:17:20 +00:00
Rafael Kitover 4e00fa605b
cmake: Make wrong vcpkg arch error more clear.
Followup on 49ca52ba.

Improve the code that shows a fatal error if the vcpkg target
architecture does not match the build environment, by showing both the
target architecture and the build environment architecture.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-16 00:56:10 +00:00
Rafael Kitover 49ca52ba03
cmake: Visual Studio misc followup on cf9a88df.
Fix the vcpkg root setting, which was trying to use CMAKE_PROJECT_DIR
before a project is defined by switching back to CMAKE_SOURCE_DIR. Also
check if the user has \vcpkg or c:\vcpkg and use those if found. Use
\vcpkg if ENV{CI} is set, e.g. on Appveyor.

Enable nasm for visual studio builds by using the nuget nasm2 package.

In Architecture.cmake check that the vcpkg arch matches the compiler
arch, and throw a fatal error otherwise.

When using GLOB to find the nuget package directory, use the package
name as the prefix, this is quite necessary when using multiple nuget
packages.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-15 19:34:18 +00:00
Rafael Kitover cf9a88dfc3
cmake: Visual Studio support improvements.
Add support for vcpkg ffmpeg, this requires using someone's
FindFFmpeg.cmake instead of relying on pkg-config, since vcpkg does not
have pkg-config.

Do not use the ffmpeg from vcpkg on appveyor however, because that
pushes the build cache generation over the time limit for jobs.

Add secur32 and bcrypt to the list of ffmpeg libs on windows, these are
standard windows libraries.

Change some code in ffmpeg.cpp to remove C-style casts of struct
initializers, which are illegal in MSVC.

Add the INT64_C and UINT64_C macros missing in MSVC's stdint.h (if not
defined) to ffmpeg.h before the ffmpeg headers are included, because
they rely on them.

Rewrite the wxWidgets finding code for the vcpkg wxWidgets to be nicer
and work correctly for debug and static builds.

Remove all /W* and /w* warnings options from cmake compiler flags, and
replace them with /W4 for debug builds, and /w (no warnings) for release
modes.

When building a static binary, remove all /MD* flags from cmake compiler
flags, and use /MT for static release builds and /MTd for static debug
builds.

Improve the vcpkg toolchain wrapper to only rebuild the vcpkg binary if
there were git updates.

Redo the handling of SDL2 and SDL_main. Only link SDL2Main to the SDL
binary and don't use the definitions.

Update CMakeSettings.json to use Ninja and include static
configurations.

Use CMAKE_PROJECT_DIR instead of CMAKE_SOURCE_DIR to determine the vcpkg
root, as CMAKE_SOURCE_DIR is sometimes set incorrectly in the 2017 GUI.

Add /nodefaultlib:libcmt to the debug build link flags, as in debug
builds libcmtd is used and libcmt should not be.

Add /subsystem:console to debug build link flags to produce a windows
console app for debug builds, like we do for mingw builds. To do this,
define a WIN32_CONSOLE_APP macro and if set, define a main() that calls
WinMain().

Call wxMesdsageOutput::Set() in OnInit with an instance of
wxMessageOutputStderr for windows debug builds to make sure the --help
text etc. goes to the console instead of a popup box.

Update the Visual Studio related text in README.md.

Fix dynamic debug builds by linking to the debug version of SDL2 and
copying the debug version of the dll to the build dir.

Fix issue in MainFrame::BindAppIcon with the function we are using not
being found in a Windows DLL in debug builds by using
wxDynamicLibrary::GetSymboolAorW() instead of GetSymbol().

Enable LTO for MSVC in Release modes, if the option is set.

Change appveyor config to use an 8 item build matrix of
x64/x86 / Release/Debug / Static/Dynamic. And test the binary in debug
modes by running --help.

When copying the wxrc.exe out of the build tree, copy both the release
and debug versions, this is so that appveyor caching of vcpkg works,
since the build trees are not cached.

Add some necessary win32 libraries to the SDL binary. And enable
building it on appveyor.

Fix #465.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-10 11:13:58 +00:00
Rafael Kitover 2b34983b9f
cmake: Support VS Ninja/jom builds on Windows.
Only set CMAKE_GENERATOR_PLATFORM to "x64" for 64 bit toolchains for any
of the "Visual Studio" generators, which use msbuild.

For other generators such as Ninja or NMake (jom) set
CMAKE_C[XX]_COMPILER to "cl" to let cmake find the compiler in the
user's PATH and set up the toolchain appropriately. On the user's part,
all that is required is running the 64 bit dev tools command prompt, or
setting up the equivalent environment in powershell.

We are no longer restricted to msbuild, and other generators such as
Ninja will work correctly.

Switch the appveyor job to Ninja, this requires some wrangling because
the appveyor environment does not include ninja. I used this:

https://github.com/boostorg/hana/blob/master/.appveyor.yml

Also update the README.md instructions to use Ninja.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-07 17:39:19 +00:00
Rafael Kitover 198e2467dd
cmake: Add vcpkg update and upgrade.
In the vcpkg module, call vcpkg update to update the portfiles and vcpkg
upgrade to upgrade any installed ports to make sure we are using the
latest versions.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-03 18:59:42 +00:00
Rafael Kitover c06e3bf3fc
cmake: update vcpkg mod for appveyor build cache
On appveyor we only cache the `vcpkg/installed` directory, so vcpkg
itself still needs to be pulled from git.

Also update vcpkg from git if it has already been cloned, and always
rebuild vcpkg itself.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-10-21 13:58:55 +00:00