scs 0.5.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/LICENSE.txt +1 -1
  4. data/lib/scs/ffi.rb +18 -0
  5. data/lib/scs/solver.rb +11 -7
  6. data/lib/scs/version.rb +1 -1
  7. data/vendor/scs/CITATION.cff +2 -3
  8. data/vendor/scs/CLAUDE.md +115 -0
  9. data/vendor/scs/CMakeLists.txt +330 -201
  10. data/vendor/scs/CONTRIBUTING.md +49 -0
  11. data/vendor/scs/Makefile +90 -43
  12. data/vendor/scs/README.md +96 -2
  13. data/vendor/scs/include/aa.h +59 -11
  14. data/vendor/scs/include/aa_stats.h +47 -0
  15. data/vendor/scs/include/cones.h +16 -7
  16. data/vendor/scs/include/glbopts.h +113 -26
  17. data/vendor/scs/include/linalg.h +5 -1
  18. data/vendor/scs/include/linsys.h +1 -2
  19. data/vendor/scs/include/normalize.h +6 -2
  20. data/vendor/scs/include/rw.h +9 -3
  21. data/vendor/scs/include/scs.h +17 -1
  22. data/vendor/scs/include/scs_blas.h +8 -0
  23. data/vendor/scs/include/scs_types.h +2 -2
  24. data/vendor/scs/include/scs_work.h +22 -1
  25. data/vendor/scs/include/util.h +3 -6
  26. data/vendor/scs/include/util_spectral_cones.h +3 -3
  27. data/vendor/scs/linsys/accelerate/direct/private.c +126 -0
  28. data/vendor/scs/linsys/accelerate/direct/private.h +34 -0
  29. data/vendor/scs/linsys/cpu/dense/private.c +250 -0
  30. data/vendor/scs/linsys/cpu/dense/private.h +31 -0
  31. data/vendor/scs/linsys/cpu/direct/private.c +86 -44
  32. data/vendor/scs/linsys/cpu/indirect/private.c +647 -113
  33. data/vendor/scs/linsys/cpu/indirect/private.h +28 -0
  34. data/vendor/scs/linsys/csparse.c +9 -3
  35. data/vendor/scs/linsys/csparse.h +4 -2
  36. data/vendor/scs/linsys/cudss/direct/private.c +77 -43
  37. data/vendor/scs/linsys/cudss/direct/private.h +33 -7
  38. data/vendor/scs/linsys/gpu/indirect/private.c +6 -2
  39. data/vendor/scs/linsys/mkl/direct/private.c +63 -31
  40. data/vendor/scs/linsys/mkl/direct/private.h +0 -1
  41. data/vendor/scs/linsys/scs_matrix.c +291 -165
  42. data/vendor/scs/linsys/scs_matrix.h +7 -9
  43. data/vendor/scs/scs.mk +35 -13
  44. data/vendor/scs/src/aa.c +673 -166
  45. data/vendor/scs/src/cones.c +545 -223
  46. data/vendor/scs/src/ctrlc.c +59 -16
  47. data/vendor/scs/src/exp_cone.c +70 -50
  48. data/vendor/scs/src/linalg.c +21 -2
  49. data/vendor/scs/src/normalize.c +24 -26
  50. data/vendor/scs/src/rw.c +596 -124
  51. data/vendor/scs/src/scs.c +990 -513
  52. data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_IPM.c +240 -187
  53. data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_Newton.c +108 -85
  54. data/vendor/scs/src/spectral_cones/logdeterminant/log_cone_wrapper.c +62 -63
  55. data/vendor/scs/src/spectral_cones/logdeterminant/logdet_cone.c +85 -78
  56. data/vendor/scs/src/spectral_cones/nuclear/ell1_cone.c +92 -97
  57. data/vendor/scs/src/spectral_cones/nuclear/nuclear_cone.c +39 -28
  58. data/vendor/scs/src/spectral_cones/sum-largest/sum_largest_cone.c +59 -40
  59. data/vendor/scs/src/spectral_cones/sum-largest/sum_largest_eval_cone.c +37 -29
  60. data/vendor/scs/src/spectral_cones/util_spectral_cones.c +12 -6
  61. data/vendor/scs/src/util.c +37 -7
  62. data/vendor/scs/test/mkl_interface_mismatch.c +97 -0
  63. data/vendor/scs/test/packaging/CMakeLists.txt +21 -0
  64. data/vendor/scs/test/packaging/consume.c +50 -0
  65. data/vendor/scs/test/problem_utils.h +9 -2
  66. data/vendor/scs/test/problems/dense_qp.h +64 -0
  67. data/vendor/scs/test/problems/hs21_tiny_qp.h +6 -2
  68. data/vendor/scs/test/problems/hs21_tiny_qp_rw.h +10 -2
  69. data/vendor/scs/test/problems/infeasible_lp.h +66 -0
  70. data/vendor/scs/test/problems/infeasible_socp.h +75 -0
  71. data/vendor/scs/test/problems/lp_update.h +110 -0
  72. data/vendor/scs/test/problems/qafiro_tiny_qp.h +3 -1
  73. data/vendor/scs/test/problems/rob_gauss_cov_est.h +6 -3
  74. data/vendor/scs/test/problems/small_qp.h +5 -0
  75. data/vendor/scs/test/problems/test_box_cone.h +92 -0
  76. data/vendor/scs/test/problems/test_dual_exp_cone.h +96 -0
  77. data/vendor/scs/test/problems/test_inaccurate.h +212 -0
  78. data/vendor/scs/test/problems/test_mixed_cones.h +113 -0
  79. data/vendor/scs/test/problems/test_normalize_roundtrip.h +279 -0
  80. data/vendor/scs/test/problems/test_power_cone.h +414 -0
  81. data/vendor/scs/test/problems/test_psd_metric.h +109 -0
  82. data/vendor/scs/test/problems/test_psd_n1.h +84 -0
  83. data/vendor/scs/test/problems/test_root_plus.h +191 -0
  84. data/vendor/scs/test/problems/test_rw_settings.h +112 -0
  85. data/vendor/scs/test/problems/test_soc_sizes.h +393 -0
  86. data/vendor/scs/test/problems/test_solver_options.h +558 -0
  87. data/vendor/scs/test/problems/test_validation.h +263 -24
  88. data/vendor/scs/test/problems/test_zero_cone.h +81 -0
  89. data/vendor/scs/test/problems/unbounded_lp.h +66 -0
  90. data/vendor/scs/test/problems/unbounded_socp.h +71 -0
  91. data/vendor/scs/test/run_from_file.c +6 -0
  92. data/vendor/scs/test/run_tests.c +71 -0
  93. data/vendor/scs/test/rw_settings.c +7 -0
  94. data/vendor/scs/test/spectral_cones_problems/test_ell1_and_nuc.h +128 -0
  95. data/vendor/scs/test/spectral_cones_problems/test_ell1_cone.h +115 -0
  96. metadata +35 -3
@@ -1,24 +1,24 @@
1
1
  # CMakeLists.txt file for scs. This software may be modified and distributed
2
2
  # under the terms of the MIT License
3
3
 
4
- cmake_minimum_required(VERSION 3.5)
4
+ # 3.22: FindLAPACK honors BLA_SIZEOF_INTEGER (the LP64/ILP64 contract) and
5
+ # provides the LAPACK::LAPACK target that keeps static packages relocatable.
6
+ cmake_minimum_required(VERSION 3.22)
5
7
 
6
8
  project(
7
9
  scs
8
10
  LANGUAGES C
9
- VERSION 3.2.11)
11
+ VERSION 3.3.1)
10
12
 
11
- # Defines the CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR and many other useful
12
- # macros. See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
13
+ # ABI version, the loader identity of the shared libraries (libscsdir.so.3.3):
14
+ # bump on ABI breaks, never on patch releases. scs.mk derives the same value
15
+ # from SCS_VERSION in include/glbopts.h.
16
+ set(SCS_ABI_VERSION "${scs_VERSION_MAJOR}.${scs_VERSION_MINOR}")
17
+
18
+ # Standard GNU install directories (lib, bin, include, etc.)
13
19
  include(GNUInstallDirs)
14
20
 
15
- # Control where libraries and executables are placed during the build. With the
16
- # following settings executables are placed in <the top level of the build
17
- # tree>/bin and libraries/archives in <top level of the build tree>/lib. This is
18
- # particularly useful to run ctests on libraries built on Windows machines:
19
- # tests, which are executables, are placed in the same folders of dlls, which
20
- # are treated as executables as well, so that they can properly find the
21
- # libraries to run. This is a because of missing RPATH on Windows.
21
+ # Place executables in bin/ and libraries in lib/ within the build tree.
22
22
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
23
23
  "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
24
24
  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
@@ -26,45 +26,34 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
26
26
  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
27
27
  "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
28
28
 
29
- # To build shared libraries in Windows, we set CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
30
- # to TRUE. See
31
- # https://cmake.org/cmake/help/v3.4/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS.html
32
- # See
33
- # https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/
29
+ # Export all symbols on Windows (avoids __declspec(dllexport) annotations).
34
30
  set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
35
31
 
36
- # Under MSVC, we set CMAKE_DEBUG_POSTFIX to "d" to add a trailing "d" to library
37
- # built in debug mode. In this Windows user can compile, build and install the
38
- # library in both Release and Debug configuration avoiding naming clashes in the
39
- # installation directories.
32
+ # Append "d" suffix to debug libraries under MSVC to avoid name clashes.
40
33
  if(MSVC)
41
34
  set(CMAKE_DEBUG_POSTFIX "d")
42
35
  endif()
43
36
 
44
- # Build position independent code. Position Independent Code (PIC) is commonly
45
- # used for shared libraries so that the same shared library code can be loaded
46
- # in each program address space in a location where it will not overlap with any
47
- # other uses of such memory. In particular, this option avoids problems
48
- # occurring when a process wants to load more than one shared library at the
49
- # same virtual address. Since shared libraries cannot predict where other shared
50
- # libraries could be loaded, this is an unavoidable problem with the traditional
51
- # shared library concept. Generating position-independent code is often the
52
- # default behavior for most modern compilers. Moreover linking a static library
53
- # that is not built with PIC from a shared library will fail on some
54
- # compiler/architecture combinations. Further details on PIC can be found here:
55
- # https://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/
37
+ # Position-independent code is required for shared libraries.
56
38
  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
57
39
 
58
- # Disable C and C++ compiler extensions. C/CXX_EXTENSIONS are ON by default to
59
- # allow the compilers to use extended variants of the C/CXX language. However,
60
- # this could expose cross-platform bugs in user code or in the headers of
61
- # third-party dependencies and thus it is strongly suggested to turn extensions
62
- # off.
40
+ # Disable compiler extensions for strict standard compliance.
41
+ # Strict C99, the oldest standard a shipping consumer compiles scs with (the
42
+ # MATLAB binding uses -std=c99): GNU-only constructs fail here first.
43
+ set(CMAKE_C_STANDARD 99)
44
+ set(CMAKE_C_STANDARD_REQUIRED ON)
63
45
  set(CMAKE_C_EXTENSIONS OFF)
46
+ # Strict C99 hides POSIX declarations on glibc and illumos (sigaction,
47
+ # clock_gettime, struct timespec) unless a feature-test macro asks for them.
48
+ # A compile definition reaches every translation unit whatever its include
49
+ # order, which a header cannot guarantee.
50
+ if(CMAKE_SYSTEM_NAME MATCHES "Linux|SunOS")
51
+ add_compile_definitions(_POSIX_C_SOURCE=200809L)
52
+ endif()
53
+
64
54
  set(CMAKE_CXX_EXTENSIONS OFF)
65
55
  list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
66
56
 
67
- # Options Shared/Dynamic or Static library?
68
57
  option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)
69
58
 
70
59
  # Enable RPATH support for installed binaries and libraries
@@ -78,8 +67,7 @@ add_install_rpath_support(
78
67
  "${CMAKE_INSTALL_FULL_LIBDIR}"
79
68
  USE_LINK_PATH)
80
69
 
81
- # Encourage user to specify a build type (e.g. Release, Debug, etc.), otherwise
82
- # set it to Release.
70
+ # Default to Release build type if none specified.
83
71
  if(NOT CMAKE_CONFIGURATION_TYPES)
84
72
  if(NOT CMAKE_BUILD_TYPE)
85
73
  message(STATUS "Setting build type to 'Release' as none was specified.")
@@ -87,115 +75,187 @@ if(NOT CMAKE_CONFIGURATION_TYPES)
87
75
  endif()
88
76
  endif()
89
77
 
90
- # Build test related commands?
91
78
  option(BUILD_TESTING "Create tests using CMake" OFF)
92
79
  if(BUILD_TESTING)
93
80
  enable_testing()
94
81
  endif()
95
82
 
96
- # Add uninstall target After 'make install' can run 'make uninstall' to remove.
83
+ # Support 'make uninstall' after install.
97
84
  include(AddUninstallTarget)
98
85
 
99
- # Some variables useful for sampling the building process. Note that the GPU
100
- # profile is not compiled.
86
+ # Linear system solver directories.
101
87
  set(LINSYS linsys)
102
88
  set(DIRSRC ${LINSYS}/cpu/direct)
103
89
  set(INDIRSRC ${LINSYS}/cpu/indirect)
104
90
  set(EXTERNAL ${LINSYS}/external)
105
91
 
106
- # Options
107
- # ----------------------------------------------
108
- # Use floats instead of doubles
92
+ # Build options
109
93
  option(SFLOAT "Use single precision floats rather than doubles" OFF)
110
94
  message(STATUS "Single precision floats (32bit) are ${SFLOAT}")
111
95
 
112
- # Use long integers for indexing
113
96
  option(DLONG "Use long integers (64bit) for indexing" OFF)
114
97
  message(STATUS "Long integers (64bit) are ${DLONG}")
115
98
 
116
- # Disable all printing
117
99
  option(NO_PRINTING "Disables all printing" OFF)
118
100
  message(STATUS "Printing is NOT ${NO_PRINTING}")
119
101
 
120
- # Disable all read/write functionality
121
102
  option(NO_READ_WRITE "Disables all read/write functionality" OFF)
122
103
  message(STATUS "Read/write functionality is NOT ${NO_READ_WRITE}")
123
104
 
124
105
  option(USE_LAPACK "Whether to use BLAS/LAPACK" ON)
125
106
  message(STATUS "BLAS/LAPACK usage is ${USE_LAPACK}")
126
107
 
127
- # spectral cones
108
+ option(BLAS64 "Use 64-bit integers for BLAS/LAPACK" OFF)
109
+ message(STATUS "64-bit BLAS integers are ${BLAS64}")
110
+
128
111
  option(USE_SPECTRAL_CONES "Whether to use spectral cones (requires LAPACK)" OFF)
129
112
  if(USE_SPECTRAL_CONES AND NOT USE_LAPACK)
130
113
  message(FATAL_ERROR "USE_SPECTRAL_CONES requires USE_LAPACK to be ON")
131
114
  endif()
132
115
 
133
- # Enable OpenMP support
134
116
  option(USE_OPENMP "Compile with OpenMP support" OFF)
135
117
  message(STATUS "OpenMP parallelization is ${USE_OPENMP}")
136
118
 
137
- # Enable cuDSS support
138
119
  option(USE_CUDSS "Compile with cuDSS support" OFF)
139
120
  message(STATUS "cuDSS support is ${USE_CUDSS}")
140
121
 
141
- set(COMPILER_OPTS "-DCTRLC")
122
+ if(APPLE)
123
+ option(USE_APPLE_ACCELERATE "Use Apple Accelerate framework for sparse LDLt" OFF)
124
+ message(STATUS "Apple Accelerate support is ${USE_APPLE_ACCELERATE}")
125
+ endif()
126
+
127
+ set(COMPILER_OPTS CTRLC)
142
128
  set(LAPACK_LINK_LIBRARIES "")
129
+ set(SCS_TEST_LINK_LIBRARIES "")
130
+ if(NOT WIN32)
131
+ list(APPEND SCS_TEST_LINK_LIBRARIES m)
132
+ endif()
143
133
 
144
134
  # Primitive types
145
135
  if(SFLOAT)
146
136
  set(SCS_FLOAT_TYPE "float")
147
- set(COMPILER_OPTS "-DSFLOAT ${COMPILER_OPTS}")
137
+ list(APPEND COMPILER_OPTS SFLOAT)
148
138
  else()
149
139
  set(SCS_FLOAT_TYPE "double")
150
140
  endif()
151
141
 
152
142
  if(DLONG)
153
143
  set(SCS_INT_TYPE "long long")
154
- set(COMPILER_OPTS "-DDLONG ${COMPILER_OPTS}")
144
+ list(APPEND COMPILER_OPTS DLONG)
155
145
  else()
156
146
  set(SCS_INT_TYPE "int")
157
147
  endif()
158
148
 
159
149
  if(NO_PRINTING)
160
- set(COMPILER_OPTS "-DNO_PRINTING=1 ${COMPILER_OPTS}")
150
+ list(APPEND COMPILER_OPTS NO_PRINTING=1)
161
151
  endif()
162
152
 
163
153
  if(NO_READ_WRITE)
164
- set(COMPILER_OPTS "-DNO_READ_WRITE=1 ${COMPILER_OPTS}")
154
+ list(APPEND COMPILER_OPTS NO_READ_WRITE=1)
165
155
  endif()
166
156
 
167
157
  if(USE_LAPACK)
168
- set(COMPILER_OPTS "-DUSE_LAPACK ${COMPILER_OPTS}")
169
- list(APPEND LAPACK_LINK_LIBRARIES "blas" "lapack")
158
+ list(APPEND COMPILER_OPTS USE_LAPACK)
159
+ if(BLAS64)
160
+ list(APPEND COMPILER_OPTS BLAS64)
161
+ set(BLA_SIZEOF_INTEGER 8)
162
+ else()
163
+ set(BLA_SIZEOF_INTEGER 4)
164
+ endif()
165
+ if(DEFINED ENV{MKLROOT} AND NOT DEFINED BLA_VENDOR)
166
+ if(BLAS64)
167
+ set(BLA_VENDOR Intel10_64ilp)
168
+ else()
169
+ set(BLA_VENDOR Intel10_64lp)
170
+ endif()
171
+ endif()
172
+ find_package(LAPACK)
173
+ if(LAPACK_FOUND)
174
+ # Link the imported target, not resolved paths: a static library exports
175
+ # its private link line, and absolute provider paths would make the
176
+ # installed package usable only on this machine.
177
+ set(LAPACK_LINK_LIBRARIES LAPACK::LAPACK)
178
+ else()
179
+ if(BLAS64)
180
+ message(FATAL_ERROR
181
+ "BLAS64=ON requires a discoverable ILP64 BLAS/LAPACK library. "
182
+ "CMake did not find one. Set BLA_VENDOR explicitly or configure "
183
+ "with -DBLAS64=OFF.")
184
+ endif()
185
+ # Fallback to linking by name (works on most Linux/Mac systems).
186
+ set(LAPACK_LINK_LIBRARIES blas lapack)
187
+ endif()
170
188
  endif()
171
189
 
190
+ find_package(Threads REQUIRED)
191
+
172
192
  if(USE_OPENMP)
173
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
193
+ find_package(OpenMP)
194
+ if(OpenMP_C_FOUND)
195
+ # Link target used below via target_link_libraries.
196
+ else()
197
+ message(WARNING "OpenMP requested but not found by CMake")
198
+ endif()
174
199
  endif()
175
200
 
176
- # Flags for spectral cones.
177
201
  if(USE_SPECTRAL_CONES)
178
- set(COMPILER_OPTS "-DUSE_SPECTRAL_CONES ${COMPILER_OPTS}")
202
+ list(APPEND COMPILER_OPTS USE_SPECTRAL_CONES)
179
203
  endif()
180
204
 
205
+ option(USE_SPECTRAL_TIMING_FLAG "Enable timing of spectral cone projections" OFF)
181
206
  if(USE_SPECTRAL_TIMING_FLAG)
182
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSPECTRAL_TIMING_FLAG")
207
+ list(APPEND COMPILER_OPTS SPECTRAL_TIMING_FLAG)
183
208
  endif()
184
209
 
210
+ option(USE_SPECTRAL_DEBUG "Enable spectral cone debug output" OFF)
185
211
  if(USE_SPECTRAL_DEBUG)
186
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSPECTRAL_DEBUG")
212
+ list(APPEND COMPILER_OPTS SPECTRAL_DEBUG)
187
213
  endif()
188
214
 
189
215
  message(STATUS "COMPILER_OPTS = ${COMPILER_OPTS}")
190
216
  message(STATUS "CMAKE_C_FLAGS = ${CMAKE_C_FLAGS}")
191
217
 
192
- # TODO this is a hack that overwrites the scs_types.h file, we should find a way
193
- # to do this that doesn't pollute the master directory.
218
+ # Generate a build-tree include overlay so CMake configuration never modifies
219
+ # the checked-in Make-compatible headers.
220
+ set(SCS_BUILD_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include")
221
+ set(SCS_GENERATED_TYPES_HDR "${SCS_BUILD_INCLUDE_DIR}/scs_types.h")
222
+ file(MAKE_DIRECTORY "${SCS_BUILD_INCLUDE_DIR}")
194
223
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/scs_types.h.in
195
- ${CMAKE_CURRENT_SOURCE_DIR}/include/scs_types.h NEWLINE_STYLE LF)
224
+ ${SCS_GENERATED_TYPES_HDR} NEWLINE_STYLE LF)
225
+
226
+ set(SCS_CONFIGURED_INCLUDE_HDR
227
+ include/aa.h
228
+ include/aa_stats.h
229
+ include/cones.h
230
+ include/ctrlc.h
231
+ include/glbopts.h
232
+ include/linalg.h
233
+ include/linsys.h
234
+ include/normalize.h
235
+ include/rw.h
236
+ include/scs.h
237
+ include/scs_blas.h
238
+ include/scs_work.h
239
+ include/util.h
240
+ include/util_spectral_cones.h)
241
+
242
+ set(SCS_BUILD_INCLUDE_HDR "")
243
+ foreach(_scs_header ${SCS_CONFIGURED_INCLUDE_HDR})
244
+ get_filename_component(_scs_header_name "${_scs_header}" NAME)
245
+ set(_scs_build_header "${SCS_BUILD_INCLUDE_DIR}/${_scs_header_name}")
246
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${_scs_header}"
247
+ "${_scs_build_header}" COPYONLY)
248
+ list(APPEND SCS_BUILD_INCLUDE_HDR "${_scs_build_header}")
249
+ endforeach()
196
250
 
197
251
  # Public headers
198
- set(${PROJECT_NAME}_PUBLIC_HDR include/scs_types.h include/scs.h)
252
+ set(${PROJECT_NAME}_PUBLIC_HDR
253
+ "${SCS_BUILD_INCLUDE_DIR}/aa_stats.h"
254
+ "${SCS_GENERATED_TYPES_HDR}"
255
+ "${SCS_BUILD_INCLUDE_DIR}/scs.h")
256
+ set(SCS_PUBLIC_INCLUDE_DIRS
257
+ "$<BUILD_INTERFACE:${SCS_BUILD_INCLUDE_DIR}>"
258
+ "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
199
259
 
200
260
  # Common source files
201
261
  set(${PROJECT_NAME}_SRC
@@ -231,40 +291,24 @@ endif()
231
291
 
232
292
  # Common header files
233
293
  set(${PROJECT_NAME}_HDR
234
- include/aa.h
235
- include/cones.h
236
- include/ctrlc.h
237
- include/glbopts.h
238
- include/linalg.h
239
- include/linsys.h
240
- include/normalize.h
241
- include/rw.h
242
- include/scs.h
243
- include/scs_blas.h
244
- include/scs_types.h
245
- include/scs_work.h
246
- include/util.h
294
+ ${SCS_BUILD_INCLUDE_HDR}
295
+ ${SCS_GENERATED_TYPES_HDR}
247
296
  ${LINSYS}/csparse.h
248
297
  ${LINSYS}/scs_matrix.h)
249
298
 
250
299
  # Spectral header files
251
- set(SPECTRAL_HDR include/util_spectral_cones.h)
300
+ set(SPECTRAL_HDR "${SCS_BUILD_INCLUDE_DIR}/util_spectral_cones.h")
252
301
 
253
302
  if(USE_SPECTRAL_CONES)
254
303
  list(APPEND ${PROJECT_NAME}_HDR ${SPECTRAL_HDR})
255
304
  endif()
256
305
 
257
- # get all the c file in amd/external
306
+ # External vendored dependencies (AMD ordering, QDLDL factorization).
258
307
  file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_SRC ${EXTERNAL}/amd/*.c)
259
-
260
- # get all the h file in amd/external
261
308
  file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_HDR ${EXTERNAL}/amd/*.h)
262
-
263
- # get all the c file in amd/external
264
309
  file(GLOB ${PROJECT_NAME}_LDL_EXTERNAL_HDR ${EXTERNAL}/qdldl/*.h)
265
310
 
266
- # ##############################################################################
267
- # Direct method. Here we compile the direct method library.
311
+ # Direct method library.
268
312
  set(${PROJECT_NAME}_DIRECT ${PROJECT_NAME}dir)
269
313
  add_library(
270
314
  ${${PROJECT_NAME}_DIRECT}
@@ -285,25 +329,24 @@ target_include_directories(
285
329
 
286
330
  target_include_directories(
287
331
  ${${PROJECT_NAME}_DIRECT}
288
- PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
289
- "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
332
+ PUBLIC ${SCS_PUBLIC_INCLUDE_DIRS})
290
333
 
291
- # Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
292
334
  target_compile_definitions(${${PROJECT_NAME}_DIRECT} PRIVATE ${COMPILER_OPTS})
293
335
 
294
- # The library depends on math (m) and (optionally) blas and lapack
295
336
  target_link_libraries(${${PROJECT_NAME}_DIRECT}
296
- PRIVATE m ${LAPACK_LINK_LIBRARIES})
337
+ PRIVATE ${LAPACK_LINK_LIBRARIES}
338
+ $<$<NOT:$<PLATFORM_ID:Windows>>:m>
339
+ $<$<BOOL:${OpenMP_C_FOUND}>:OpenMP::OpenMP_C>
340
+ Threads::Threads)
297
341
 
298
- # Set some properties
299
342
  set_target_properties(
300
343
  ${${PROJECT_NAME}_DIRECT}
301
- PROPERTIES VERSION ${scs_VERSION} PUBLIC_HEADER
344
+ PROPERTIES VERSION ${scs_VERSION} SOVERSION ${SCS_ABI_VERSION}
345
+ PUBLIC_HEADER
302
346
  "${${PROJECT_NAME}_PUBLIC_HDR}")
303
347
 
304
348
  add_library(scs::${${PROJECT_NAME}_DIRECT} ALIAS ${${PROJECT_NAME}_DIRECT})
305
349
 
306
- # Install the library
307
350
  install(
308
351
  TARGETS ${${PROJECT_NAME}_DIRECT}
309
352
  EXPORT ${PROJECT_NAME}
@@ -313,12 +356,9 @@ install(
313
356
  RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
314
357
  PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
315
358
 
316
- # Add the direct method to the set of the compiled targets
317
359
  set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_DIRECT})
318
360
 
319
- # ##############################################################################
320
-
321
- # Indirect method. Here we compile the indirect method library.
361
+ # Indirect method library.
322
362
  set(${PROJECT_NAME}_INDIRECT ${PROJECT_NAME}indir)
323
363
  add_library(
324
364
  ${${PROJECT_NAME}_INDIRECT}
@@ -333,26 +373,25 @@ target_include_directories(
333
373
 
334
374
  target_include_directories(
335
375
  ${${PROJECT_NAME}_INDIRECT}
336
- PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
337
- "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
376
+ PUBLIC ${SCS_PUBLIC_INCLUDE_DIRS})
338
377
 
339
- # Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
340
378
  target_compile_definitions(${${PROJECT_NAME}_INDIRECT} PRIVATE ${COMPILER_OPTS}
341
379
  -DINDIRECT)
342
380
 
343
- # The library depends on math (m) and (optionally) blas and lapack
344
381
  target_link_libraries(${${PROJECT_NAME}_INDIRECT}
345
- PUBLIC m ${LAPACK_LINK_LIBRARIES})
382
+ PRIVATE $<$<NOT:$<PLATFORM_ID:Windows>>:m>
383
+ ${LAPACK_LINK_LIBRARIES}
384
+ $<$<BOOL:${OpenMP_C_FOUND}>:OpenMP::OpenMP_C>
385
+ Threads::Threads)
346
386
 
347
- # Set some properties
348
387
  set_target_properties(
349
388
  ${${PROJECT_NAME}_INDIRECT}
350
- PROPERTIES VERSION ${scs_VERSION} PUBLIC_HEADER
389
+ PROPERTIES VERSION ${scs_VERSION} SOVERSION ${SCS_ABI_VERSION}
390
+ PUBLIC_HEADER
351
391
  "${${PROJECT_NAME}_PUBLIC_HDR}")
352
392
 
353
393
  add_library(scs::${${PROJECT_NAME}_INDIRECT} ALIAS ${${PROJECT_NAME}_INDIRECT})
354
394
 
355
- # Install the library
356
395
  install(
357
396
  TARGETS ${${PROJECT_NAME}_INDIRECT}
358
397
  EXPORT ${PROJECT_NAME}
@@ -362,20 +401,71 @@ install(
362
401
  RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
363
402
  PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
364
403
 
365
- # Add the indirect method to the set of the compiled targets
366
404
  set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_INDIRECT})
367
405
 
368
- # ##############################################################################
406
+ # Dense direct method library (optional, requires LAPACK).
407
+ if(USE_LAPACK)
408
+ set(DENSESRC ${LINSYS}/cpu/dense)
409
+
410
+ set(${PROJECT_NAME}_DENSE ${PROJECT_NAME}dense)
411
+ add_library(
412
+ ${${PROJECT_NAME}_DENSE}
413
+ ${${PROJECT_NAME}_HDR} ${${PROJECT_NAME}_SRC} ${DENSESRC}/private.c
414
+ ${DENSESRC}/private.h)
415
+
416
+ target_include_directories(
417
+ ${${PROJECT_NAME}_DENSE}
418
+ PRIVATE
419
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${DENSESRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
420
+ )
421
+
422
+ target_include_directories(
423
+ ${${PROJECT_NAME}_DENSE}
424
+ PUBLIC ${SCS_PUBLIC_INCLUDE_DIRS})
425
+
426
+ target_compile_definitions(${${PROJECT_NAME}_DENSE} PRIVATE ${COMPILER_OPTS})
427
+
428
+ target_link_libraries(${${PROJECT_NAME}_DENSE}
429
+ PRIVATE ${LAPACK_LINK_LIBRARIES}
430
+ $<$<NOT:$<PLATFORM_ID:Windows>>:m>
431
+ $<$<BOOL:${OpenMP_C_FOUND}>:OpenMP::OpenMP_C>
432
+ Threads::Threads)
433
+
434
+ set_target_properties(
435
+ ${${PROJECT_NAME}_DENSE}
436
+ PROPERTIES VERSION ${scs_VERSION} SOVERSION ${SCS_ABI_VERSION}
437
+ PUBLIC_HEADER
438
+ "${${PROJECT_NAME}_PUBLIC_HDR}")
439
+
440
+ add_library(scs::${${PROJECT_NAME}_DENSE} ALIAS ${${PROJECT_NAME}_DENSE})
441
+
442
+ install(
443
+ TARGETS ${${PROJECT_NAME}_DENSE}
444
+ EXPORT ${PROJECT_NAME}
445
+ COMPONENT runtime
446
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
447
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
448
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
449
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
450
+
451
+ set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_DENSE})
452
+ endif()
369
453
 
370
- # If MKLROOT is defined, then we install the MKL version.
454
+ # MKL Pardiso library (optional, requires MKLROOT environment variable).
371
455
  if(DEFINED ENV{MKLROOT})
372
456
 
373
457
  message(STATUS "MKLROOT set to $ENV{MKLROOT}")
374
458
  message(STATUS "Will install SCS-MKL (libscsmkl).")
375
459
 
460
+ if(BLAS64 AND NOT DLONG)
461
+ message(FATAL_ERROR
462
+ "MKL PARDISO with BLAS64 requires DLONG=ON so that the "
463
+ "pardiso_64 entry point matches the ILP64 BLAS interface.")
464
+ endif()
465
+
376
466
  set(MKLSRC ${LINSYS}/mkl/direct)
377
467
 
378
- # Here we compile the direct MKL pardiso library
468
+ # MKL Pardiso direct solver library
379
469
  set(${PROJECT_NAME}_MKL ${PROJECT_NAME}mkl)
380
470
  add_library(
381
471
  ${${PROJECT_NAME}_MKL}
@@ -390,35 +480,41 @@ if(DEFINED ENV{MKLROOT})
390
480
 
391
481
  target_include_directories(
392
482
  ${${PROJECT_NAME}_MKL}
393
- PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
394
- "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
395
-
396
- target_compile_definitions(${${PROJECT_NAME}_MKL} PRIVATE ${COMPILER_OPTS})
397
- # See:
398
- # https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html
399
- # This is probably not correct for other systems. TODO: make SCS-MKL work for
400
- # all combinations of platform / compiler / threading options.
401
- target_link_options(${${PROJECT_NAME}_MKL} PRIVATE "LINKER:--no-as-needed")
402
- target_link_directories(${${PROJECT_NAME}_MKL} PRIVATE $ENV{MKLROOT}/lib)
483
+ PUBLIC ${SCS_PUBLIC_INCLUDE_DIRS})
484
+
485
+ target_compile_definitions(
486
+ ${${PROJECT_NAME}_MKL}
487
+ PRIVATE ${COMPILER_OPTS} SCS_MKL)
488
+ # Link against mkl_rt (the single dynamic library) which dispatches to the
489
+ # correct interface layer at runtime. The BLAS integer width (LP64 vs ILP64)
490
+ # is set at startup by the MKL-specific path in src/scs.c, controlled by the
491
+ # BLAS64 compile flag.
492
+ #
493
+ # Note: The PARDISO integer width (pardiso vs pardiso_64) is controlled by
494
+ # DLONG, not by the MKL interface layer. See linsys/mkl/direct/private.c.
495
+ # oneMKL's own package config (MKLConfig.cmake, oneMKL >= 2021.3) provides
496
+ # the MKL::MKL target, which keeps a static export relocatable; SDL mode
497
+ # links the single dynamic library (mkl_rt) whose MKL_Set_Interface_Layer
498
+ # the runtime check uses. --no-as-needed keeps mkl_rt as DT_NEEDED for that
499
+ # check; it is a GNU/ELF option, hence Linux only.
500
+ set(MKL_LINK sdl)
501
+ find_package(MKL CONFIG REQUIRED PATHS "$ENV{MKLROOT}")
502
+ set(SCS_MKL_USES_CONFIG TRUE)
503
+ target_link_options(${${PROJECT_NAME}_MKL} PRIVATE
504
+ "$<$<PLATFORM_ID:Linux>:LINKER:--no-as-needed>")
403
505
  target_link_libraries(
404
506
  ${${PROJECT_NAME}_MKL}
405
- PRIVATE m
406
- mkl_rt
407
- mkl_gnu_thread
408
- mkl_core
409
- gomp
410
- pthread
411
- dl)
412
-
413
- # Set some properties
507
+ PRIVATE $<$<NOT:$<PLATFORM_ID:Windows>>:m> MKL::MKL Threads::Threads
508
+ ${CMAKE_DL_LIBS})
509
+
414
510
  set_target_properties(
415
511
  ${${PROJECT_NAME}_MKL}
416
- PROPERTIES VERSION ${scs_VERSION} PUBLIC_HEADER
512
+ PROPERTIES VERSION ${scs_VERSION} SOVERSION ${SCS_ABI_VERSION}
513
+ PUBLIC_HEADER
417
514
  "${${PROJECT_NAME}_PUBLIC_HDR}")
418
515
 
419
516
  add_library(scs::${${PROJECT_NAME}_MKL} ALIAS ${${PROJECT_NAME}_MKL})
420
517
 
421
- # Install the library
422
518
  install(
423
519
  TARGETS ${${PROJECT_NAME}_MKL}
424
520
  EXPORT ${PROJECT_NAME}
@@ -428,7 +524,6 @@ if(DEFINED ENV{MKLROOT})
428
524
  RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
429
525
  PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
430
526
 
431
- # Add the mkl method to the set of the compiled targets
432
527
  set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_MKL})
433
528
  else()
434
529
  message(
@@ -436,10 +531,7 @@ else()
436
531
  )
437
532
  endif()
438
533
 
439
- # ##############################################################################
440
-
441
- # If cuDSS is enabled and environment variables are set, install the cuDSS
442
- # version
534
+ # cuDSS GPU solver library (optional, requires CUDA toolkit and cuDSS).
443
535
  if(USE_CUDSS)
444
536
  find_package(CUDAToolkit REQUIRED)
445
537
  find_package(cudss REQUIRED)
@@ -456,7 +548,6 @@ if(USE_CUDSS)
456
548
 
457
549
  set(CUDSSSRC ${LINSYS}/cudss/direct)
458
550
 
459
- # Here we compile the direct cuDSS library
460
551
  set(${PROJECT_NAME}_CUDSS ${PROJECT_NAME}cudss)
461
552
  add_library(
462
553
  ${${PROJECT_NAME}_CUDSS} ${${PROJECT_NAME}_HDR} ${${PROJECT_NAME}_SRC}
@@ -470,25 +561,24 @@ if(USE_CUDSS)
470
561
 
471
562
  target_include_directories(
472
563
  ${${PROJECT_NAME}_CUDSS}
473
- PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
474
- "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
564
+ PUBLIC ${SCS_PUBLIC_INCLUDE_DIRS})
475
565
 
476
566
  target_compile_definitions(${${PROJECT_NAME}_CUDSS} PRIVATE ${COMPILER_OPTS})
477
567
 
478
568
  target_link_libraries(
479
569
  ${${PROJECT_NAME}_CUDSS}
480
570
  PRIVATE CUDA::cudart cudss $<$<NOT:$<PLATFORM_ID:Windows>>:m>
481
- ${LAPACK_LINK_LIBRARIES})
571
+ ${LAPACK_LINK_LIBRARIES}
572
+ Threads::Threads)
482
573
 
483
- # Set some properties
484
574
  set_target_properties(
485
575
  ${${PROJECT_NAME}_CUDSS}
486
- PROPERTIES VERSION ${scs_VERSION} PUBLIC_HEADER
576
+ PROPERTIES VERSION ${scs_VERSION} SOVERSION ${SCS_ABI_VERSION}
577
+ PUBLIC_HEADER
487
578
  "${${PROJECT_NAME}_PUBLIC_HDR}")
488
579
 
489
580
  add_library(scs::${${PROJECT_NAME}_CUDSS} ALIAS ${${PROJECT_NAME}_CUDSS})
490
581
 
491
- # Install the library
492
582
  install(
493
583
  TARGETS ${${PROJECT_NAME}_CUDSS}
494
584
  EXPORT ${PROJECT_NAME}
@@ -498,13 +588,75 @@ if(USE_CUDSS)
498
588
  RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
499
589
  PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
500
590
 
501
- # Add the cuDSS method to the set of the compiled targets
502
591
  set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_CUDSS})
503
592
  endif()
504
593
 
505
- # ##############################################################################
506
- # Install the .cmake file. It is possible to link scs o consumer libraries.
594
+ # Apple Accelerate library (optional, macOS only).
595
+ if(APPLE AND USE_APPLE_ACCELERATE)
596
+ if(DLONG)
597
+ message(
598
+ FATAL_ERROR
599
+ "Apple Accelerate requires 32-bit integers. Set DLONG=OFF or do not use -DDLONG=ON"
600
+ )
601
+ endif()
602
+
603
+ message(STATUS "Will install SCS-Accelerate (libscsaccel).")
604
+
605
+ set(ACCELSRC ${LINSYS}/accelerate/direct)
606
+
607
+ set(${PROJECT_NAME}_ACCEL ${PROJECT_NAME}accel)
608
+ add_library(
609
+ ${${PROJECT_NAME}_ACCEL}
610
+ ${${PROJECT_NAME}_HDR} ${${PROJECT_NAME}_SRC} ${ACCELSRC}/private.c
611
+ ${ACCELSRC}/private.h)
612
+
613
+ target_include_directories(
614
+ ${${PROJECT_NAME}_ACCEL}
615
+ PRIVATE
616
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${ACCELSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
617
+ )
618
+
619
+ target_include_directories(
620
+ ${${PROJECT_NAME}_ACCEL}
621
+ PUBLIC ${SCS_PUBLIC_INCLUDE_DIRS})
622
+
623
+ target_compile_definitions(${${PROJECT_NAME}_ACCEL} PRIVATE ${COMPILER_OPTS})
624
+
625
+ find_library(ACCELERATE_FRAMEWORK Accelerate REQUIRED)
626
+ target_link_libraries(
627
+ ${${PROJECT_NAME}_ACCEL}
628
+ PRIVATE ${ACCELERATE_FRAMEWORK}
629
+ $<$<BOOL:${OpenMP_C_FOUND}>:OpenMP::OpenMP_C>
630
+ Threads::Threads)
631
+
632
+ set_target_properties(
633
+ ${${PROJECT_NAME}_ACCEL}
634
+ PROPERTIES VERSION ${scs_VERSION} SOVERSION ${SCS_ABI_VERSION}
635
+ PUBLIC_HEADER
636
+ "${${PROJECT_NAME}_PUBLIC_HDR}")
637
+
638
+ add_library(scs::${${PROJECT_NAME}_ACCEL} ALIAS ${${PROJECT_NAME}_ACCEL})
639
+
640
+ install(
641
+ TARGETS ${${PROJECT_NAME}_ACCEL}
642
+ EXPORT ${PROJECT_NAME}
643
+ COMPONENT runtime
644
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
645
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
646
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
647
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
648
+
649
+ set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_ACCEL})
650
+ endif()
651
+
652
+ # Install CMake package config files for find_package(scs) support.
507
653
  include(InstallBasicPackageFiles)
654
+ # The config template re-finds a static library's private dependencies at the
655
+ # LAPACK integer width scs was built with; see cmake/scsConfig.cmake.in.
656
+ set(SCS_LAPACK_INT_BYTES "")
657
+ if(USE_LAPACK AND LAPACK_FOUND)
658
+ set(SCS_LAPACK_INT_BYTES "${BLA_SIZEOF_INTEGER}")
659
+ endif()
508
660
  install_basic_package_files(
509
661
  ${PROJECT_NAME}
510
662
  NAMESPACE
@@ -517,68 +669,45 @@ install_basic_package_files(
517
669
  SameMajorVersion
518
670
  VARS_PREFIX
519
671
  ${PROJECT_NAME}
672
+ CONFIG_TEMPLATE
673
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/scsConfig.cmake.in"
520
674
  NO_CHECK_REQUIRED_COMPONENTS_MACRO)
521
675
 
522
- # Add the tests
676
+ # Tests
523
677
  if(BUILD_TESTING)
524
- add_executable(run_tests_direct test/run_tests.c)
525
- target_compile_definitions(run_tests_direct PRIVATE ${COMPILER_OPTS})
526
- target_link_libraries(run_tests_direct PRIVATE scs::scsdir)
527
- target_include_directories(
528
- run_tests_direct
529
- PRIVATE
530
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
531
- )
532
-
533
- add_test(
534
- NAME run_tests_direct
535
- COMMAND run_tests_direct
536
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
537
-
538
- add_executable(run_tests_indirect test/run_tests.c)
539
- target_compile_definitions(run_tests_indirect PRIVATE ${COMPILER_OPTS})
540
- target_link_libraries(run_tests_indirect PRIVATE scs::scsindir)
541
- target_include_directories(
542
- run_tests_indirect
543
- PRIVATE
544
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
545
- )
546
-
547
- add_test(
548
- NAME run_tests_indirect
549
- COMMAND run_tests_indirect
550
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
551
-
552
- if(DEFINED ENV{MKLROOT})
553
- add_executable(run_tests_mkl test/run_tests.c)
554
- target_compile_definitions(run_tests_mkl PRIVATE ${COMPILER_OPTS})
555
- target_link_libraries(run_tests_mkl PRIVATE scs::scsmkl)
678
+ # Helper to avoid repeating test boilerplate for each backend.
679
+ function(scs_add_test TEST_NAME LINK_TARGET)
680
+ add_executable(${TEST_NAME} test/run_tests.c)
681
+ target_compile_definitions(${TEST_NAME} PRIVATE ${COMPILER_OPTS})
682
+ target_link_libraries(${TEST_NAME} PRIVATE ${LINK_TARGET}
683
+ ${SCS_TEST_LINK_LIBRARIES})
556
684
  target_include_directories(
557
- run_tests_mkl
685
+ ${TEST_NAME}
558
686
  PRIVATE
559
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
687
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${SCS_BUILD_INCLUDE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
560
688
  )
561
-
562
689
  add_test(
563
- NAME run_tests_mkl
564
- COMMAND run_tests_mkl
690
+ NAME ${TEST_NAME}
691
+ COMMAND ${TEST_NAME}
565
692
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
693
+ endfunction()
694
+
695
+ scs_add_test(run_tests_direct scs::scsdir)
696
+ scs_add_test(run_tests_indirect scs::scsindir)
697
+
698
+ if(USE_LAPACK)
699
+ scs_add_test(run_tests_dense scs::scsdense)
566
700
  endif()
567
701
 
568
- if(USE_CUDSS)
569
- add_executable(run_tests_cudss test/run_tests.c)
570
- target_compile_definitions(run_tests_cudss PRIVATE ${COMPILER_OPTS})
571
- target_link_libraries(run_tests_cudss PRIVATE scs::scscudss)
572
- target_include_directories(
573
- run_tests_cudss
574
- PRIVATE
575
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
576
- )
702
+ if(DEFINED ENV{MKLROOT})
703
+ scs_add_test(run_tests_mkl scs::scsmkl)
704
+ endif()
577
705
 
578
- add_test(
579
- NAME run_tests_cudss
580
- COMMAND run_tests_cudss
581
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
706
+ if(USE_CUDSS)
707
+ scs_add_test(run_tests_cudss scs::scscudss)
582
708
  endif()
583
709
 
710
+ if(APPLE AND USE_APPLE_ACCELERATE)
711
+ scs_add_test(run_tests_accelerate scs::scsaccel)
712
+ endif()
584
713
  endif()