I’m currently attempting to build an EasyRPG fork with Emscripten using the following script:
{
buildEmscriptenPackage,
fmt,
freetype,
harfbuzz,
liblcf,
libpng,
nlohmann_json,
pixman,
SDL2,
zlib,
autoconf,
automake,
cmake,
emscripten,
gnum4,
libtool,
meson,
pkg-config,
ninja,
unzip,
which
}: buildEmscriptenPackage {
pname = "minnaengine";
version = "0.1.0";
src = ./.;
strictDeps = true;
buildInputs = [
fmt
freetype
harfbuzz
liblcf
libpng
nlohmann_json
pixman
SDL2
zlib
];
nativeBuildInputs = [
autoconf
automake
cmake
emscripten
gnum4
libtool
meson
pkg-config
ninja
unzip
which
];
configurePhase = ''
mkdir -p .emscriptencache/
export EM_CACHE=$(pwd)/.emscriptencache/
emcmake cmake . \
-GNinja \
-Bbuild \
-DCMAKE_CXX_COMPILER_LAUNCHER="emcc" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=OFF \
-DSDL2_INCLUDE_DIR=${SDL2}/include \
-DSDL2_LIBRARY=${SDL2}/lib \
-DPLAYER_ENABLE_FMMIDI=OFF \
-DPLAYER_WITH_MPG123=OFF \
-DPLAYER_WITH_LIBSNDFILE=OFF \
-DPLAYER_WITH_OGGVORBIS=OFF \
-DPLAYER_WITH_WILDMIDI=OFF \
-DPLAYER_WITH_FLUIDLITE=OFF \
-DPLAYER_WITH_XMP=OFF \
-DPLAYER_ENABLE_DRWAV=OFF \
-DPLAYER_JS_BUILD_SHELL=ON \
-DPLAYER_JS_OUTPUT_NAME=minnaengine \
-DPLAYER_JS_GAME_URL=/data/ \
-DCMAKE_CXX_FLAGS='-O3 -g0 -msimd128'
'';
buildPhase = ''
ls
'';
checkPhase = "";
}
A lot of it is strictly provisional as I’m trying to get it working at the bare minimum before I polish it. I’m building it with nix-build and the initial configure phase seems to work fine until it tries to find fmt. It complains that it’s unable to find a version 5.2 for the package, instead finding a newer version that is 64-bit:
-- Build type is set to Release.
-- Found SDL2: /nix/store/dgvj2cvlyqp5513cjza6lmy2bah6vdqj-sdl2-compat-2.32.58/lib (Required is at least version "2.0.14")
-- Found liblcf: /nix/store/ms87qh2nm2irw3z5d2w224sadjf7g1y0-liblcf-0.8.1/lib/cmake/liblcf (liblcf::liblcf, v0.8.1)
-- Found ZLIB: /nix/store/l7xwm1f6f3zj2x8jwdbi8gdyfbx07sh7-zlib-1.3.1/lib/libz.so (found version "1.3.1")
-- Found PNG: /nix/store/s8md611ry6w14m4awmgivld52ym8s3b2-libpng-apng-1.6.50/lib/libpng.so (found version "1.6.50")
CMake Error at builds/cmake/Modules/PlayerFindPackage.cmake:66 (find_package):
Could not find a configuration file for package "fmt" that is compatible
with requested version "5.2".
The following configuration files were considered but not accepted:
/nix/store/nbzws3vkz282gf1p0mydxd28ckn8b0wr-fmt-12.0.0-dev/lib/cmake/fmt/fmt-config.cmake, version: 12.0.0 (64bit)
Call Stack (most recent call first):
CMakeLists.txt:964 (player_find_package)
-- Configuring incomplete, errors occurred!
This is the CMakeLists line in question:
player_find_package(NAME fmt TARGET fmt::fmt VERSION 5.2 REQUIRED)
I’m unsure if the “version” parameter is referring to an exact version that it wants, or a minimum version; I’m going to assume it refers to a minimum version because it wouldn’t make much sense otherwise…?
So, from what I’ve read online, it seems that the problem here is that the package is 64-bit when it wants a 32-bit package? The build instructions recommend “fmtlib >= 6”. The name is rather vague so I assume it’s referring to that fmt, which I naturally inserted into the buildInputs. My confusion is that it seems to find all of the other dependencies up to this point with no issue at all, so has this package just not been built for the Emscripten target yet? I’m not sure what to do about this, or if this is even a nixpkgs problem or just an issue Nix has nothing to do with.
I am rather unfamiliar with both CMake and Emscripten, so any help would be appreciated… other people building the same software outside of Nix don’t seem to have run into this issue in particular.