Skip to content

Commit

Permalink
Merge pull request #333314 from nim65s/casadi-darwin
Browse files Browse the repository at this point in the history
casadi: build on darwin
  • Loading branch information
wegank authored Aug 14, 2024
2 parents f697d47 + c07ae91 commit d4c5ef7
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 28 deletions.
27 changes: 19 additions & 8 deletions pkgs/by-name/ca/casadi/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#sundials,
superscs,
spral,
swig,
swig4,
tinyxml-2,
withUnfree ? false,
}:
Expand Down Expand Up @@ -96,6 +96,17 @@ stdenv.mkDerivation (finalAttrs: {
substituteInPlace swig/python/CMakeLists.txt --replace-fail \
"if (SWIG_IMPORT)" \
"if (NOT SWIG_IMPORT)"
''
+ lib.optionalString stdenv.isDarwin ''
# this is only printing stuff, and is not defined on all CPU
substituteInPlace casadi/interfaces/hpipm/hpipm_runtime.hpp --replace-fail \
"d_print_exp_tran_mat" \
"//d_print_exp_tran_mat"
# fix missing symbols
substituteInPlace cmake/FindCLANG.cmake --replace-fail \
"clangBasic)" \
"clangBasic clangASTMatchers clangSupport)"
'';

nativeBuildInputs = [
Expand Down Expand Up @@ -128,7 +139,7 @@ stdenv.mkDerivation (finalAttrs: {
#sundials
superscs
spral
swig
swig4
tinyxml-2
]
++ lib.optionals withUnfree [
Expand All @@ -138,11 +149,15 @@ stdenv.mkDerivation (finalAttrs: {
++ lib.optionals pythonSupport [
python3Packages.numpy
python3Packages.python
];
]
++ lib.optionals stdenv.isDarwin [ llvmPackages_17.openmp ];

cmakeFlags = [
(lib.cmakeBool "WITH_PYTHON" pythonSupport)
(lib.cmakeBool "WITH_PYTHON3" pythonSupport)
# We don't mind always setting this cmake variable, it will be read only if
# pythonSupport is enabled.
"-DPYTHON_PREFIX=${placeholder "out"}/${python3Packages.python.sitePackages}"
(lib.cmakeBool "WITH_JSON" false)
(lib.cmakeBool "WITH_INSTALL_INTERNAL_HEADERS" true)
(lib.cmakeBool "INSTALL_INTERNAL_HEADERS" true)
Expand Down Expand Up @@ -189,17 +204,13 @@ stdenv.mkDerivation (finalAttrs: {
#(lib.cmakeBool "WITH_ALPAQA" true) # this requires casadi...
];

# I don't know how to pass absolute $out path from cmakeFlags
postConfigure = lib.optionalString pythonSupport ''
cmake -DPYTHON_PREFIX=$out/${python3Packages.python.sitePackages} ..
'';

doCheck = true;

meta = {
description = "CasADi is a symbolic framework for numeric optimization implementing automatic differentiation in forward and reverse modes on sparse matrix-valued computational graphs. It supports self-contained C-code generation and interfaces state-of-the-art codes such as SUNDIALS, IPOPT etc. It can be used from C++, Python or Matlab/Octave";
homepage = "https://github.com/casadi/casadi";
license = lib.licenses.lgpl3Only;
maintainers = with lib.maintainers; [ nim65s ];
platforms = lib.platforms.all;
};
})
3 changes: 2 additions & 1 deletion pkgs/by-name/hp/hpipm/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ stdenv.mkDerivation (finalAttrs: {
];

cmakeFlags = [
"-DBLASFEO_PATH=${blasfeo}"
"-DHPIPM_FIND_BLASFEO=ON"
"-DBUILD_SHARED_LIBS=ON"
] ++ lib.optionals (!stdenv.isx86_64) [ "-DTARGET=GENERIC" ];

meta = {
Expand Down
66 changes: 60 additions & 6 deletions pkgs/by-name/mu/mumps/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ stdenv.mkDerivation (finalAttrs: {
})
];

postPatch = ''
# Compatibility with coin-or-mumps version
# https://github.com/coin-or-tools/ThirdParty-Mumps/blob/stable/3.0/get.Mumps#L66
cp libseq/mpi.h libseq/mumps_mpi.h
'';
postPatch =
''
# Compatibility with coin-or-mumps version
# https://github.com/coin-or-tools/ThirdParty-Mumps/blob/stable/3.0/get.Mumps#L66
cp libseq/mpi.h libseq/mumps_mpi.h
''
+ lib.optionalString stdenv.isDarwin ''
substituteInPlace src/Makefile --replace-fail \
"-Wl,\''$(SONAME),libmumps_common" \
"-Wl,-install_name,$out/lib/libmumps_common"
'';

configurePhase = ''
cp Make.inc/Makefile.debian.SEQ ./Makefile.inc
Expand Down Expand Up @@ -67,11 +73,59 @@ stdenv.mkDerivation (finalAttrs: {
scotch
];

preFixup = lib.optionalString stdenv.isDarwin ''
install_name_tool \
-change libmpiseq.dylib \
$out/lib/libmpiseq.dylib \
-change libpord.dylib \
$out/lib/libpord.dylib \
$out/lib/libmumps_common.dylib
install_name_tool \
-change libmpiseq.dylib \
$out/lib/libmpiseq.dylib \
-change libpord.dylib \
$out/lib/libpord.dylib \
-id \
$out/lib/libcmumps.dylib \
$out/lib/libcmumps.dylib
install_name_tool \
-change libmpiseq.dylib \
$out/lib/libmpiseq.dylib \
-change libpord.dylib \
$out/lib/libpord.dylib \
-id \
$out/lib/libdmumps.dylib \
$out/lib/libdmumps.dylib
install_name_tool \
-change libmpiseq.dylib \
$out/lib/libmpiseq.dylib \
-change libpord.dylib \
$out/lib/libpord.dylib \
-id \
$out/lib/libsmumps.dylib \
$out/lib/libsmumps.dylib
install_name_tool \
-change libmpiseq.dylib \
$out/lib/libmpiseq.dylib \
-change libpord.dylib \
$out/lib/libpord.dylib \
-id \
$out/lib/libzmumps.dylib \
$out/lib/libzmumps.dylib
install_name_tool \
-id \
$out/lib/libmpiseq.dylib \
$out/lib/libmpiseq.dylib
install_name_tool \
-id \
$out/lib/libpord.dylib \
$out/lib/libpord.dylib
'';

meta = {
description = "MUltifrontal Massively Parallel sparse direct Solver";
homepage = "http://mumps-solver.org/";
license = lib.licenses.cecill-c;
maintainers = with lib.maintainers; [ nim65s ];
broken = stdenv.isDarwin;
};
})
14 changes: 9 additions & 5 deletions pkgs/by-name/pr/proxsuite/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ stdenv.mkDerivation (finalAttrs: {
"out"
];

cmakeFlags = [
(lib.cmakeBool "BUILD_DOCUMENTATION" true)
(lib.cmakeBool "INSTALL_DOCUMENTATION" true)
(lib.cmakeBool "BUILD_PYTHON_INTERFACE" pythonSupport)
];
cmakeFlags =
[
(lib.cmakeBool "BUILD_DOCUMENTATION" true)
(lib.cmakeBool "INSTALL_DOCUMENTATION" true)
(lib.cmakeBool "BUILD_PYTHON_INTERFACE" pythonSupport)
]
++ lib.optionals (stdenv.hostPlatform.system == "aarch64-linux") [
"-DCMAKE_CTEST_ARGUMENTS=--exclude-regex;ProxQP::dense: test primal infeasibility solving"
];

strictDeps = true;

Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/libraries/pinocchio/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
, boost
, eigen
, example-robot-data
, casadiSupport ? !stdenv.isDarwin
, casadiSupport ? true
, collisionSupport ? true
, console-bridge
, jrl-cmakemodules
Expand Down
46 changes: 40 additions & 6 deletions pkgs/development/libraries/science/math/bonmin/default.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
{ lib
, stdenv
, fetchFromGitHub
, fontconfig
, gfortran
, pkg-config
, blas
, bzip2
, cbc
, clp
, doxygen
, graphviz
, ipopt
, lapack
, libamplsolver
, osi
, texliveSmall
, zlib
}:

Expand All @@ -27,8 +32,11 @@ stdenv.mkDerivation rec {
};

nativeBuildInputs = [
doxygen
gfortran
graphviz
pkg-config
texliveSmall
];
buildInputs = [
blas
Expand All @@ -38,17 +46,43 @@ stdenv.mkDerivation rec {
ipopt
lapack
libamplsolver
osi
zlib
];

meta = with lib; {
configureFlagsArray = lib.optionals stdenv.isDarwin [
"--with-asl-lib=-lipoptamplinterface -lamplsolver"
];

# Fix doc install. Should not be necessary after next release
# ref https://github.com/coin-or/Bonmin/commit/4f665bc9e489a73cb867472be9aea518976ecd28
sourceRoot = "${src.name}/Bonmin";

# Fontconfig error: Cannot load default config file: No such file: (null)
env.FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf";

# Fontconfig error: No writable cache directories
preBuild = "export XDG_CACHE_HOME=$(mktemp -d)";

doCheck = true;
checkTarget = "test";

# ignore one failing test
postPatch = lib.optionalString stdenv.isDarwin ''
substituteInPlace test/Makefile.in --replace-fail \
"./unitTest\''$(EXEEXT)" \
""
'';

# install documentation
postInstall = "make install-doxygen-docs";

meta = {
description = "Open-source code for solving general MINLP (Mixed Integer NonLinear Programming) problems";
mainProgram = "bonmin";
homepage = "https://github.com/coin-or/Bonmin";
license = licenses.epl10;
platforms = platforms.unix;
maintainers = with maintainers; [ aanderse ];
# never built on aarch64-darwin, x86_64-darwin since first introduction in nixpkgs
broken = stdenv.isDarwin;
license = lib.licenses.epl10;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ aanderse ];
};
}
2 changes: 1 addition & 1 deletion pkgs/development/libraries/science/math/ipopt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
, lapack
, gfortran
, enableAMPL ? true, libamplsolver
, enableMUMPS ? !stdenv.isDarwin, mumps, mpi
, enableMUMPS ? true, mumps, mpi
, enableSPRAL ? true, spral
}:

Expand Down

0 comments on commit d4c5ef7

Please sign in to comment.