1{ lib, stdenv, fetchFromGitHub, cmake, octave ? null, libiconv }:
2
3stdenv.mkDerivation rec {
4 pname = "nlopt";
5 version = "2.7.1";
6
7 src = fetchFromGitHub {
8 owner = "stevengj";
9 repo = pname;
10 rev = "v${version}";
11 sha256 = "sha256-TgieCX7yUdTAEblzXY/gCN0r6F9TVDh4RdNDjQdXZ1o=";
12 };
13
14 nativeBuildInputs = [ cmake ] ++ lib.optionals stdenv.isDarwin [ libiconv ];
15 buildInputs = [ octave ];
16
17 configureFlags = [
18 "--with-cxx"
19 "--enable-shared"
20 "--with-pic"
21 "--without-guile"
22 "--without-python"
23 "--without-matlab"
24 ] ++ lib.optionals (octave != null) [
25 "--with-octave"
26 "M_INSTALL_DIR=$(out)/${octave.sitePath}/m"
27 "OCT_INSTALL_DIR=$(out)/${octave.sitePath}/oct"
28 ];
29
30 postFixup = ''
31 substituteInPlace $out/lib/cmake/nlopt/NLoptLibraryDepends.cmake --replace \
32 'INTERFACE_INCLUDE_DIRECTORIES "''${_IMPORT_PREFIX}/' 'INTERFACE_INCLUDE_DIRECTORIES "'
33 '';
34
35 meta = {
36 homepage = "https://nlopt.readthedocs.io/en/latest/";
37 description = "Free open-source library for nonlinear optimization";
38 license = lib.licenses.lgpl21Plus;
39 hydraPlatforms = lib.platforms.linux;
40 };
41
42}