scs 0.3.2 → 0.4.1

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +35 -6
  5. data/lib/scs/matrix.rb +72 -0
  6. data/lib/scs/solver.rb +19 -26
  7. data/lib/scs/version.rb +1 -1
  8. data/lib/scs.rb +1 -0
  9. data/vendor/scs/CITATION.cff +2 -2
  10. data/vendor/scs/CMakeLists.txt +285 -169
  11. data/vendor/scs/Makefile +43 -18
  12. data/vendor/scs/README.md +3 -1
  13. data/vendor/scs/include/cones.h +5 -3
  14. data/vendor/scs/include/glbopts.h +35 -17
  15. data/vendor/scs/include/linsys.h +8 -8
  16. data/vendor/scs/include/normalize.h +1 -0
  17. data/vendor/scs/include/rw.h +3 -3
  18. data/vendor/scs/include/scs.h +51 -24
  19. data/vendor/scs/include/scs_types.h +3 -1
  20. data/vendor/scs/include/scs_work.h +13 -15
  21. data/vendor/scs/include/util.h +4 -2
  22. data/vendor/scs/linsys/cpu/direct/private.c +32 -153
  23. data/vendor/scs/linsys/cpu/direct/private.h +6 -6
  24. data/vendor/scs/linsys/cpu/indirect/private.c +9 -22
  25. data/vendor/scs/linsys/cpu/indirect/private.h +4 -2
  26. data/vendor/scs/linsys/csparse.c +140 -12
  27. data/vendor/scs/linsys/csparse.h +10 -17
  28. data/vendor/scs/linsys/external/amd/LICENSE.txt +0 -897
  29. data/vendor/scs/linsys/external/amd/SuiteSparse_config.c +4 -2
  30. data/vendor/scs/linsys/external/amd/SuiteSparse_config.h +0 -5
  31. data/vendor/scs/linsys/gpu/gpu.c +4 -4
  32. data/vendor/scs/linsys/gpu/gpu.h +1 -1
  33. data/vendor/scs/linsys/gpu/indirect/private.c +15 -26
  34. data/vendor/scs/linsys/mkl/direct/private.c +182 -0
  35. data/vendor/scs/linsys/mkl/direct/private.h +38 -0
  36. data/vendor/scs/linsys/scs_matrix.c +49 -72
  37. data/vendor/scs/linsys/scs_matrix.h +4 -3
  38. data/vendor/scs/scs.mk +39 -30
  39. data/vendor/scs/src/aa.c +0 -4
  40. data/vendor/scs/src/cones.c +78 -184
  41. data/vendor/scs/src/exp_cone.c +399 -0
  42. data/vendor/scs/src/normalize.c +51 -0
  43. data/vendor/scs/src/rw.c +139 -76
  44. data/vendor/scs/src/scs.c +275 -202
  45. data/vendor/scs/src/util.c +36 -13
  46. data/vendor/scs/test/minunit.h +2 -1
  47. data/vendor/scs/test/problem_utils.h +5 -4
  48. data/vendor/scs/test/problems/degenerate.h +1 -0
  49. data/vendor/scs/test/problems/hs21_tiny_qp.h +2 -1
  50. data/vendor/scs/test/problems/hs21_tiny_qp_rw.h +13 -4
  51. data/vendor/scs/test/problems/infeasible_tiny_qp.h +1 -0
  52. data/vendor/scs/test/problems/max_ent +0 -0
  53. data/vendor/scs/test/problems/max_ent.h +8 -0
  54. data/vendor/scs/test/problems/qafiro_tiny_qp.h +2 -1
  55. data/vendor/scs/test/problems/random_prob.h +2 -39
  56. data/vendor/scs/test/problems/rob_gauss_cov_est.h +15 -3
  57. data/vendor/scs/test/problems/small_lp.h +4 -1
  58. data/vendor/scs/test/problems/small_qp.h +42 -7
  59. data/vendor/scs/test/problems/test_exp_cone.h +84 -0
  60. data/vendor/scs/test/problems/test_prob_from_data_file.h +57 -0
  61. data/vendor/scs/test/problems/test_validation.h +4 -1
  62. data/vendor/scs/test/problems/unbounded_tiny_qp.h +3 -3
  63. data/vendor/scs/test/random_socp_prob.c +3 -1
  64. data/vendor/scs/test/run_from_file.c +22 -4
  65. data/vendor/scs/test/run_tests.c +22 -9
  66. metadata +12 -4
@@ -1,30 +1,36 @@
1
- # CMakeLists.txt file for scs
2
- # This software may be modified and distributed under the terms of the MIT License
1
+ # CMakeLists.txt file for scs. This software may be modified and distributed
2
+ # under the terms of the MIT License
3
3
 
4
4
  cmake_minimum_required(VERSION 3.5)
5
5
 
6
- project(scs
6
+ project(
7
+ scs
7
8
  LANGUAGES C
8
- VERSION 3.1.1)
9
+ VERSION 3.2.3)
9
10
 
10
- # Defines the CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR and many other useful macros.
11
- # See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
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
12
13
  include(GNUInstallDirs)
13
14
 
14
- # Control where libraries and executables are placed during the build.
15
- # With the following settings executables are placed in <the top level of the
16
- # build tree>/bin and libraries/archives in <top level of the build tree>/lib.
17
- # This is particularly useful to run ctests on libraries built on Windows
18
- # machines: tests, which are executables, are placed in the same folders of
19
- # dlls, which are treated as executables as well, so that they can properly
20
- # find the libraries to run. This is a because of missing RPATH on Windows.
21
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
22
- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
23
- set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
24
-
25
- # To build shared libraries in Windows, we set CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS to TRUE.
26
- # See https://cmake.org/cmake/help/v3.4/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS.html
27
- # See https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/
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.
22
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
23
+ "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
24
+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
25
+ "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
26
+ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
27
+ "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
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/
28
34
  set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
29
35
 
30
36
  # Under MSVC, we set CMAKE_DEBUG_POSTFIX to "d" to add a trailing "d" to library
@@ -35,45 +41,45 @@ if(MSVC)
35
41
  set(CMAKE_DEBUG_POSTFIX "d")
36
42
  endif()
37
43
 
38
- # Build position independent code.
39
- # Position Independent Code (PIC) is commonly used for shared libraries so that
40
- # the same shared library code can be loaded in each program address space in a
41
- # location where it will not overlap with any other uses of such memory.
42
- # In particular, this option avoids problems occurring when a process wants to
43
- # load more than one shared library at the same virtual address.
44
- # Since shared libraries cannot predict where other shared libraries could be
45
- # loaded, this is an unavoidable problem with the traditional shared library
46
- # concept.
47
- # Generating position-independent code is often the default behavior for most
48
- # modern compilers.
49
- # Moreover linking a static library that is not built with PIC from a shared
50
- # library will fail on some compiler/architecture combinations.
51
- # Further details on PIC can be found here:
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:
52
55
  # https://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/
53
56
  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
54
57
 
55
- # Disable C and C++ compiler extensions.
56
- # C/CXX_EXTENSIONS are ON by default to allow the compilers to use extended
57
- # variants of the C/CXX language.
58
- # However, this could expose cross-platform bugs in user code or in the headers
59
- # of third-party dependencies and thus it is strongly suggested to turn
60
- # extensions off.
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.
61
63
  set(CMAKE_C_EXTENSIONS OFF)
62
64
  set(CMAKE_CXX_EXTENSIONS OFF)
63
65
  list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
64
66
 
65
- ### Options
66
- # Shared/Dynamic or Static library?
67
+ # Options Shared/Dynamic or Static library?
67
68
  option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)
68
69
 
69
70
  # Enable RPATH support for installed binaries and libraries
70
71
  include(AddInstallRPATHSupport)
71
- add_install_rpath_support(BIN_DIRS "${CMAKE_INSTALL_FULL_BINDIR}"
72
- LIB_DIRS "${CMAKE_INSTALL_FULL_LIBDIR}"
73
- INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}"
72
+ add_install_rpath_support(
73
+ BIN_DIRS
74
+ "${CMAKE_INSTALL_FULL_BINDIR}"
75
+ LIB_DIRS
76
+ "${CMAKE_INSTALL_FULL_LIBDIR}"
77
+ INSTALL_NAME_DIR
78
+ "${CMAKE_INSTALL_FULL_LIBDIR}"
74
79
  USE_LINK_PATH)
75
80
 
76
- # Encourage user to specify a build type (e.g. Release, Debug, etc.), otherwise set it to Release.
81
+ # Encourage user to specify a build type (e.g. Release, Debug, etc.), otherwise
82
+ # set it to Release.
77
83
  if(NOT CMAKE_CONFIGURATION_TYPES)
78
84
  if(NOT CMAKE_BUILD_TYPE)
79
85
  message(STATUS "Setting build type to 'Release' as none was specified.")
@@ -81,19 +87,17 @@ if(NOT CMAKE_CONFIGURATION_TYPES)
81
87
  endif()
82
88
  endif()
83
89
 
84
-
85
90
  # Build test related commands?
86
91
  option(BUILD_TESTING "Create tests using CMake" OFF)
87
92
  if(BUILD_TESTING)
88
93
  enable_testing()
89
94
  endif()
90
95
 
91
- # Add uninstall target
92
- # After 'make install' can run 'make uninstall' to remove.
96
+ # Add uninstall target After 'make install' can run 'make uninstall' to remove.
93
97
  include(AddUninstallTarget)
94
98
 
95
- ### Some variables useful for sampling the building process
96
- # Note that the GPU profile is not compiled.
99
+ # Some variables useful for sampling the building process. Note that the GPU
100
+ # profile is not compiled.
97
101
  set(LINSYS linsys)
98
102
  set(DIRSRC ${LINSYS}/cpu/direct)
99
103
  set(INDIRSRC ${LINSYS}/cpu/indirect)
@@ -109,8 +113,15 @@ message(STATUS "Single precision floats (32bit) are ${SFLOAT}")
109
113
  option(DLONG "Use long integers (64bit) for indexing" OFF)
110
114
  message(STATUS "Long integers (64bit) are ${DLONG}")
111
115
 
116
+ # Disable all printing
117
+ option(NO_PRINTING "Disables all printing" OFF)
118
+ message(STATUS "Printing is NOT ${NO_PRINTING}")
119
+
120
+ # Disable all read/write functionality
121
+ option(NO_READ_WRITE "Disables all read/write functionality" OFF)
122
+ message(STATUS "Read/write functionality is NOT ${NO_READ_WRITE}")
112
123
 
113
- set(COMPILER_OPTS "-DUSE_LAPACK -DCOPYAMATRIX -DCTRLC")
124
+ set(COMPILER_OPTS "-DUSE_LAPACK -DCTRLC")
114
125
 
115
126
  # Primitive types
116
127
  if(SFLOAT)
@@ -127,70 +138,71 @@ else()
127
138
  set(SCS_INT_TYPE "int")
128
139
  endif()
129
140
 
141
+ if(NO_PRINTING)
142
+ set(COMPILER_OPTS "-DNO_PRINTING=1 ${COMPILER_OPTS}")
143
+ endif()
144
+
145
+ if(NO_READ_WRITE)
146
+ set(COMPILER_OPTS "-DNO_READ_WRITE=1 ${COMPILER_OPTS}")
147
+ endif()
148
+
130
149
  message(STATUS "COMPILER_OPTS = ${COMPILER_OPTS}")
131
150
 
132
- # TODO this is a hack that overwrites the scs_types.h file, we should
133
- # find a way to do this that doesn't pollute the master directory.
151
+ # TODO this is a hack that overwrites the scs_types.h file, we should find a way
152
+ # to do this that doesn't pollute the master directory.
134
153
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/scs_types.h.in
135
- ${CMAKE_CURRENT_SOURCE_DIR}/include/scs_types.h
136
- NEWLINE_STYLE LF)
154
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/scs_types.h NEWLINE_STYLE LF)
137
155
 
138
- # Public headers
139
- set(${PROJECT_NAME}_PUBLIC_HDR
140
- include/scs_types.h
141
- include/scs.h)
156
+ # Public headers
157
+ set(${PROJECT_NAME}_PUBLIC_HDR include/scs_types.h include/scs.h)
142
158
 
143
159
  # Common source files
144
160
  set(${PROJECT_NAME}_SRC
145
- src/aa.c
146
- src/cones.c
147
- src/ctrlc.c
148
- src/linalg.c
149
- src/normalize.c
150
- src/rw.c
151
- src/scs.c
152
- src/scs_version.c
153
- src/util.c
154
- ${LINSYS}/csparse.c
155
- ${LINSYS}/scs_matrix.c)
161
+ src/aa.c
162
+ src/cones.c
163
+ src/ctrlc.c
164
+ src/exp_cone.c
165
+ src/linalg.c
166
+ src/normalize.c
167
+ src/rw.c
168
+ src/scs.c
169
+ src/scs_version.c
170
+ src/util.c
171
+ ${LINSYS}/csparse.c
172
+ ${LINSYS}/scs_matrix.c)
156
173
 
157
174
  # Common header files
158
175
  set(${PROJECT_NAME}_HDR
159
- include/aa.h
160
- include/cones.h
161
- include/ctrlc.h
162
- include/glbopts.h
163
- include/linalg.h
164
- include/linsys.h
165
- include/normalize.h
166
- include/rw.h
167
- include/scs.h
168
- include/scs_blas.h
169
- include/scs_types.h
170
- include/scs_work.h
171
- include/util.h
172
- ${LINSYS}/csparse.h
173
- ${LINSYS}/scs_matrix.h)
176
+ include/aa.h
177
+ include/cones.h
178
+ include/ctrlc.h
179
+ include/glbopts.h
180
+ include/linalg.h
181
+ include/linsys.h
182
+ include/normalize.h
183
+ include/rw.h
184
+ include/scs.h
185
+ include/scs_blas.h
186
+ include/scs_types.h
187
+ include/scs_work.h
188
+ include/util.h
189
+ ${LINSYS}/csparse.h
190
+ ${LINSYS}/scs_matrix.h)
174
191
 
175
192
  # get all the c file in amd/external
176
- file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_SRC
177
- ${EXTERNAL}/amd/*.c
178
- )
193
+ file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_SRC ${EXTERNAL}/amd/*.c)
179
194
 
180
195
  # get all the h file in amd/external
181
- file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_HDR
182
- ${EXTERNAL}/amd/*.h
183
- )
196
+ file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_HDR ${EXTERNAL}/amd/*.h)
184
197
 
185
198
  # get all the c file in amd/external
186
- file(GLOB ${PROJECT_NAME}_LDL_EXTERNAL_HDR
187
- ${EXTERNAL}/qdldl/*.h
188
- )
199
+ file(GLOB ${PROJECT_NAME}_LDL_EXTERNAL_HDR ${EXTERNAL}/qdldl/*.h)
189
200
 
190
- ### Direct method
191
- # Here we compile the direct method library
201
+ # ##############################################################################
202
+ # Direct method. Here we compile the direct method library.
192
203
  set(${PROJECT_NAME}_DIRECT ${PROJECT_NAME}dir)
193
- add_library(${${PROJECT_NAME}_DIRECT}
204
+ add_library(
205
+ ${${PROJECT_NAME}_DIRECT}
194
206
  ${${PROJECT_NAME}_HDR}
195
207
  ${${PROJECT_NAME}_SRC}
196
208
  ${DIRSRC}/private.c
@@ -200,121 +212,225 @@ add_library(${${PROJECT_NAME}_DIRECT}
200
212
  ${${PROJECT_NAME}_AMD_EXTERNAL_HDR}
201
213
  ${${PROJECT_NAME}_LDL_EXTERNAL_HDR})
202
214
 
203
- target_include_directories(${${PROJECT_NAME}_DIRECT} PRIVATE
204
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/amd;${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/qdldl;${CMAKE_CURRENT_SOURCE_DIR}/${DIRSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>")
215
+ target_include_directories(
216
+ ${${PROJECT_NAME}_DIRECT}
217
+ PRIVATE
218
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/amd;${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/qdldl;${CMAKE_CURRENT_SOURCE_DIR}/${DIRSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
219
+ )
205
220
 
206
- target_include_directories(${${PROJECT_NAME}_DIRECT} PUBLIC
207
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
208
- "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
221
+ target_include_directories(
222
+ ${${PROJECT_NAME}_DIRECT}
223
+ PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
224
+ "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
209
225
 
210
226
  # Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
211
227
  target_compile_definitions(${${PROJECT_NAME}_DIRECT} PRIVATE ${COMPILER_OPTS})
212
228
 
213
229
  # The library depends on math (m) blas and lapack
214
- target_link_libraries(${${PROJECT_NAME}_DIRECT} PRIVATE
215
- m
216
- blas
217
- lapack)
230
+ target_link_libraries(${${PROJECT_NAME}_DIRECT} PRIVATE m blas lapack)
218
231
 
219
232
  # Set some properties
220
- set_target_properties(${${PROJECT_NAME}_DIRECT} PROPERTIES
221
- VERSION ${scs_VERSION}
222
- PUBLIC_HEADER "${${PROJECT_NAME}_PUBLIC_HDR}")
233
+ set_target_properties(
234
+ ${${PROJECT_NAME}_DIRECT}
235
+ PROPERTIES VERSION ${scs_VERSION} PUBLIC_HEADER
236
+ "${${PROJECT_NAME}_PUBLIC_HDR}")
223
237
 
224
238
  add_library(scs::${${PROJECT_NAME}_DIRECT} ALIAS ${${PROJECT_NAME}_DIRECT})
225
239
 
226
240
  # Install the library
227
- install(TARGETS ${${PROJECT_NAME}_DIRECT}
228
- EXPORT ${PROJECT_NAME}
241
+ install(
242
+ TARGETS ${${PROJECT_NAME}_DIRECT}
243
+ EXPORT ${PROJECT_NAME}
229
244
  COMPONENT runtime
230
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
231
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
232
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
233
- PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
245
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
246
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
247
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
248
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
234
249
 
235
250
  # Add the direct method to the set of the compiled targets
236
- set_property(GLOBAL APPEND PROPERTY scs_TARGETS ${${PROJECT_NAME}_DIRECT})
237
-
238
- ### Indirect method
239
- # Here we compile the indirect method library
240
- set(${PROJECT_NAME}_INDIRECT ${PROJECT_NAME}indir)
241
- add_library(${${PROJECT_NAME}_INDIRECT}
242
- ${${PROJECT_NAME}_HDR}
243
- ${${PROJECT_NAME}_SRC}
244
- ${INDIRSRC}/private.c
245
- ${INDIRSRC}/private.h
246
- ${${${PROJECT_NAME}_INDIRECT}_HDR}
247
- )
251
+ set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_DIRECT})
248
252
 
253
+ # ##############################################################################
249
254
 
250
- target_include_directories(${${PROJECT_NAME}_INDIRECT} PRIVATE
251
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/amd;${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/qdldl;${CMAKE_CURRENT_SOURCE_DIR}/${INDIRSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>")
252
-
253
- target_include_directories(${${PROJECT_NAME}_INDIRECT} PUBLIC
254
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
255
- "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
255
+ # Indirect method. Here we compile the indirect method library.
256
+ set(${PROJECT_NAME}_INDIRECT ${PROJECT_NAME}indir)
257
+ add_library(
258
+ ${${PROJECT_NAME}_INDIRECT}
259
+ ${${PROJECT_NAME}_HDR} ${${PROJECT_NAME}_SRC} ${INDIRSRC}/private.c
260
+ ${INDIRSRC}/private.h ${${${PROJECT_NAME}_INDIRECT}_HDR})
261
+
262
+ target_include_directories(
263
+ ${${PROJECT_NAME}_INDIRECT}
264
+ PRIVATE
265
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INDIRSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
266
+ )
267
+
268
+ target_include_directories(
269
+ ${${PROJECT_NAME}_INDIRECT}
270
+ PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
271
+ "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
256
272
 
257
273
  # Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
258
- target_compile_definitions(${${PROJECT_NAME}_INDIRECT} PRIVATE ${COMPILER_OPTS} -DINDIRECT)
274
+ target_compile_definitions(${${PROJECT_NAME}_INDIRECT} PRIVATE ${COMPILER_OPTS}
275
+ -DINDIRECT)
259
276
 
260
277
  # The library depends on math (m) blas and lapack
261
- target_link_libraries(${${PROJECT_NAME}_INDIRECT} PUBLIC
262
- m
263
- blas
264
- lapack)
278
+ target_link_libraries(${${PROJECT_NAME}_INDIRECT} PUBLIC m blas lapack)
265
279
 
266
280
  # Set some properties
267
- set_target_properties(${${PROJECT_NAME}_INDIRECT} PROPERTIES
268
- VERSION ${scs_VERSION}
269
- PUBLIC_HEADER "${${PROJECT_NAME}_PUBLIC_HDR}")
281
+ set_target_properties(
282
+ ${${PROJECT_NAME}_INDIRECT}
283
+ PROPERTIES VERSION ${scs_VERSION} PUBLIC_HEADER
284
+ "${${PROJECT_NAME}_PUBLIC_HDR}")
270
285
 
271
286
  add_library(scs::${${PROJECT_NAME}_INDIRECT} ALIAS ${${PROJECT_NAME}_INDIRECT})
272
287
 
273
288
  # Install the library
274
- install(TARGETS ${${PROJECT_NAME}_INDIRECT}
275
- EXPORT ${PROJECT_NAME}
289
+ install(
290
+ TARGETS ${${PROJECT_NAME}_INDIRECT}
291
+ EXPORT ${PROJECT_NAME}
276
292
  COMPONENT runtime
277
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
278
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
279
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
293
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
294
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
295
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
280
296
  PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
281
297
 
282
298
  # Add the indirect method to the set of the compiled targets
283
- set_property(GLOBAL APPEND PROPERTY scs_TARGETS ${${PROJECT_NAME}_INDIRECT})
299
+ set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_INDIRECT})
284
300
 
285
- ### Install the .cmake file.
286
- # Thanks to thanks file it will be possible to link scs to consumer libraries
301
+ # ##############################################################################
302
+
303
+ # If MKLROOT is defined, then we install the MKL version.
304
+ if(DEFINED ENV{MKLROOT})
305
+
306
+ message(STATUS "MKLROOT set to $ENV{MKLROOT}")
307
+ message(STATUS "Will install SCS-MKL (libscsmkl).")
308
+
309
+ set(MKLSRC ${LINSYS}/mkl/direct)
310
+
311
+ # Here we compile the direct MKL pardiso library
312
+ set(${PROJECT_NAME}_MKL ${PROJECT_NAME}mkl)
313
+ add_library(
314
+ ${${PROJECT_NAME}_MKL}
315
+ ${${PROJECT_NAME}_HDR} ${${PROJECT_NAME}_SRC} ${MKLSRC}/private.c
316
+ ${MKLSRC}/private.h ${${${PROJECT_NAME}_MKL}_HDR})
317
+
318
+ target_include_directories(
319
+ ${${PROJECT_NAME}_MKL}
320
+ PRIVATE
321
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${MKLSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
322
+ )
323
+
324
+ target_include_directories(
325
+ ${${PROJECT_NAME}_MKL}
326
+ PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
327
+ "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
328
+
329
+ target_compile_definitions(${${PROJECT_NAME}_MKL} PRIVATE ${COMPILER_OPTS})
330
+ # See:
331
+ # https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html
332
+ # This is probably not correct for other systems. TODO: make SCS-MKL
333
+ # work for all combinations of platform / compiler / threading options.
334
+ target_link_options(${${PROJECT_NAME}_MKL} PRIVATE "LINKER:--no-as-needed")
335
+ target_link_directories(${${PROJECT_NAME}_MKL} PRIVATE $ENV{MKLROOT}/lib)
336
+ target_link_libraries(
337
+ ${${PROJECT_NAME}_MKL}
338
+ PRIVATE m
339
+ mkl_rt
340
+ mkl_gnu_thread
341
+ mkl_core
342
+ gomp
343
+ pthread
344
+ dl)
345
+
346
+ # Set some properties
347
+ set_target_properties(
348
+ ${${PROJECT_NAME}_MKL}
349
+ PROPERTIES VERSION ${scs_VERSION} PUBLIC_HEADER
350
+ "${${PROJECT_NAME}_PUBLIC_HDR}")
351
+
352
+ add_library(scs::${${PROJECT_NAME}_MKL} ALIAS ${${PROJECT_NAME}_MKL})
353
+
354
+ # Install the library
355
+ install(
356
+ TARGETS ${${PROJECT_NAME}_MKL}
357
+ EXPORT ${PROJECT_NAME}
358
+ COMPONENT runtime
359
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
360
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
361
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
362
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
363
+
364
+ # Add the mkl method to the set of the compiled targets
365
+ set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_MKL})
366
+ else()
367
+ message(
368
+ STATUS "MKLROOT environment variable is undefined, skipping SCS-MKL install"
369
+ )
370
+ endif()
371
+
372
+ # ##############################################################################
373
+
374
+ # Install the .cmake file. It is possible to link scs o consumer libraries.
287
375
  include(InstallBasicPackageFiles)
288
- install_basic_package_files(${PROJECT_NAME}
289
- NAMESPACE scs::
290
- VERSION ${${PROJECT_NAME}_VERSION}
291
- TARGETS_PROPERTY scs_TARGETS
292
- COMPATIBILITY SameMajorVersion
293
- VARS_PREFIX ${PROJECT_NAME}
376
+ install_basic_package_files(
377
+ ${PROJECT_NAME}
378
+ NAMESPACE
379
+ scs::
380
+ VERSION
381
+ ${${PROJECT_NAME}_VERSION}
382
+ TARGETS_PROPERTY
383
+ SCS_TARGETS
384
+ COMPATIBILITY
385
+ SameMajorVersion
386
+ VARS_PREFIX
387
+ ${PROJECT_NAME}
294
388
  NO_CHECK_REQUIRED_COMPONENTS_MACRO)
295
389
 
296
- ### Add the tests
390
+ # Add the tests
297
391
  if(BUILD_TESTING)
298
- add_executable(run_tests_direct test/run_tests.c)
392
+ add_executable(run_tests_direct test/run_tests.c)
299
393
  target_compile_definitions(run_tests_direct PRIVATE ${COMPILER_OPTS})
300
- target_link_libraries(run_tests_direct PRIVATE
301
- scs::scsdir)
302
- target_include_directories(run_tests_direct PRIVATE
303
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>" )
394
+ target_link_libraries(run_tests_direct PRIVATE scs::scsdir)
395
+ target_include_directories(
396
+ run_tests_direct
397
+ PRIVATE
398
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
399
+ )
304
400
 
305
- add_test(NAME run_tests_direct
401
+ add_test(
402
+ NAME run_tests_direct
306
403
  COMMAND run_tests_direct
307
404
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
308
405
 
309
- add_executable(run_tests_indirect test/run_tests.c)
406
+ add_executable(run_tests_indirect test/run_tests.c)
310
407
  target_compile_definitions(run_tests_indirect PRIVATE ${COMPILER_OPTS})
311
- target_link_libraries(run_tests_indirect PRIVATE
312
- scs::scsindir)
313
- target_include_directories(run_tests_indirect PRIVATE
314
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>" )
408
+ target_link_libraries(run_tests_indirect PRIVATE scs::scsindir)
409
+ target_include_directories(
410
+ run_tests_indirect
411
+ PRIVATE
412
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
413
+ )
315
414
 
316
- add_test(NAME run_tests_indirect
415
+ add_test(
416
+ NAME run_tests_indirect
317
417
  COMMAND run_tests_indirect
318
418
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
319
419
 
420
+ if(DEFINED ENV{MKLROOT})
421
+ add_executable(run_tests_mkl test/run_tests.c)
422
+ target_compile_definitions(run_tests_mkl PRIVATE ${COMPILER_OPTS})
423
+ target_link_libraries(run_tests_mkl PRIVATE scs::scsmkl)
424
+ target_include_directories(
425
+ run_tests_mkl
426
+ PRIVATE
427
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
428
+ )
429
+
430
+ add_test(
431
+ NAME run_tests_mkl
432
+ COMMAND run_tests_mkl
433
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
434
+ endif()
435
+
320
436
  endif()