Skip to content

Commit 73582b3

Browse files
committed
cmake: Enable soplex when building SCIP
1 parent 8da2248 commit 73582b3

File tree

5 files changed

+415
-53
lines changed

5 files changed

+415
-53
lines changed

CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,19 @@ message(STATUS "Build PDLP: ${BUILD_PDLP}")
296296
CMAKE_DEPENDENT_OPTION(USE_SCIP "Use the Scip solver" ON "BUILD_CXX" OFF)
297297
message(STATUS "SCIP support: ${USE_SCIP}")
298298
if(USE_SCIP)
299+
CMAKE_DEPENDENT_OPTION(BUILD_Boost "Build the Boost dependency Library" OFF
300+
"NOT BUILD_DEPS" ON)
301+
CMAKE_DEPENDENT_OPTION(BUILD_soplex "Build the Soplex dependency Library" OFF
302+
"NOT BUILD_DEPS" ON)
299303
CMAKE_DEPENDENT_OPTION(BUILD_SCIP "Build the SCIP dependency Library" OFF
300304
"NOT BUILD_DEPS" ON)
301305
else()
306+
set(BUILD_Boost OFF)
307+
set(BUILD_soplex OFF)
302308
set(BUILD_SCIP OFF)
303309
endif()
310+
message(STATUS "Build Boost (Soplex requirement): ${BUILD_Boost}")
311+
message(STATUS "Build Soplex (SCIP requirement): ${BUILD_soplex}")
304312
message(STATUS "Build SCIP: ${BUILD_SCIP}")
305313

306314
# Optional third party solvers (disabled by default)

cmake/dependencies/CMakeLists.txt

+64-11
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,21 @@ endif()
7878
if(BUILD_absl)
7979
message(CHECK_START "Fetching Abseil-cpp")
8080
list(APPEND CMAKE_MESSAGE_INDENT " ")
81-
set(ABSL_ENABLE_INSTALL ON)
8281
set(ABSL_USE_SYSTEM_INCLUDES ON)
82+
# We want Abseil to declare what C++ standard it was compiled with.
8383
set(ABSL_PROPAGATE_CXX_STD ON)
84+
# We want Abseil to keep the INSTALL rules enabled, even though it is a
85+
# subproject. Otherwise the install rules in this project break.
86+
set(ABSL_ENABLE_INSTALL ON)
8487
set(ABSL_BUILD_TESTING OFF)
8588
FetchContent_Declare(
8689
absl
8790
GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
8891
GIT_TAG "20250127.0"
8992
GIT_SHALLOW TRUE
90-
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/abseil-cpp-20250127.0.patch"
93+
PATCH_COMMAND git apply --ignore-whitespace
94+
"${CMAKE_CURRENT_LIST_DIR}/../../patches/abseil-cpp-20250127.0.patch"
95+
OVERRIDE_FIND_PACKAGE
9196
)
9297
FetchContent_MakeAvailable(absl)
9398
list(POP_BACK CMAKE_MESSAGE_INDENT)
@@ -259,12 +264,68 @@ if(BUILD_HIGHS)
259264
message(CHECK_PASS "fetched")
260265
endif()
261266

267+
# ##############################################################################
268+
# BOOST
269+
# ##############################################################################
270+
if(BUILD_Boost)
271+
message(CHECK_START "Fetching Boost")
272+
list(APPEND CMAKE_MESSAGE_INDENT " ")
273+
FetchContent_Declare(
274+
Boost
275+
URL
276+
https://github.com/boostorg/boost/releases/download/boost-1.87.0/boost-1.87.0-cmake.tar.gz
277+
USES_TERMINAL_DOWNLOAD TRUE
278+
DOWNLOAD_NO_EXTRACT FALSE
279+
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/boost-1.87.0.patch"
280+
)
281+
set(BOOST_INCLUDE_LIBRARIES multiprecision serialization)
282+
option(BOOST_SKIP_INSTALL_RULES NO)
283+
set(BOOST_ENABLE_CMAKE ON)
284+
FetchContent_MakeAvailable(Boost)
285+
list(POP_BACK CMAKE_MESSAGE_INDENT)
286+
message(CHECK_PASS "fetched")
287+
endif()
288+
289+
# ##############################################################################
290+
# SOPLEX
291+
# ##############################################################################
292+
if(BUILD_soplex)
293+
message(CHECK_START "Fetching SOPLEX")
294+
list(APPEND CMAKE_MESSAGE_INDENT " ")
295+
FetchContent_Declare(
296+
soplex
297+
GIT_REPOSITORY "https://github.com/scipopt/soplex.git"
298+
GIT_TAG "release-713"
299+
GIT_SHALLOW TRUE
300+
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/soplex-v7.1.3.patch"
301+
)
302+
set(SHARED OFF)
303+
set(ZLIB ON CACHE BOOL "Soplex param" FORCE)
304+
set(GMP OFF CACHE BOOL "Soplex param" FORCE)
305+
set(PAPILO OFF CACHE BOOL "Soplex param" FORCE)
306+
set(BOOST ON CACHE BOOL "Soplex param" FORCE)
307+
set(QUADMATH OFF CACHE BOOL "Soplex param" FORCE)
308+
set(MPFR OFF CACHE BOOL "Soplex param" FORCE)
309+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON CACHE BOOL "Soplex param" FORCE)
310+
set(Boost_INCLUDE_DIR "../boost-src/libs/config/include" CACHE PATH "Soplex param" FORCE)
311+
FetchContent_MakeAvailable(SOPLEX)
312+
list(POP_BACK CMAKE_MESSAGE_INDENT)
313+
message(CHECK_PASS "fetched")
314+
endif()
315+
262316
# ##############################################################################
263317
# SCIP
264318
# ##############################################################################
265319
if(BUILD_SCIP)
266320
message(CHECK_START "Fetching SCIP")
267321
list(APPEND CMAKE_MESSAGE_INDENT " ")
322+
FetchContent_Declare(
323+
scip
324+
GIT_REPOSITORY "https://github.com/scipopt/scip.git"
325+
GIT_TAG "v921"
326+
GIT_SHALLOW TRUE
327+
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/scip-v921.patch"
328+
)
268329
set(SHARED OFF)
269330
set(READLINE OFF)
270331
set(GMP OFF)
@@ -275,17 +336,9 @@ if(BUILD_SCIP)
275336

276337
set(TPI "tny" CACHE STRING "Scip param")
277338
set(EXPRINT "none" CACHE STRING "Scip param")
278-
set(LPS "none" CACHE STRING "Scip param")
339+
set(LPS "spx" CACHE STRING "Scip param")
279340
set(SYM "none" CACHE STRING "Scip param")
280-
FetchContent_Declare(
281-
scip
282-
GIT_REPOSITORY "https://github.com/scipopt/scip.git"
283-
GIT_TAG "v921"
284-
GIT_SHALLOW TRUE
285-
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/scip-v921.patch"
286-
)
287341
FetchContent_MakeAvailable(scip)
288-
set(LPI_GLOP_SRC ${scip_SOURCE_DIR}/src/lpi/lpi_glop.cpp PARENT_SCOPE)
289342
list(POP_BACK CMAKE_MESSAGE_INDENT)
290343
message(CHECK_PASS "fetched")
291344
endif()

patches/boost-1.87.0.patch

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff -ru a/tools/cmake/include/BoostInstall.cmake b/tools/cmake/include/BoostInstall.cmake
2+
--- a/tools/cmake/include/BoostInstall.cmake 2024-12-12 00:43:08.000000000 +0100
3+
+++ b/tools/cmake/include/BoostInstall.cmake 2025-03-03 13:11:00.310140710 +0100
4+
@@ -306,7 +306,7 @@
5+
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
6+
)
7+
8+
- export(TARGETS ${LIB} NAMESPACE Boost:: FILE export/${LIB}-targets.cmake)
9+
+ #export(TARGETS ${LIB} NAMESPACE Boost:: FILE export/${LIB}-targets.cmake)
10+
11+
if(MSVC)
12+
if(TYPE STREQUAL "SHARED_LIBRARY")

patches/scip-v921.patch

+116-42
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,119 @@
1-
diff --git a/src/lpi/lpi_glop.cpp b/src/lpi/lpi_glop.cpp
2-
index a90120188a..2c068e5e30 100644
3-
--- a/src/lpi/lpi_glop.cpp
4-
+++ b/src/lpi/lpi_glop.cpp
5-
@@ -51,7 +51,6 @@
6-
#include "ortools/util/time_limit.h"
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 8492dc75..70d7dd21 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -412,22 +412,11 @@ endif()
6+
#search the selected LP solver library
7+
message(STATUS "Finding Solver \"${LPS}\"")
8+
if(LPS STREQUAL "spx")
9+
- message(STATUS "Finding Soplex")
10+
- find_package(SOPLEX CONFIG HINTS ${SOPLEX_DIR})
11+
- if(NOT SOPLEX_FOUND)
12+
- # Utilities to automatically download missing dependencies
13+
- include(cmake/Dependencies.cmake)
14+
- find_or_download_package(
15+
- NAME SOPLEX
16+
- VERSION 7.0.1
17+
- URL https://github.com/scipopt/soplex/archive/refs/tags/release-701.tar.gz
18+
- URL_HASH SHA256=80cce994dcbe45fd52b60e31a3aeb5d2c60a7ddbaae495e0ce6bf58481675696
19+
- COMPONENTS soplex)
20+
- find_package(SOPLEX REQUIRED CONFIG HINTS _deps/local)
21+
- endif()
22+
- if(NOT SOPLEX_FOUND)
23+
+ message(STATUS "Finding Soplex...")
24+
+ if(NOT TARGET libsoplex-pic OR NOT TARGET libsoplex)
25+
message(FATAL_ERROR "Requested LP solver SoPlex not found.")
26+
endif()
27+
+ set(SOPLEX_FOUND TRUE)
28+
if (DEFINED SOPLEX_WITH_PAPILO)
29+
message(STATUS "SOPLEX links PAPILO")
30+
if((NOT SCIP_WITH_PAPILO)) # TODO not sure how to handle AUTOBUILD
31+
@@ -502,9 +491,9 @@ if(SOPLEX_FOUND)
32+
message(STATUS "Finding SOPLEX - found")
33+
# SoPlex headers can be directly included
34+
include_directories(${SOPLEX_INCLUDE_DIRS})
35+
- set(LPS_LIBRARIES ${SOPLEX_LIBRARIES})
36+
+ set(LPS_LIBRARIES libsoplex)
37+
if(SHARED)
38+
- set(LPS_PIC_LIBRARIES ${SOPLEX_PIC_LIBRARIES})
39+
+ set(LPS_PIC_LIBRARIES libsoplex-pic)
40+
else()
41+
set(LPS_PIC_LIBRARIES ${LPS_LIBRARIES})
42+
endif()
43+
@@ -514,7 +503,7 @@ if(SOPLEX_FOUND)
44+
set(lpi lpi/lpi_spx2.cpp)
45+
endif()
46+
else()
47+
- message(STATUS "Support SOPLEX: OFF")
48+
+ message(FATAL_ERROR "SOPLEX not found !")
49+
endif()
750

8-
#include "ortools/base/logging.h"
9-
-#include "ortools/base/vlog_is_on.h"
51+
if(CLP_FOUND)
52+
diff --git a/scip-config.cmake.in b/scip-config.cmake.in
53+
index 559552f9..682ac40a 100644
54+
--- a/scip-config.cmake.in
55+
+++ b/scip-config.cmake.in
56+
@@ -1,17 +1,16 @@
57+
if(NOT TARGET libscip)
58+
- include("${CMAKE_CURRENT_LIST_DIR}/scip-targets.cmake")
59+
-endif()
60+
+ include(CMakeFindDependencyMacro)
61+
+ if(@ZIMPL_NEEDED@)
62+
+ find_dependency(ZIMPL REQUIRED NO_MODULE)
63+
+ endif()
64+
+ if(@SOPLEX_NEEDED@)
65+
+ find_dependency(SOPLEX REQUIRED NO_MODULE)
66+
+ endif()
1067

11-
#include "lpi/lpi.h"
12-
#include "scip/pub_message.h"
13-
@@ -2942,12 +2941,12 @@ SCIP_RETCODE SCIPlpiSetIntpar(
14-
SCIPdebugMessage("SCIPlpiSetIntpar: SCIP_LPPAR_LPINFO -> %d.\n", ival);
15-
if ( ival == 0 )
16-
{
17-
- (void) google::SetVLOGLevel("*", google::GLOG_INFO);
18-
+ absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
19-
lpi->lp_info = false;
20-
}
21-
else
22-
{
23-
- (void) google::SetVLOGLevel("*", google::GLOG_ERROR);
24-
+ absl::SetStderrThreshold(absl::LogSeverityAtLeast::kError);
25-
lpi->lp_info = true;
26-
}
27-
break;
28-
@@ -3190,7 +3189,7 @@ SCIP_RETCODE SCIPlpiReadLP(
68+
-if(@ZIMPL_NEEDED@)
69+
- set(ZIMPL_DIR "@CONF_ZIMPL_DIR@")
70+
- find_package(ZIMPL QUIET CONFIG)
71+
-endif()
72+
-
73+
-if(@SOPLEX_NEEDED@)
74+
- set(SOPLEX_DIR "@CONF_SOPLEX_DIR@")
75+
- find_package(SOPLEX QUIET CONFIG)
76+
+ include("${CMAKE_CURRENT_LIST_DIR}/scip-targets.cmake")
77+
endif()
78+
79+
+# Legacy
80+
set(SCIP_LIBRARIES libscip)
81+
set(SCIP_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
82+
set(SCIP_FOUND TRUE)
83+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
84+
index e6fda2d5..bbc55db1 100644
85+
--- a/src/CMakeLists.txt
86+
+++ b/src/CMakeLists.txt
87+
@@ -1149,17 +1149,8 @@ install(TARGETS scip libscip EXPORT scip-targets
88+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
89+
90+
# Add all targets to the build-tree export set
91+
-export(TARGETS scip libscip
92+
- FILE "${PROJECT_BINARY_DIR}/scip-targets.cmake")
93+
-
94+
-# make soplex and zimpl dir absolute for the config file
95+
-if(SOPLEX_NEEDED)
96+
- get_filename_component(CONF_SOPLEX_DIR ${SOPLEX_DIR} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR})
97+
-endif()
98+
-
99+
-if(ZIMPL_NEEDED)
100+
- get_filename_component(CONF_ZIMPL_DIR ${ZIMPL_DIR} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR})
101+
-endif()
102+
+#export(TARGETS scip libscip
103+
+# FILE "${PROJECT_BINARY_DIR}/scip-targets.cmake")
104+
105+
# configure the config file for the build tree
106+
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}")
107+
@@ -1175,12 +1166,6 @@ ${PROJECT_BINARY_DIR}/scip-config-version.cmake
108+
109+
#configure the config file for the install
110+
set(CONF_INCLUDE_DIRS "\${CMAKE_CURRENT_LIST_DIR}/../../../include")
111+
-if(SOPLEX_NEEDED)
112+
- set(CONF_SOPLEX_DIR "\${CMAKE_CURRENT_LIST_DIR}/../soplex")
113+
-endif()
114+
-if(ZIMPL_NEEDED)
115+
- set(CONF_ZIMPL_DIR "\${CMAKE_CURRENT_LIST_DIR}/../zimpl")
116+
-endif()
117+
configure_file(${PROJECT_SOURCE_DIR}/scip-config.cmake.in
118+
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/scip-config.cmake" @ONLY)
29119

30-
const std::string filespec(fname);
31-
MPModelProto proto;
32-
- if ( ! ReadFileToProto(filespec, &proto) )
33-
+ if ( ! ReadFileToProto(filespec, &proto).ok() )
34-
{
35-
SCIPerrorMessage("Could not read <%s>\n", fname);
36-
return SCIP_READERROR;
37-
@@ -3214,7 +3213,7 @@ SCIP_RETCODE SCIPlpiWriteLP(
38-
MPModelProto proto;
39-
LinearProgramToMPModelProto(*lpi->linear_program, &proto);
40-
const std::string filespec(fname);
41-
- if ( ! WriteProtoToFile(filespec, proto, operations_research::ProtoWriteFormat::kProtoText, true) )
42-
+ if ( ! WriteProtoToFile(filespec, proto, operations_research::ProtoWriteFormat::kProtoText, true).ok() )
43-
{
44-
SCIPerrorMessage("Could not write <%s>\n", fname);
45-
return SCIP_READERROR;

0 commit comments

Comments
 (0)