25 pythonSupport ? false,
39 stdenv.mkDerivation (finalAttrs: {
43 src = fetchFromGitHub {
46 rev = finalAttrs.version;
47 hash = "sha256-Mft0qhjdAbU82RgjYuKue5p7EqbTbt3ii5yXSsCFHrQ=";
52 name = "fix-FindMUMPS.cmake.patch";
53 url = "https://github.com/casadi/casadi/pull/3899/commits/274f4b23f73e60c5302bec0479fe1e92682b63d2.patch";
54 hash = "sha256-3GWEWlN8dKLD6htpnOQLChldcT3hE09JWLeuCfAhY+4=";
56 # update include file path and link with clangAPINotes
57 # https://github.com/casadi/casadi/issues/3969
63 # fix case of hpipmConfig.cmake
64 substituteInPlace CMakeLists.txt --replace-fail \
68 # nix provide lib/clang headers in libclang, not in llvm.
69 substituteInPlace casadi/interfaces/clang/CMakeLists.txt --replace-fail \
70 '$'{CLANG_LLVM_LIB_DIR} \
71 ${lib.getLib llvmPackages.libclang}/lib
73 # help casadi find its own libs
74 substituteInPlace casadi/core/casadi_os.cpp --replace-fail \
75 "std::vector<std::string> search_paths;" \
76 "std::vector<std::string> search_paths;
77 search_paths.push_back(\"$out/lib\");"
79 + lib.optionalString pythonSupport ''
80 # fix including Python.h issue
81 substituteInPlace swig/python/CMakeLists.txt --replace-fail \
82 "add_library(_casadi MODULE \''${PYTHON_FILE})" \
83 "add_library(_casadi MODULE \''${PYTHON_FILE})
84 target_include_directories(_casadi SYSTEM PRIVATE
85 ${python3Packages.python}/include/python3.${python3Packages.python.sourceVersion.minor})"
87 # I have no clue. without this, it tries to install a non existent file.
88 # maybe a run without SWIG_IMPORT is required before a run with SWIG_IMPORT.
89 # but we need SWIG_IMPORT at some point for something else TODO
90 substituteInPlace swig/python/CMakeLists.txt --replace-fail \
92 "if (NOT SWIG_IMPORT)"
94 + lib.optionalString stdenv.hostPlatform.isDarwin ''
95 # this is only printing stuff, and is not defined on all CPU
96 substituteInPlace casadi/interfaces/hpipm/hpipm_runtime.hpp --replace-fail \
97 "d_print_exp_tran_mat" \
98 "//d_print_exp_tran_mat"
100 # fix missing symbols
101 substituteInPlace cmake/FindCLANG.cmake --replace-fail \
103 "clangBasic clangASTMatchers clangSupport)"
106 nativeBuildInputs = [
127 llvmPackages.libclang
140 ++ lib.optionals withUnfree [
144 ++ lib.optionals pythonSupport [
145 python3Packages.numpy
146 python3Packages.python
148 ++ lib.optionals stdenv.hostPlatform.isDarwin [ llvmPackages.openmp ];
151 (lib.cmakeBool "WITH_PYTHON" pythonSupport)
152 (lib.cmakeBool "WITH_PYTHON3" pythonSupport)
153 # We don't mind always setting this cmake variable, it will be read only if
154 # pythonSupport is enabled.
155 "-DPYTHON_PREFIX=${placeholder "out"}/${python3Packages.python.sitePackages}"
156 (lib.cmakeBool "WITH_JSON" false)
157 (lib.cmakeBool "WITH_INSTALL_INTERNAL_HEADERS" true)
158 (lib.cmakeBool "INSTALL_INTERNAL_HEADERS" true)
159 (lib.cmakeBool "ENABLE_EXPORT_ALL" true)
160 (lib.cmakeBool "SWIG_EXPORT" true)
161 (lib.cmakeBool "SWIG_IMPORT" false)
162 (lib.cmakeBool "WITH_OPENMP" true)
163 (lib.cmakeBool "WITH_THREAD" true)
164 (lib.cmakeBool "WITH_OPENCL" false)
165 (lib.cmakeBool "WITH_BUILD_SUNDIALS" true) # ref. https://github.com/casadi/casadi/issues/2125
166 (lib.cmakeBool "WITH_SUNDIALS" true)
167 (lib.cmakeBool "WITH_BUILD_CSPARSE" false)
168 (lib.cmakeBool "WITH_CSPARSE" true)
169 (lib.cmakeBool "WITH_BLASFEO" true)
170 (lib.cmakeBool "WITH_HPIPM" true)
171 (lib.cmakeBool "WITH_FATROP" true)
172 (lib.cmakeBool "WITH_BUILD_FATROP" false)
173 (lib.cmakeBool "WITH_SUPERSCS" false) # packaging too chaotic
174 (lib.cmakeBool "WITH_BUILD_OSQP" false)
175 (lib.cmakeBool "WITH_OSQP" true)
176 (lib.cmakeBool "WITH_PROXQP" true)
177 (lib.cmakeBool "WITH_BUILD_TINYXML" false)
178 (lib.cmakeBool "WITH_TINYXML" true)
179 (lib.cmakeBool "WITH_BUILD_DSDP" true) # not sure where this come from
180 (lib.cmakeBool "WITH_DSDP" true)
181 (lib.cmakeBool "WITH_CLANG" true)
182 (lib.cmakeBool "WITH_LAPACK" true)
183 (lib.cmakeBool "WITH_QPOASES" true)
184 (lib.cmakeBool "WITH_BLOCKSQP" true)
185 (lib.cmakeBool "WITH_SLEQP" true)
186 (lib.cmakeBool "WITH_IPOPT" true)
187 (lib.cmakeBool "WITH_KNITRO" withUnfree)
188 (lib.cmakeBool "WITH_SNOPT" withUnfree)
189 (lib.cmakeBool "WITH_WORHP" withUnfree)
190 (lib.cmakeBool "WITH_CPLEX" withUnfree)
191 (lib.cmakeBool "WITH_GUROBI" withUnfree)
192 (lib.cmakeBool "WITH_BONMIN" true)
193 (lib.cmakeBool "WITH_CBC" true)
194 (lib.cmakeBool "WITH_CLP" true)
195 (lib.cmakeBool "WITH_MUMPS" true)
196 (lib.cmakeBool "WITH_SPRAL" true)
197 (lib.cmakeBool "WITH_HSL" withUnfree)
198 (lib.cmakeBool "WITH_HIGHS" true)
199 #(lib.cmakeBool "WITH_ALPAQA" true) # this requires casadi...
205 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";
206 homepage = "https://github.com/casadi/casadi";
207 license = lib.licenses.lgpl3Only;
208 maintainers = with lib.maintainers; [ nim65s ];
209 platforms = lib.platforms.all;