For those who don't know what cmake is, it generates build files for a number of different build systems (eg, MAKE, Visual Studio etc.). Think of it like a cross platform alternative to the Unix autotools.
I've created an experimental proof-of-concept cmake configuration for PCem that folks may be interested in trying. If there's any interest, I will try and improve it based on user feedback. If Sarah is interested, I'll submit it as formal patch for inclusion upstream once the kinks have been worked out.
Why cmake? I realized that there are many users here who are using their own custom build system to compile PCem. Some are using MSYS, others MSYS2. Then there's the ones using standalone MinGW and MinGW-w64. And still others who may be using Linux. The current situation means that Sarah is keeping a whole bunch of different makefiles and autotools files in sync with each others.
The idea of using cmake would mean that only one set of files (or for most tasks, the source list file) needs to be altered, and cmake can worry about creating build system specific files.
Also, cmake makes it easy to build out of source.
Usage
I've currently tested this with a standalone/portable version of MinGW-w64, and MSYS2. It should also work fine on Linux.
Standalone MinGW(w-64) is the most difficult to get working, simply due to the fact that finding needed libraries/headers can be a bit of a pain. Here's a suggested example that should hopefully work:
Code: Select all
(make sure gcc and g++ are in your path)
> set PATH=%PATH%;C:\mingw-w64\mingw32\bin
(set root dir of where wxWidgets can be found. In my case, it's installed to my MinGW location)
> set WXWIN=C:/mingw-w64/mingw32
(create a build directory. May be subdirectory of pcem directory. In my case, it's a sibling directory)
> mkdir pcem-build
> cd pcem-build
(run cmake. The option "-DCMAKE_PREFIX_PATH" will help cmake find the appropriate libraries)
pcem-build> cmake -G "MinGW Makefiles" -DCMAKE_PREFIX_PATH=C:/mingw-w64/mingw32 ../pcem
(If it errors out unable to find wxWidgets, run the above again. If it still doesn't work, we will need to figure out how to improve things)
(Once successfully run, we simply run mingw32-make
pcem-build> mingw32-make -j
Code: Select all
$ pacman -S mingw-w64-i686-cmake
$ mkdir pcem-build
$ cd pcem-build
$ cmake -G "MSYS Makefiles" ../pcem
$ make -j
Code: Select all
$ mkdir pcem-build
$ cd pcem-build
$ cmake -G "Unix Makefiles" ../pcem
$ make -j
EDIT: If you change a source file, running make (or mingw32-make) again should be sufficient. No need to re-run cmake after source code changes, or even new source files. Also, if you want to start again, it's a simple matter of deleting the contents of your build directory and re-running cmake.
I welcome any feedback. As said earlier, this is an experimental POC, expect it to break :p Have fun!
As an aside, cmake is only slightly less obtuse to figure out than the autotools. I've also never used cmake before today, so there are probably better ways of doing some stuff.