1- cmake_minimum_required (VERSION 3.15 )
1+ cmake_minimum_required (VERSION 3.28 )
22file (STRINGS "version.txt" NLE_VERSION)
33# Remove any rcXX suffix from the version number as CMake doesn't like it
44string (REGEX REPLACE "rc[0-9+]$" "" CMAKE_NLE_VERSION ${NLE_VERSION} )
@@ -53,6 +53,22 @@ message(STATUS "HACKDIR set to: ${HACKDIR}")
5353set (VARDIR ${HACKDIR} )
5454set (INSTDIR ${HACKDIR} )
5555
56+ # pybind11 via FetchContent
57+ include (FetchContent)
58+ FetchContent_Declare(
59+ pybind11
60+ GIT_REPOSITORY https://github.com/pybind/pybind11.git
61+ GIT_TAG v3.0.1
62+ EXCLUDE_FROM_ALL )
63+ FetchContent_MakeAvailable(pybind11)
64+
65+ # de-boost-ified version of boost.context via FetchContent
66+ FetchContent_Declare(
67+ deboost_context
68+ GIT_REPOSITORY https://github.com/septag/deboost.context.git
69+ GIT_HASH "259fc4103bad6bb484d5ff426ace56ac557107a4" EXCLUDE_FROM_ALL )
70+ FetchContent_MakeAvailable(deboost_context)
71+
5672add_compile_definitions (
5773 GCC_WARN
5874 NOCLIPPING
@@ -78,9 +94,6 @@ set(NLE_DAT_GEN ${nle_BINARY_DIR}/dat)
7894set (NLE_UTIL_GEN ${nle_BINARY_DIR} /util)
7995
8096set (CMAKE_INSTALL_MESSAGE LAZY) # Don't tell us about up-to-date files.
81-
82- # EXCLUDE_FROM_ALL: Don't install this static library into /usr/local.
83- add_subdirectory (third_party/deboost.context EXCLUDE_FROM_ALL )
8497add_subdirectory (util)
8598add_subdirectory (dat)
8699
@@ -96,17 +109,27 @@ file(
96109 "win/tty/*.c"
97110 "win/rl/winrl.cc" )
98111
99- # static version of bzip2 library
100- add_library (
101- bz2_static STATIC
102- "third_party/bzip2/blocksort.c"
103- "third_party/bzip2/bzlib.c"
104- "third_party/bzip2/compress.c"
105- "third_party/bzip2/crctable.c"
106- "third_party/bzip2/decompress.c"
107- "third_party/bzip2/huffman.c"
108- "third_party/bzip2/randtable.c" )
109- target_link_libraries (bz2_static)
112+ # FetchContent for bzip2
113+ include (FetchContent)
114+ FetchContent_Declare(
115+ bzip2
116+ GIT_REPOSITORY git://sourceware.org/git/bzip2.git
117+ GIT_HASH fbc4b11da543753b3b803e5546f56e26ec90c2a7 EXCLUDE_FROM_ALL )
118+ FetchContent_MakeAvailable(bzip2)
119+
120+ # Manually add bzip2 source files from the downloaded directory
121+ set (BZIP2_SRC
122+ ${bzip2_SOURCE_DIR} /blocksort.c
123+ ${bzip2_SOURCE_DIR} /bzlib.c
124+ ${bzip2_SOURCE_DIR} /compress.c
125+ ${bzip2_SOURCE_DIR} /crctable.c
126+ ${bzip2_SOURCE_DIR} /decompress.c
127+ ${bzip2_SOURCE_DIR} /huffman.c
128+ ${bzip2_SOURCE_DIR} /randtable.c)
129+
130+ # EXCLUDE_FROM_ALL: Don't install this static library into /usr/local.
131+ add_library (bz2_static STATIC EXCLUDE_FROM_ALL ${BZIP2_SRC} )
132+ target_include_directories (bz2_static PUBLIC ${bzip2_SOURCE_DIR} )
110133
111134# terminal emulator library
112135add_library (tmt STATIC "third_party/libtmt/tmt.c" )
@@ -119,8 +142,7 @@ set_target_properties(nethack PROPERTIES CXX_STANDARD 14 SUFFIX ".so")
119142target_include_directories (
120143 nethack
121144 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /include ${NLE_INC_GEN} /usr/local/include
122- ${CMAKE_CURRENT_SOURCE_DIR} /third_party/libtmt
123- ${CMAKE_CURRENT_SOURCE_DIR} /third_party/bzip2)
145+ ${CMAKE_CURRENT_SOURCE_DIR} /third_party/libtmt ${bzip2_SOURCE_DIR} )
124146# target_link_directories(nethack PUBLIC /usr/local/lib)
125147
126148# Careful with -DMONITOR_HEAP: Ironically, it fails to fclose FILE* heaplog.
@@ -131,9 +153,8 @@ target_link_libraries(nethack PUBLIC m fcontext bz2_static tmt)
131153# dlopen wrapper library
132154add_library (nethackdl STATIC "sys/unix/nledl.c" )
133155target_include_directories (
134- nethackdl
135- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /include
136- ${CMAKE_CURRENT_SOURCE_DIR} /third_party/deboost.context/include )
156+ nethackdl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /include
157+ ${deboost_context_SOURCE_DIR} /include )
137158target_link_libraries (nethackdl PUBLIC dl)
138159
139160# rlmain C++ (test) binary
@@ -144,7 +165,6 @@ target_include_directories(rlmain PUBLIC ${NLE_INC_GEN})
144165add_dependencies (rlmain util) # For pm.h.
145166
146167# pybind11 core python library.
147- add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /third_party/pybind11)
148168pybind11_add_module(
149169 _pynethack
150170 win/rl/pynethack.cc
@@ -165,8 +185,7 @@ add_library(
165185target_include_directories (
166186 converter
167187 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /third_party/libtmt
168- ${CMAKE_CURRENT_SOURCE_DIR} /third_party/converter
169- ${CMAKE_CURRENT_SOURCE_DIR} /third_party/bzip2)
188+ ${CMAKE_CURRENT_SOURCE_DIR} /third_party/converter ${bzip2_SOURCE_DIR} )
170189target_link_libraries (converter PUBLIC bz2_static tmt)
171190if (CMAKE_BUILD_TYPE MATCHES Debug)
172191 target_compile_options (converter PRIVATE -Wall -Wextra -pedantic -Werror)
0 commit comments