2 files changed +28
-21
lines changed Original file line number Diff line number Diff line change 3
3
stdenv ,
4
4
fetchFromGitHub ,
5
5
cmake ,
6
- octave ? null ,
7
- libiconv ,
6
+ # Optionally build python bindings
7
+ withPython ? false ,
8
+ # Optionally build octave bindings
9
+ withOctave ? false ,
10
+ # For retrieving optional dependencies related to the aforementioned bindings
11
+ pkgs ,
8
12
} :
9
-
10
13
stdenv . mkDerivation rec {
11
14
pname = "nlopt" ;
12
15
version = "2.7.1" ;
@@ -18,26 +21,30 @@ stdenv.mkDerivation rec {
18
21
sha256 = "sha256-TgieCX7yUdTAEblzXY/gCN0r6F9TVDh4RdNDjQdXZ1o=" ;
19
22
} ;
20
23
21
- nativeBuildInputs = [ cmake ] ++ lib . optionals stdenv . hostPlatform . isDarwin [ libiconv ] ;
22
- buildInputs = [ octave ] ;
23
-
24
- configureFlags =
25
- [
26
- "--with-cxx"
27
- "--enable-shared"
28
- "--with-pic"
29
- "--without-guile"
30
- "--without-python"
31
- "--without-matlab"
32
- ]
33
- ++ lib . optionals ( octave != null ) [
34
- "--with-octave"
35
- "M_INSTALL_DIR=$(out)/${ octave . sitePath } /m"
36
- "OCT_INSTALL_DIR=$(out)/${ octave . sitePath } /oct"
24
+ nativeBuildInputs =
25
+ [ cmake ]
26
+ ## The octave bindings are vendored within the repository, and therefore do not require further effort.
27
+ ##
28
+ ## Building the python bindings requires SWIG, and numpy in addition to the CXX routines.
29
+ ++ lib . optionals withPython [
30
+ pkgs . swig
31
+ ( pkgs . python3 . withPackages ( p : [ p . numpy ] ) )
37
32
] ;
38
33
34
+ cmakeFlags = [
35
+ "-DBUILD_SHARED_LIBS=OFF"
36
+ "-DNLOPT_CXX=ON"
37
+ "-DNLOPT_PYTHON=${ if withPython then "ON" else "OFF" } "
38
+ "-DNLOPT_OCTAVE=${ if withOctave then "ON" else "OFF" } "
39
+ "-DNLOPT_MATLAB=OFF"
40
+ "-DNLOPT_GUILE=OFF"
41
+ "-DNLOPT_SWIG=${ if withPython then "ON" else "OFF" } "
42
+ ] ;
43
+
44
+ doCheck = true ;
45
+
39
46
postFixup = ''
40
- substituteInPlace $out/lib/cmake/nlopt/NLoptLibraryDepends.cmake --replace \
47
+ substituteInPlace $out/lib/cmake/nlopt/NLoptLibraryDepends.cmake --replace-fail \
41
48
'INTERFACE_INCLUDE_DIRECTORIES "'' ${_IMPORT_PREFIX}/' 'INTERFACE_INCLUDE_DIRECTORIES "'
42
49
'' ;
43
50
Original file line number Diff line number Diff line change @@ -4298,7 +4298,7 @@ with pkgs;
4298
4298
4299
4299
nifskope = libsForQt5.callPackage ../tools/graphics/nifskope { };
4300
4300
4301
- nlopt = callPackage ../development/libraries/nlopt { octave = null; };
4301
+ nlopt = callPackage ../development/libraries/nlopt { };
4302
4302
4303
4303
notation = callPackage ../by-name/no/notation/package.nix {
4304
4304
buildGoModule = buildGo123Module;
0 commit comments