The change allows correct and optimized incremental builds with VC and
ninja but unix makefile backend will rebuild everything if anything
changes in structures.
While testing the build dependency issues I noticed that cmake C module
overwrites our CMAKE_BUILD_TYPE help. I decided to fix the help and make
the build type a gui string which makes it easier to select build
configuration.
ninja has a single build file which avoided issues if multiple targets
depend on same files. But Unix Makefiles generator user recursive make
which requires each ADD_CUSTOM_COMMAND to have only one target depending
on them.
Then makefile generator also has stupid rule that it touches all
secundary output files if primary file has been updated.
It was surprising hard to find a version that actually works correctly
for both issues. Solution is using BYPRODUCTS and refactoring command
and target dependencies.
As a bonus this change now allows build to work from source tarball if
the tarball includes git-describe.h.
Using add_custom_command allows cmake to track dependency from command
to git-describe.h that is implicit dependency of DFHackVersion.cpp.
The change also fixes issues if there is multiple build directories and
git-describe.h missing but git-dsecribe.h.tmp is present.
_exit seems to run dll unloading code which calls static destructors.
Standrd requires std::_Exit not to call destructors which makes using it
attractive in case MSVC actually follows the standard.
I'm not sure if calling GetModuleHandle in static construction is safe.
But I assumme it is and works correctly.
There is still potential issue that documentation can be understood
meaning that the HMODULE will resolve only symbols from exe while
RTLD_DEFAULT resolves all global symbols.
plen+cooked_cursor==cols => begin = -1 which is passed to substr. The
sign is incorrect as code should be removing a character from begin
instead of trying to add a character.