From f3615ea5db4f0ac1a024479af460b4e223b8a117 Mon Sep 17 00:00:00 2001 From: fettgoenner Date: Mon, 15 Dec 2025 13:06:19 +0100 Subject: [PATCH] or-tools: fix compatibility with SCIP 10 --- pkgs/by-name/or/or-tools/gscip-scip10.patch | 15 ++++ pkgs/by-name/or/or-tools/package.nix | 15 +++- pkgs/by-name/or/or-tools/scip.patch | 98 +++++++-------------- 3 files changed, 59 insertions(+), 69 deletions(-) create mode 100644 pkgs/by-name/or/or-tools/gscip-scip10.patch diff --git a/pkgs/by-name/or/or-tools/gscip-scip10.patch b/pkgs/by-name/or/or-tools/gscip-scip10.patch new file mode 100644 index 000000000000..529cb39632bb --- /dev/null +++ b/pkgs/by-name/or/or-tools/gscip-scip10.patch @@ -0,0 +1,15 @@ +--- a/ortools/gscip/gscip.cc ++++ b/ortools/gscip/gscip.cc +@@ -48,7 +48,13 @@ + #include "scip/cons_indicator.h" + #include "scip/cons_linear.h" + #include "scip/cons_or.h" ++#if SCIP_VERSION_MAJOR >= 10 ++#include "scip/cons_nonlinear.h" ++#define SCIPcreateConsBasicQuadratic SCIPcreateConsBasicQuadraticNonlinear ++#define SCIPcreateConsQuadratic SCIPcreateConsQuadraticNonlinear ++#else + #include "scip/cons_quadratic.h" ++#endif // SCIP_VERSION_MAJOR >= 10 + #include "scip/cons_sos1.h" + #include "scip/cons_sos2.h" diff --git a/pkgs/by-name/or/or-tools/package.nix b/pkgs/by-name/or/or-tools/package.nix index f5260e0ac88e..e84496913785 100644 --- a/pkgs/by-name/or/or-tools/package.nix +++ b/pkgs/by-name/or/or-tools/package.nix @@ -64,12 +64,13 @@ let scipopt-scip' = scipopt-scip.overrideAttrs (old: { patches = old.patches or [ ] ++ [ # from https://github.com/google/or-tools/commit/77a28070b9c4c83995ac6bbfa9544722ff3342ce#diff-c95174a817e73db366d414af1e329c1856f70e5158ed3994d43da88765ccc98f - ./scip.patch + ./scip.patch # https://github.com/google/or-tools/pull/4932/files#diff-e6b0a69b2e4b97ec922abc459d909483d440a1e0d2868bed263927b106b6efe6 ]; + # message(STATUS "Finding Soplex") # Their patch forgets to find_package() soplex, bring it back. postPatch = (old.postPatch or "") + '' substituteInPlace CMakeLists.txt \ - --replace-fail 'message(STATUS "Finding Soplex...")' 'find_package(SOPLEX CONFIG HINTS ''${SOPLEX_DIR})' + --replace-fail 'message(STATUS "Finding Soplex")' 'find_package(SOPLEX CONFIG HINTS ''${SOPLEX_DIR})' ''; }); @@ -112,6 +113,16 @@ stdenv.mkDerivation (finalAttrs: { includes = [ "ortools/math_opt/solvers/highs_solver_test.cc" ]; hash = "sha256-/dFk/F/3/BwH5IwIwNU4Ua+4sROPXYCjO8R6jpoZpgo="; }) + # Fix compatibility with SCIP 10.0 + # https://github.com/google/or-tools/issues/4912 + (fetchpatch { + url = "https://github.com/google/or-tools/pull/4932.patch"; + includes = [ "ortools/linear_solver/proto_solver/scip_proto_solver.cc" ]; + hash = "sha256-1jw/r3yAjIpq9o8mqAbNorQgmT1E5nt809N+Gb+D9ZI="; + }) + # Compatibility with SCIP 10.0 also needs the following patch adjusted for or-tools 9.14 + # https://github.com/google/or-tools/pull/4932/files#diff-9559febee3c6051bab4def3c102cb78cbf8a57fc2be4058ace32f89436c784a9 + ./gscip-scip10.patch ]; # or-tools normally attempts to build Protobuf for the build platform when diff --git a/pkgs/by-name/or/or-tools/scip.patch b/pkgs/by-name/or/or-tools/scip.patch index 7a92254118b6..dbb153101564 100644 --- a/pkgs/by-name/or/or-tools/scip.patch +++ b/pkgs/by-name/or/or-tools/scip.patch @@ -1,8 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 8492dc75..4c12a9bf 100644 +index b3c57799..eeeca4c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -38,9 +38,11 @@ set(CPACK_PACKAGE_VENDOR "Zuse Institute Berlin") +@@ -52,9 +52,11 @@ set(CPACK_PACKAGE_VENDOR "Zuse Institute Berlin") set(CPACK_PACKAGE_CONTACT "http://scipopt.org") include(CPack) @@ -17,25 +17,12 @@ index 8492dc75..4c12a9bf 100644 if(SCIPOptSuite_BINARY_DIR) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SCIPOptSuite_BINARY_DIR}/bin) -@@ -412,22 +414,11 @@ endif() - #search the selected LP solver library +@@ -517,10 +519,10 @@ endif() message(STATUS "Finding Solver \"${LPS}\"") if(LPS STREQUAL "spx") -- message(STATUS "Finding Soplex") -- find_package(SOPLEX CONFIG HINTS ${SOPLEX_DIR}) + message(STATUS "Finding Soplex") +- find_package(SOPLEX REQUIRED CONFIG HINTS ${SOPLEX_DIR}) - if(NOT SOPLEX_FOUND) -- # Utilities to automatically download missing dependencies -- include(cmake/Dependencies.cmake) -- find_or_download_package( -- NAME SOPLEX -- VERSION 7.0.1 -- URL https://github.com/scipopt/soplex/archive/refs/tags/release-701.tar.gz -- URL_HASH SHA256=80cce994dcbe45fd52b60e31a3aeb5d2c60a7ddbaae495e0ce6bf58481675696 -- COMPONENTS soplex) -- find_package(SOPLEX REQUIRED CONFIG HINTS _deps/local) -- endif() -- if(NOT SOPLEX_FOUND) -+ message(STATUS "Finding Soplex...") + if(NOT TARGET libsoplex-pic OR NOT TARGET libsoplex) message(FATAL_ERROR "Requested LP solver SoPlex not found.") endif() @@ -43,64 +30,41 @@ index 8492dc75..4c12a9bf 100644 if (DEFINED SOPLEX_WITH_PAPILO) message(STATUS "SOPLEX links PAPILO") if((NOT SCIP_WITH_PAPILO)) # TODO not sure how to handle AUTOBUILD -@@ -502,9 +493,9 @@ if(SOPLEX_FOUND) +@@ -593,11 +595,11 @@ if(SOPLEX_FOUND) message(STATUS "Finding SOPLEX - found") # SoPlex headers can be directly included include_directories(${SOPLEX_INCLUDE_DIRS}) - set(LPS_LIBRARIES ${SOPLEX_LIBRARIES}) +- set(LPS_PIC_LIBRARIES ${SOPLEX_PIC_LIBRARIES}) + set(LPS_LIBRARIES libsoplex) - if(SHARED) -- set(LPS_PIC_LIBRARIES ${SOPLEX_PIC_LIBRARIES}) -+ set(LPS_PIC_LIBRARIES libsoplex-pic) - else() - set(LPS_PIC_LIBRARIES ${LPS_LIBRARIES}) - endif() -@@ -514,7 +505,7 @@ if(SOPLEX_FOUND) - set(lpi lpi/lpi_spx2.cpp) - endif() ++ set(LPS_PIC_LIBRARIES libsoplex-pic) + set(lpi lpi/lpi_spx.cpp) else() - message(STATUS "Support SOPLEX: OFF") + message(FATAL_ERROR "SOPLEX not found !") endif() if(CLP_FOUND) -diff --git a/scip-config.cmake.in b/scip-config.cmake.in -index 559552f9..682ac40a 100644 ---- a/scip-config.cmake.in -+++ b/scip-config.cmake.in -@@ -1,17 +1,16 @@ - if(NOT TARGET libscip) -- include("${CMAKE_CURRENT_LIST_DIR}/scip-targets.cmake") --endif() -+ include(CMakeFindDependencyMacro) -+ if(@ZIMPL_NEEDED@) -+ find_dependency(ZIMPL REQUIRED NO_MODULE) -+ endif() -+ if(@SOPLEX_NEEDED@) -+ find_dependency(SOPLEX REQUIRED NO_MODULE) -+ endif() - --if(@ZIMPL_NEEDED@) -- set(ZIMPL_DIR "@CONF_ZIMPL_DIR@") -- find_package(ZIMPL QUIET CONFIG) --endif() -- --if(@SOPLEX_NEEDED@) -- set(SOPLEX_DIR "@CONF_SOPLEX_DIR@") -- find_package(SOPLEX QUIET CONFIG) -+ include("${CMAKE_CURRENT_LIST_DIR}/scip-targets.cmake") - endif() - -+# Legacy - set(SCIP_LIBRARIES libscip) - set(SCIP_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@") - set(SCIP_FOUND TRUE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index e6fda2d5..2d04b845 100644 +index c6ce7283..6b6b1fc8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt -@@ -1149,17 +1149,8 @@ install(TARGETS scip libscip EXPORT scip-targets - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +@@ -1213,6 +1213,13 @@ target_link_libraries(scip + add_dependencies(libscip scip_update_githash) + add_dependencies(scip scip_update_githash) + ++if(APPLE) ++ set_target_properties(libscip PROPERTIES ++ INSTALL_RPATH "@loader_path") ++elseif(UNIX) ++ set_target_properties(libscip PROPERTIES ++ INSTALL_RPATH "$ORIGIN") ++endif() + set_target_properties(libscip PROPERTIES + VERSION ${SCIP_VERSION_MAJOR}.${SCIP_VERSION_MINOR}.${SCIP_VERSION_PATCH} + SOVERSION ${SCIP_VERSION_MAJOR}.${SCIP_VERSION_MINOR} +@@ -1265,17 +1272,8 @@ install(FILES ${PROJECT_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_DATADIR} + install(FILES ${PROJECT_SOURCE_DIR}/src/tclique/LICENSE DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/scip/tclique) # Add all targets to the build-tree export set -export(TARGETS scip libscip @@ -117,11 +81,11 @@ index e6fda2d5..2d04b845 100644 +#export(TARGETS scip libscip +# FILE "${PROJECT_BINARY_DIR}/scip-targets.cmake") - # configure the config file for the build tree - set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}") -@@ -1175,18 +1166,16 @@ ${PROJECT_BINARY_DIR}/scip-config-version.cmake - - #configure the config file for the install + # Configure scip-config.cmake for the build-tree: + # We add the CMake module path from the sources. +@@ -1295,18 +1293,16 @@ ${PROJECT_BINARY_DIR}/scip-config-version.cmake + # We add the current directory of the installed scip-config.cmake as a CMake module path. + set(EXTRA_CMAKE_MODULE_PATH "\${CMAKE_CURRENT_LIST_DIR}") set(CONF_INCLUDE_DIRS "\${CMAKE_CURRENT_LIST_DIR}/../../../include") -if(SOPLEX_NEEDED) - set(CONF_SOPLEX_DIR "\${CMAKE_CURRENT_LIST_DIR}/../soplex")