Migrate to a CMake-based build system.

This completely removes the old system of mkfiles.pl + Recipe + .R
files that I used to manage the various per-platform makefiles and
other build scripts in this code base. In its place is a
CMakeLists.txt setup, which is still able to compile for Linux,
Windows, MacOS, NestedVM and Emscripten.

The main reason for doing this is because mkfiles.pl was a horrible
pile of unmaintainable cruft. It was hard to keep up to date (e.g.
didn't reliably support the latest Visual Studio project files); it
was so specific to me that nobody else could maintain it (or was even
interested in trying, and who can blame them?), and it wasn't even
easy to _use_ if you weren't me. And it didn't even produce very good
makefiles.

In fact I've been wanting to hurl mkfiles.pl in the bin for years, but
was blocked by CMake not quite being able to support my clang-cl based
system for cross-compiling for Windows on Linux. But CMake 3.20 was
released this month and fixes the last bug in that area (it had to do
with preprocessing of .rc files), so now I'm unblocked!

CMake is not perfect, but it's better at mkfiles.pl's job than
mkfiles.pl was, and it has the great advantage that lots of other
people already know about it.

Other advantages of the CMake system:

 - Easier to build with. At least for the big three platforms, it's
   possible to write down a list of build commands that's actually the
   same everywhere ("cmake ." followed by "cmake --build ."). There's
   endless scope for making your end-user cmake commands more fancy
   than that, for various advantages, but very few people _have_ to.

 - Less effort required to add a new puzzle. You just add a puzzle()
   statement to the top-level CMakeLists.txt, instead of needing to
   remember eight separate fiddly things to put in the .R file. (Look
   at the reduction in CHECKLST.txt!)

 - The 'unfinished' subdirectory is now _built_ unconditionally, even
   if the things in it don't go into the 'make install' target. So
   they won't bit-rot in future.

 - Unix build: unified the old icons makefile with the main build, so
   that each puzzle builds without an icon, runs to build its icon,
   then relinks with it.

 - Windows build: far easier to switch back and forth between debug
   and release than with the old makefiles.

 - MacOS build: CMake has its own .dmg generator, which is surely
   better thought out than my ten-line bodge.

 - net reduction in the number of lines of code in the code base. In
   fact, that's still true _even_ if you don't count the deletion of
   mkfiles.pl itself - that script didn't even have the virtue of
   allowing everything else to be done exceptionally concisely.
This commit is contained in:
Simon Tatham
2021-03-29 18:23:11 +01:00
parent 72b28b5e71
commit cc7f5503dc
82 changed files with 1202 additions and 3668 deletions

46
README
View File

@ -2,48 +2,12 @@ This is the README accompanying the source code to Simon Tatham's
puzzle collection. The collection's web site is at
<https://www.chiark.greenend.org.uk/~sgtatham/puzzles/>.
If you've obtained the source code by downloading a .tar.gz archive
from the Puzzles web site, you should find several Makefiles in the
source code. However, if you've checked the source code out from the
Puzzles git repository, you won't find the Makefiles: they're
automatically generated by `mkfiles.pl', so run that to create them.
The puzzle collection is built using CMake <https://cmake.org/>. To
compile in the simplest way (on any of Linux, Windows or Mac), run
these commands in the source directory:
The Makefiles include:
- `Makefile.am', together with the static `configure.ac', is intended
as input to automake. Run `mkauto.sh' to turn these into a
configure script and Makefile.in, after which you can then run
`./configure' to create an actual Unix Makefile.
- `Makefile.vc' should work under MS Visual C++ on Windows. Run
'nmake /f Makefile.vc' in a Visual Studio command prompt.
- `Makefile.cyg' should work under Cygwin / MinGW. With appropriate
tweaks and setting of TOOLPATH, it should work for both compiling
on Windows and cross-compiling on Unix.
- `Makefile.osx' should work under Mac OS X, provided the Xcode
tools are installed. It builds a single monolithic OS X
application capable of running any of the puzzles, or even more
than one of them at a time.
- `Makefile.wce' should work under MS eMbedded Visual C++ on
Windows and the Pocket PC SDK; it builds Pocket PC binaries.
Many of these Makefiles build a program called `nullgame' in
addition to the actual game binaries. This program doesn't do
anything; it's just a template for people to start from when adding
a new game to the collection, and it's compiled every time to ensure
that it _does_ compile and link successfully (because otherwise it
wouldn't be much use as a template). Once it's built, you can run it
if you really want to (but it's very boring), and then you should
ignore it.
DO NOT EDIT THE MAKEFILES DIRECTLY, if you plan to send any changes
back to the maintainer. The makefiles are generated automatically by
the Perl script `mkfiles.pl' from the file `Recipe' and the various
.R files. If you need to change the makefiles as part of a patch,
you should change Recipe, *.R, and/or mkfiles.pl.
cmake .
cmake --build .
The manual is provided in Windows Help format for the Windows build;
in text format for anyone who needs it; and in HTML for the Mac OS X