Commit f1914312 authored by Adkins, Cameron's avatar Adkins, Cameron
Browse files

openvdb: cross-compile support for mingw

parent 9db7ad12
Loading
Loading
Loading
Loading
+22 −7
Original line number Diff line number Diff line
{ lib, stdenv, fetchFromGitHub, cmake, boost, jemalloc, c-blosc, tbb, zlib }:
{ lib, stdenv, fetchFromGitHub, cmake, boost, jemalloc, c-blosc, tbb, zlib, bzip2, lzma, zstd}:

stdenv.mkDerivation rec
{
@@ -16,14 +16,29 @@ stdenv.mkDerivation rec

  nativeBuildInputs = [ cmake ];

  buildInputs = [ boost tbb jemalloc c-blosc zlib ];

  cmakeFlags = [ "-DOPENVDB_CORE_STATIC=OFF" "-DOPENVDB_BUILD_NANOVDB=ON"];
  buildInputs = [ boost tbb jemalloc c-blosc zlib ] ++ lib.optionals stdenv.hostPlatform.isMinGW [
    bzip2
    lzma
    zstd
  ];

  cmakeFlags = [
    "-DOPENVDB_BUILD_NANOVDB=ON"
  ] ++ lib.optionals stdenv.hostPlatform.isMinGW [
    "-DOPENVDB_CORE_STATIC=ON"
    "-DOPENVDB_CORE_SHARED=OFF"
    "-DBoost_USE_STATIC_LIBS=ON"
  ] ++ lib.optionals stdenv.hostPlatform.isUnix [
    "-DOPENVDB_CORE_STATIC=OFF"
    "-DOPENVDB_CORE_SHARED=ON"
  ];

  # error: aligned deallocation function of type 'void (void *, std::align_val_t) noexcept' is only available on macOS 10.13 or newer
  env = lib.optionalAttrs (stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13" && lib.versionAtLeast tbb.version "2021.8.0") {
    NIX_CFLAGS_COMPILE = "-faligned-allocation";
  };
  NIX_CFLAGS_COMPILE = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13" && lib.versionAtLeast tbb.version "2021.8.0") [
    "-faligned-allocation"
  ] ++ lib.optionals stdenv.hostPlatform.isMinGW [
    "-Wa,-mbig-obj"
  ];

  postFixup = ''
    substituteInPlace $dev/lib/cmake/OpenVDB/FindOpenVDB.cmake \
+3 −1
Original line number Diff line number Diff line
@@ -22456,7 +22456,9 @@ with pkgs;
  watcherclient = with python311Packages; toPythonApplication python-watcherclient;
  zunclient = with python311Packages; toPythonApplication python-zunclient;
  openvdb = callPackage ../development/libraries/openvdb { };
  openvdb = callPackage ../development/libraries/openvdb {
    tbb = tbb_2021_11;
  };
  openvr = callPackage ../by-name/op/openvr/package.nix {
    inherit (darwin.apple_sdk.frameworks) Foundation AppKit;