Skip to content

Add CMake for 5.0#1558

Draft
mark-z-r wants to merge 26 commits into
NetHack:NetHack-5.0from
mark-z-r:cmake
Draft

Add CMake for 5.0#1558
mark-z-r wants to merge 26 commits into
NetHack:NetHack-5.0from
mark-z-r:cmake

Conversation

@mark-z-r

@mark-z-r mark-z-r commented May 28, 2026

Copy link
Copy Markdown

commits from cmake 3.7 (scraped most, if not all, of the files from this)

  • CMakeLists.txt files from NetHack 3.6.6.
  • CMakeLists.txt for NetHack 3.7.
  • Specify lua build output
  • Add missing panic.c dependency to makedefs
  • Add libdl and libm dependencies
  • List sources without GLOB.

My commits

  • Basically entirely rewrote CMakeLists.txt
  • and more...

I thought i would use the 3.7 attempt as a starting point, but so much has changed
since then that I decided to start over

What the PR plans to cover:

  • buildable on chimera linux (this means llvm and musl)
  • UBSAN & ASAN (soft requirements for chimera linux packages)
  • most of the options detailed in sys/unix/README.hints, some of them might be dummy
    switches for now
    (no longer planned)
  • Only system vendored lua

I dont remeber why I decided to do this. (probably something to do with creating a chimera port)

I would like some confirmation that this pr will get accepted if it is up to snuff. or
in other words, I want to make sure that this PR will not get rejected just because CMake support
is unwanted

Heinrich Kuttler and others added 24 commits January 20, 2022 23:53
libm math functions are used by lua and NetHack and Lua both need to
link to libdl.a.
Updates to NetHack 3.7 CMakeLists.txt
Be able to carry out uplifts during minor release
lifetimes.

Document a way to be able to uplift struct content
without incrementing EDITLEVEL and breaking existing savefiles.
Use the mechanics outlined to uplift the contents instead, where
it is feasible to do so. The uplift is currently one-way only. An
uplifted savefile cannot be used with an earlier build of NetHack
, one built with a lower SAVEFILE_REVISION_LEVEL, than the one which
wrote the savefile.

The final byte (byte 79) of the 80 critical bytes in the savefile,
of which 10 are reserved for future expansion and not currently
used, will now be used for holding the savefile revision level
(SAVEFILE_REVISION_LEVEL in include/patchlevel.h) at the time
the savefile was written.

That leaves 9 of the bytes available for future use.
The directories and permissions portion of the linux.500 and macOS.500
hints files and their included files has been consolidated to
dirs-perms.500.

The builder can edit that one file now, to identify
the folders that will be utilised as part of the build.

Alternatively, you can set those folders and permissions in a
make.perms file in the top of the NetHack folder tree and
they should take precedence over the ones in dirs-perms.500
because dirs-perms.500 uses '?=' variable assignment, which
means "set the value of the variable if no value has been set."

* NOTE: BUILD CHANGE *

This also makes WANT_SOURCE_INSTALL=1 the default over
WANT_SHARED_INSTALL=1, if neither is explicitly set.
The new default is the safer and less-impacting default,
but it will change where things get installed over earlier
Makefile builds. You can be explicit with WANT_SHARED_INSTALL=1
in your make command to get that..

These are the differences between the two:

make WANT_SHARED_INSTALL=1    Place the results of the install/update portion
                              of the build into a shared area on a multiuser
                              system.

make WANT_SOURCE_INSTALL=1    Place the results of the install/update portion
                              of the build into a subfolder of the source
                              tree, rather than in a system-wide shared area.

Also note that the macOS hints file behaves slightly differntly depending
on whether WANT_SOURCE_INSTALL=1 was set versus letting it be the default.
That's not new, it behaved that way before.
It was using dupstr(), so strutil had to be added to the project.
There is no unintentional spelling mistake.
Close NetHack#1523
and split out the options into a seperate file
	modified:   CMakeLists.txt
	new file:   CMakeOptions.txt
the resultant binary don't work though
lots done, probably should have split this up into more commits...

important to note is that I changed report.c to not output a backtrace
if NO_BACKTRACE if defined. NO_BACKTRACE gets defined if `backtrace()` is
not defined.

still missing a lot of features that the makefiles have, but it is hard
dechipering the current build system...

	modified:   CMakeLists.txt
	modified:   CMakeOptions.txt
	new file:   src/CMakeLists.txt
	modified:   src/report.c
	new file:   sys/CMakeLists.txt
	modified:   util/CMakeLists.txt
	new file:   win/CMakeLists.txt
	new file:   win/curses/CMakeLists.txt
	new file:   win/tty/CMakeLists.txt
	modified:   CMakeOptions.txt
	modified:   src/CMakeLists.txt
	modified:   sys/CMakeLists.txt
	new file:   sys/share/CMakeLists.txt
just that. added some info on finding config values for cmake too
mark-z-r added 2 commits June 3, 2026 23:37
nethack can run now. requires manual setup of data dirs, but it runs!

next steps: data files (makedefs) and installs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants