Commit 3f2edde8 authored by qbisi's avatar qbisi
Browse files

pagmo2: modernize; drop use of gold

parent 1168d9be
Loading
Loading
Loading
Loading
+36 −23
Original line number Diff line number Diff line
{
  fetchFromGitHub,
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
  eigen,
  nlopt,
  ipopt,
  boost,
  onetbb,
  # tests pass but take 30+ minutes
  runTests ? false,
  testers,
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "pagmo2";
  version = "2.19.1";

  src = fetchFromGitHub {
    owner = "esa";
    repo = "pagmo2";
    rev = "v${version}";
    rev = "v${finalAttrs.version}";
    sha256 = "sha256-ido3e0hQLDEPT0AmsfAVTPlGbWe5QBkxgRO6Fg1wp/c=";
  };

  outputs = [
    "out"
    "dev"
  ];

  nativeBuildInputs = [ cmake ];

  buildInputs = [
    onetbb
  ];

  propagatedBuildInputs = [
    eigen
    nlopt
    ipopt
    boost
    onetbb
  ]
  ++ lib.optional (!stdenv.hostPlatform.isDarwin) ipopt;
  ];

  cmakeFlags = [
    "-DPAGMO_BUILD_TESTS=${if runTests then "ON" else "OFF"}"
    "-DPAGMO_WITH_EIGEN3=yes"
    "-DPAGMO_WITH_NLOPT=yes"
    "-DNLOPT_LIBRARY=${nlopt}/lib/libnlopt${stdenv.hostPlatform.extensions.sharedLibrary}"
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [
    "-DPAGMO_WITH_IPOPT=yes"
    "-DCMAKE_CXX_FLAGS='-fuse-ld=gold'"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # FIXME: fails ipopt test with Invalid_Option on darwin, so disable.
    "-DPAGMO_WITH_IPOPT=no"
    "-DLLVM_USE_LINKER=gold"
    (lib.cmakeBool "PAGMO_BUILD_TESTS" finalAttrs.finalPackage.doCheck)
    (lib.cmakeBool "PAGMO_WITH_EIGEN3" true)
    (lib.cmakeBool "PAGMO_WITH_NLOPT" true)
    (lib.cmakeBool "PAGMO_WITH_IPOPT" true)
  ];

  doCheck = runTests;
  env = {
    # Workaround clang17+ / lto bug
    # See https://github.com/esa/pagmo2/pull/585
    # Should be removed in new release
    NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-fno-assume-unique-vtables";
  };

  doCheck = true;

  passthru = {
    tests.cmake-config = testers.hasCmakeConfigModules {
      moduleNames = [ "pagmo" ];
      package = finalAttrs.finalPackage;
    };
  };

  meta = {
    homepage = "https://esa.github.io/pagmo2/";
@@ -57,4 +70,4 @@ stdenv.mkDerivation rec {
    platforms = lib.platforms.unix;
    maintainers = [ lib.maintainers.costrouc ];
  };
}
})
+0 −6
Original line number Diff line number Diff line
@@ -5,9 +5,6 @@
  fetchFromGitHub,
  cmake,
  boost,
  eigen,
  ipopt,
  nlopt,
  pagmo2,
  python,
  cloudpickle,
@@ -43,9 +40,6 @@ toPythonModule (

    buildInputs = [
      boost
      eigen
      ipopt
      nlopt
      pagmo2
      pybind11
    ];