scs 0.4.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/scs/ffi.rb +2 -2
- data/lib/scs/version.rb +1 -1
- data/lib/scs.rb +3 -3
- data/vendor/scs/CITATION.cff +2 -2
- data/vendor/scs/CMakeLists.txt +305 -171
- data/vendor/scs/Makefile +44 -19
- data/vendor/scs/README.md +1 -1
- data/vendor/scs/include/glbopts.h +34 -14
- data/vendor/scs/include/linsys.h +8 -8
- data/vendor/scs/include/scs.h +6 -2
- data/vendor/scs/include/scs_blas.h +4 -0
- data/vendor/scs/include/scs_types.h +3 -1
- data/vendor/scs/include/scs_work.h +9 -8
- data/vendor/scs/include/util.h +1 -1
- data/vendor/scs/linsys/cpu/direct/private.c +32 -153
- data/vendor/scs/linsys/cpu/direct/private.h +6 -6
- data/vendor/scs/linsys/cpu/indirect/private.c +9 -22
- data/vendor/scs/linsys/cpu/indirect/private.h +4 -2
- data/vendor/scs/linsys/csparse.c +140 -12
- data/vendor/scs/linsys/csparse.h +10 -17
- data/vendor/scs/linsys/gpu/gpu.c +4 -4
- data/vendor/scs/linsys/gpu/gpu.h +1 -1
- data/vendor/scs/linsys/gpu/indirect/private.c +15 -26
- data/vendor/scs/linsys/mkl/direct/private.c +182 -0
- data/vendor/scs/linsys/mkl/direct/private.h +38 -0
- data/vendor/scs/linsys/scs_matrix.c +11 -5
- data/vendor/scs/scs.mk +40 -27
- data/vendor/scs/src/cones.c +17 -161
- data/vendor/scs/src/exp_cone.c +399 -0
- data/vendor/scs/src/linalg.c +17 -3
- data/vendor/scs/src/normalize.c +4 -2
- data/vendor/scs/src/rw.c +107 -38
- data/vendor/scs/src/scs.c +103 -69
- data/vendor/scs/src/util.c +12 -3
- data/vendor/scs/test/minunit.h +2 -1
- data/vendor/scs/test/problem_utils.h +2 -1
- data/vendor/scs/test/problems/hs21_tiny_qp.h +1 -1
- data/vendor/scs/test/problems/hs21_tiny_qp_rw.h +8 -3
- data/vendor/scs/test/problems/max_ent +0 -0
- data/vendor/scs/test/problems/max_ent.h +8 -0
- data/vendor/scs/test/problems/mpc_bug.h +19 -0
- data/vendor/scs/test/problems/mpc_bug1 +0 -0
- data/vendor/scs/test/problems/mpc_bug2 +0 -0
- data/vendor/scs/test/problems/mpc_bug3 +0 -0
- data/vendor/scs/test/problems/random_prob.h +2 -43
- data/vendor/scs/test/problems/rob_gauss_cov_est.h +7 -2
- data/vendor/scs/test/problems/test_exp_cone.h +84 -0
- data/vendor/scs/test/problems/test_prob_from_data_file.h +73 -0
- data/vendor/scs/test/run_from_file.c +7 -1
- data/vendor/scs/test/run_tests.c +25 -9
- metadata +14 -3
data/vendor/scs/CMakeLists.txt
CHANGED
@@ -1,30 +1,36 @@
|
|
1
|
-
# CMakeLists.txt file for scs
|
2
|
-
#
|
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(
|
6
|
+
project(
|
7
|
+
scs
|
7
8
|
LANGUAGES C
|
8
|
-
VERSION 3.2.
|
9
|
+
VERSION 3.2.6)
|
9
10
|
|
10
|
-
# Defines the CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR and many other useful
|
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
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
22
|
-
|
23
|
-
set(
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
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
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
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
|
-
|
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(
|
72
|
-
|
73
|
-
|
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
|
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
|
-
|
96
|
-
#
|
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,23 @@ 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}")
|
123
|
+
|
124
|
+
option(USE_LAPACK "Whether to use BLAS/LAPACK" ON)
|
125
|
+
message(STATUS "BLAS/LAPACK usage is ${USE_LAPACK}")
|
112
126
|
|
113
|
-
|
127
|
+
# Enable OpenMP support
|
128
|
+
option(USE_OPENMP "Compile with OpenMP support" OFF)
|
129
|
+
message(STATUS "OpenMP parallelization is ${USE_OPENMP}")
|
130
|
+
|
131
|
+
set(COMPILER_OPTS "-DCTRLC")
|
132
|
+
set(LAPACK_LINK_LIBRARIES "")
|
114
133
|
|
115
134
|
# Primitive types
|
116
135
|
if(SFLOAT)
|
@@ -127,70 +146,81 @@ else()
|
|
127
146
|
set(SCS_INT_TYPE "int")
|
128
147
|
endif()
|
129
148
|
|
149
|
+
if(NO_PRINTING)
|
150
|
+
set(COMPILER_OPTS "-DNO_PRINTING=1 ${COMPILER_OPTS}")
|
151
|
+
endif()
|
152
|
+
|
153
|
+
if(NO_READ_WRITE)
|
154
|
+
set(COMPILER_OPTS "-DNO_READ_WRITE=1 ${COMPILER_OPTS}")
|
155
|
+
endif()
|
156
|
+
|
157
|
+
if (USE_LAPACK)
|
158
|
+
set(COMPILER_OPTS "-DUSE_LAPACK ${COMPILER_OPTS}")
|
159
|
+
list(APPEND LAPACK_LINK_LIBRARIES "blas" "lapack")
|
160
|
+
endif()
|
161
|
+
|
162
|
+
if(USE_OPENMP)
|
163
|
+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
|
164
|
+
endif()
|
165
|
+
|
130
166
|
message(STATUS "COMPILER_OPTS = ${COMPILER_OPTS}")
|
167
|
+
message(STATUS "CMAKE_C_FLAGS = ${CMAKE_C_FLAGS}")
|
131
168
|
|
132
|
-
# TODO this is a hack that overwrites the scs_types.h file, we should
|
133
|
-
#
|
169
|
+
# TODO this is a hack that overwrites the scs_types.h file, we should find a way
|
170
|
+
# to do this that doesn't pollute the master directory.
|
134
171
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/scs_types.h.in
|
135
|
-
${CMAKE_CURRENT_SOURCE_DIR}/include/scs_types.h
|
136
|
-
NEWLINE_STYLE LF)
|
172
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/scs_types.h NEWLINE_STYLE LF)
|
137
173
|
|
138
|
-
# Public headers
|
139
|
-
set(${PROJECT_NAME}_PUBLIC_HDR
|
140
|
-
include/scs_types.h
|
141
|
-
include/scs.h)
|
174
|
+
# Public headers
|
175
|
+
set(${PROJECT_NAME}_PUBLIC_HDR include/scs_types.h include/scs.h)
|
142
176
|
|
143
177
|
# Common source files
|
144
178
|
set(${PROJECT_NAME}_SRC
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
179
|
+
src/aa.c
|
180
|
+
src/cones.c
|
181
|
+
src/ctrlc.c
|
182
|
+
src/exp_cone.c
|
183
|
+
src/linalg.c
|
184
|
+
src/normalize.c
|
185
|
+
src/rw.c
|
186
|
+
src/scs.c
|
187
|
+
src/scs_version.c
|
188
|
+
src/util.c
|
189
|
+
${LINSYS}/csparse.c
|
190
|
+
${LINSYS}/scs_matrix.c)
|
156
191
|
|
157
192
|
# Common header files
|
158
193
|
set(${PROJECT_NAME}_HDR
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
194
|
+
include/aa.h
|
195
|
+
include/cones.h
|
196
|
+
include/ctrlc.h
|
197
|
+
include/glbopts.h
|
198
|
+
include/linalg.h
|
199
|
+
include/linsys.h
|
200
|
+
include/normalize.h
|
201
|
+
include/rw.h
|
202
|
+
include/scs.h
|
203
|
+
include/scs_blas.h
|
204
|
+
include/scs_types.h
|
205
|
+
include/scs_work.h
|
206
|
+
include/util.h
|
207
|
+
${LINSYS}/csparse.h
|
208
|
+
${LINSYS}/scs_matrix.h)
|
174
209
|
|
175
210
|
# get all the c file in amd/external
|
176
|
-
file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_SRC
|
177
|
-
${EXTERNAL}/amd/*.c
|
178
|
-
)
|
211
|
+
file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_SRC ${EXTERNAL}/amd/*.c)
|
179
212
|
|
180
213
|
# get all the h file in amd/external
|
181
|
-
file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_HDR
|
182
|
-
${EXTERNAL}/amd/*.h
|
183
|
-
)
|
214
|
+
file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_HDR ${EXTERNAL}/amd/*.h)
|
184
215
|
|
185
216
|
# get all the c file in amd/external
|
186
|
-
file(GLOB ${PROJECT_NAME}_LDL_EXTERNAL_HDR
|
187
|
-
${EXTERNAL}/qdldl/*.h
|
188
|
-
)
|
217
|
+
file(GLOB ${PROJECT_NAME}_LDL_EXTERNAL_HDR ${EXTERNAL}/qdldl/*.h)
|
189
218
|
|
190
|
-
|
191
|
-
# Here we compile the direct method library
|
219
|
+
# ##############################################################################
|
220
|
+
# Direct method. Here we compile the direct method library.
|
192
221
|
set(${PROJECT_NAME}_DIRECT ${PROJECT_NAME}dir)
|
193
|
-
add_library(
|
222
|
+
add_library(
|
223
|
+
${${PROJECT_NAME}_DIRECT}
|
194
224
|
${${PROJECT_NAME}_HDR}
|
195
225
|
${${PROJECT_NAME}_SRC}
|
196
226
|
${DIRSRC}/private.c
|
@@ -200,121 +230,225 @@ add_library(${${PROJECT_NAME}_DIRECT}
|
|
200
230
|
${${PROJECT_NAME}_AMD_EXTERNAL_HDR}
|
201
231
|
${${PROJECT_NAME}_LDL_EXTERNAL_HDR})
|
202
232
|
|
203
|
-
target_include_directories(
|
204
|
-
|
233
|
+
target_include_directories(
|
234
|
+
${${PROJECT_NAME}_DIRECT}
|
235
|
+
PRIVATE
|
236
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/amd;${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/qdldl;${CMAKE_CURRENT_SOURCE_DIR}/${DIRSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
|
237
|
+
)
|
205
238
|
|
206
|
-
target_include_directories(
|
207
|
-
|
208
|
-
"$<
|
239
|
+
target_include_directories(
|
240
|
+
${${PROJECT_NAME}_DIRECT}
|
241
|
+
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
242
|
+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
|
209
243
|
|
210
244
|
# Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
|
211
245
|
target_compile_definitions(${${PROJECT_NAME}_DIRECT} PRIVATE ${COMPILER_OPTS})
|
212
246
|
|
213
|
-
# The library depends on math (m) blas and lapack
|
214
|
-
target_link_libraries(${${PROJECT_NAME}_DIRECT} PRIVATE
|
215
|
-
m
|
216
|
-
blas
|
217
|
-
lapack)
|
247
|
+
# The library depends on math (m) and (optionally) blas and lapack
|
248
|
+
target_link_libraries(${${PROJECT_NAME}_DIRECT} PRIVATE m ${LAPACK_LINK_LIBRARIES})
|
218
249
|
|
219
250
|
# Set some properties
|
220
|
-
set_target_properties(
|
221
|
-
|
222
|
-
|
251
|
+
set_target_properties(
|
252
|
+
${${PROJECT_NAME}_DIRECT}
|
253
|
+
PROPERTIES VERSION ${scs_VERSION} PUBLIC_HEADER
|
254
|
+
"${${PROJECT_NAME}_PUBLIC_HDR}")
|
223
255
|
|
224
256
|
add_library(scs::${${PROJECT_NAME}_DIRECT} ALIAS ${${PROJECT_NAME}_DIRECT})
|
225
257
|
|
226
258
|
# Install the library
|
227
|
-
install(
|
228
|
-
|
259
|
+
install(
|
260
|
+
TARGETS ${${PROJECT_NAME}_DIRECT}
|
261
|
+
EXPORT ${PROJECT_NAME}
|
229
262
|
COMPONENT runtime
|
230
|
-
LIBRARY
|
231
|
-
ARCHIVE
|
232
|
-
RUNTIME
|
233
|
-
PUBLIC_HEADER
|
263
|
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
|
264
|
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
|
265
|
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
|
266
|
+
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
|
234
267
|
|
235
268
|
# Add the direct method to the set of the compiled targets
|
236
|
-
set_property(GLOBAL APPEND PROPERTY
|
269
|
+
set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_DIRECT})
|
237
270
|
|
238
|
-
|
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
|
-
)
|
271
|
+
# ##############################################################################
|
248
272
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
273
|
+
# Indirect method. Here we compile the indirect method library.
|
274
|
+
set(${PROJECT_NAME}_INDIRECT ${PROJECT_NAME}indir)
|
275
|
+
add_library(
|
276
|
+
${${PROJECT_NAME}_INDIRECT}
|
277
|
+
${${PROJECT_NAME}_HDR} ${${PROJECT_NAME}_SRC} ${INDIRSRC}/private.c
|
278
|
+
${INDIRSRC}/private.h ${${${PROJECT_NAME}_INDIRECT}_HDR})
|
279
|
+
|
280
|
+
target_include_directories(
|
281
|
+
${${PROJECT_NAME}_INDIRECT}
|
282
|
+
PRIVATE
|
283
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INDIRSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
|
284
|
+
)
|
285
|
+
|
286
|
+
target_include_directories(
|
287
|
+
${${PROJECT_NAME}_INDIRECT}
|
288
|
+
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
289
|
+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
|
256
290
|
|
257
291
|
# Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
|
258
|
-
target_compile_definitions(${${PROJECT_NAME}_INDIRECT} PRIVATE ${COMPILER_OPTS}
|
292
|
+
target_compile_definitions(${${PROJECT_NAME}_INDIRECT} PRIVATE ${COMPILER_OPTS}
|
293
|
+
-DINDIRECT)
|
259
294
|
|
260
|
-
# The library depends on math (m) blas and lapack
|
261
|
-
target_link_libraries(${${PROJECT_NAME}_INDIRECT} PUBLIC
|
262
|
-
m
|
263
|
-
blas
|
264
|
-
lapack)
|
295
|
+
# The library depends on math (m) and (optionally) blas and lapack
|
296
|
+
target_link_libraries(${${PROJECT_NAME}_INDIRECT} PUBLIC m ${LAPACK_LINK_LIBRARIES})
|
265
297
|
|
266
298
|
# Set some properties
|
267
|
-
set_target_properties(
|
268
|
-
|
269
|
-
|
299
|
+
set_target_properties(
|
300
|
+
${${PROJECT_NAME}_INDIRECT}
|
301
|
+
PROPERTIES VERSION ${scs_VERSION} PUBLIC_HEADER
|
302
|
+
"${${PROJECT_NAME}_PUBLIC_HDR}")
|
270
303
|
|
271
304
|
add_library(scs::${${PROJECT_NAME}_INDIRECT} ALIAS ${${PROJECT_NAME}_INDIRECT})
|
272
305
|
|
273
306
|
# Install the library
|
274
|
-
install(
|
275
|
-
|
307
|
+
install(
|
308
|
+
TARGETS ${${PROJECT_NAME}_INDIRECT}
|
309
|
+
EXPORT ${PROJECT_NAME}
|
276
310
|
COMPONENT runtime
|
277
|
-
LIBRARY
|
278
|
-
ARCHIVE
|
279
|
-
RUNTIME
|
311
|
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
|
312
|
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
|
313
|
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
|
280
314
|
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
|
281
315
|
|
282
316
|
# Add the indirect method to the set of the compiled targets
|
283
|
-
set_property(GLOBAL APPEND PROPERTY
|
317
|
+
set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_INDIRECT})
|
318
|
+
|
319
|
+
# ##############################################################################
|
320
|
+
|
321
|
+
# If MKLROOT is defined, then we install the MKL version.
|
322
|
+
if(DEFINED ENV{MKLROOT})
|
323
|
+
|
324
|
+
message(STATUS "MKLROOT set to $ENV{MKLROOT}")
|
325
|
+
message(STATUS "Will install SCS-MKL (libscsmkl).")
|
326
|
+
|
327
|
+
set(MKLSRC ${LINSYS}/mkl/direct)
|
328
|
+
|
329
|
+
# Here we compile the direct MKL pardiso library
|
330
|
+
set(${PROJECT_NAME}_MKL ${PROJECT_NAME}mkl)
|
331
|
+
add_library(
|
332
|
+
${${PROJECT_NAME}_MKL}
|
333
|
+
${${PROJECT_NAME}_HDR} ${${PROJECT_NAME}_SRC} ${MKLSRC}/private.c
|
334
|
+
${MKLSRC}/private.h ${${${PROJECT_NAME}_MKL}_HDR})
|
335
|
+
|
336
|
+
target_include_directories(
|
337
|
+
${${PROJECT_NAME}_MKL}
|
338
|
+
PRIVATE
|
339
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${MKLSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
|
340
|
+
)
|
284
341
|
|
285
|
-
|
286
|
-
|
342
|
+
target_include_directories(
|
343
|
+
${${PROJECT_NAME}_MKL}
|
344
|
+
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
345
|
+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
|
346
|
+
|
347
|
+
target_compile_definitions(${${PROJECT_NAME}_MKL} PRIVATE ${COMPILER_OPTS})
|
348
|
+
# See:
|
349
|
+
# https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html
|
350
|
+
# This is probably not correct for other systems. TODO: make SCS-MKL
|
351
|
+
# work for all combinations of platform / compiler / threading options.
|
352
|
+
target_link_options(${${PROJECT_NAME}_MKL} PRIVATE "LINKER:--no-as-needed")
|
353
|
+
target_link_directories(${${PROJECT_NAME}_MKL} PRIVATE $ENV{MKLROOT}/lib)
|
354
|
+
target_link_libraries(
|
355
|
+
${${PROJECT_NAME}_MKL}
|
356
|
+
PRIVATE m
|
357
|
+
mkl_rt
|
358
|
+
mkl_gnu_thread
|
359
|
+
mkl_core
|
360
|
+
gomp
|
361
|
+
pthread
|
362
|
+
dl)
|
363
|
+
|
364
|
+
# Set some properties
|
365
|
+
set_target_properties(
|
366
|
+
${${PROJECT_NAME}_MKL}
|
367
|
+
PROPERTIES VERSION ${scs_VERSION} PUBLIC_HEADER
|
368
|
+
"${${PROJECT_NAME}_PUBLIC_HDR}")
|
369
|
+
|
370
|
+
add_library(scs::${${PROJECT_NAME}_MKL} ALIAS ${${PROJECT_NAME}_MKL})
|
371
|
+
|
372
|
+
# Install the library
|
373
|
+
install(
|
374
|
+
TARGETS ${${PROJECT_NAME}_MKL}
|
375
|
+
EXPORT ${PROJECT_NAME}
|
376
|
+
COMPONENT runtime
|
377
|
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
|
378
|
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
|
379
|
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
|
380
|
+
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
|
381
|
+
|
382
|
+
# Add the mkl method to the set of the compiled targets
|
383
|
+
set_property(GLOBAL APPEND PROPERTY SCS_TARGETS ${${PROJECT_NAME}_MKL})
|
384
|
+
else()
|
385
|
+
message(
|
386
|
+
STATUS "MKLROOT environment variable is undefined, skipping SCS-MKL install"
|
387
|
+
)
|
388
|
+
endif()
|
389
|
+
|
390
|
+
# ##############################################################################
|
391
|
+
|
392
|
+
# Install the .cmake file. It is possible to link scs o consumer libraries.
|
287
393
|
include(InstallBasicPackageFiles)
|
288
|
-
install_basic_package_files(
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
394
|
+
install_basic_package_files(
|
395
|
+
${PROJECT_NAME}
|
396
|
+
NAMESPACE
|
397
|
+
scs::
|
398
|
+
VERSION
|
399
|
+
${${PROJECT_NAME}_VERSION}
|
400
|
+
TARGETS_PROPERTY
|
401
|
+
SCS_TARGETS
|
402
|
+
COMPATIBILITY
|
403
|
+
SameMajorVersion
|
404
|
+
VARS_PREFIX
|
405
|
+
${PROJECT_NAME}
|
294
406
|
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
295
407
|
|
296
|
-
|
408
|
+
# Add the tests
|
297
409
|
if(BUILD_TESTING)
|
298
|
-
add_executable(run_tests_direct
|
410
|
+
add_executable(run_tests_direct test/run_tests.c)
|
299
411
|
target_compile_definitions(run_tests_direct PRIVATE ${COMPILER_OPTS})
|
300
|
-
target_link_libraries(run_tests_direct PRIVATE
|
301
|
-
|
302
|
-
|
303
|
-
|
412
|
+
target_link_libraries(run_tests_direct PRIVATE scs::scsdir)
|
413
|
+
target_include_directories(
|
414
|
+
run_tests_direct
|
415
|
+
PRIVATE
|
416
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
|
417
|
+
)
|
304
418
|
|
305
|
-
add_test(
|
419
|
+
add_test(
|
420
|
+
NAME run_tests_direct
|
306
421
|
COMMAND run_tests_direct
|
307
422
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
308
423
|
|
309
|
-
add_executable(run_tests_indirect
|
424
|
+
add_executable(run_tests_indirect test/run_tests.c)
|
310
425
|
target_compile_definitions(run_tests_indirect PRIVATE ${COMPILER_OPTS})
|
311
|
-
target_link_libraries(run_tests_indirect PRIVATE
|
312
|
-
|
313
|
-
|
314
|
-
|
426
|
+
target_link_libraries(run_tests_indirect PRIVATE scs::scsindir)
|
427
|
+
target_include_directories(
|
428
|
+
run_tests_indirect
|
429
|
+
PRIVATE
|
430
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
|
431
|
+
)
|
315
432
|
|
316
|
-
add_test(
|
433
|
+
add_test(
|
434
|
+
NAME run_tests_indirect
|
317
435
|
COMMAND run_tests_indirect
|
318
436
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
319
437
|
|
438
|
+
if(DEFINED ENV{MKLROOT})
|
439
|
+
add_executable(run_tests_mkl test/run_tests.c)
|
440
|
+
target_compile_definitions(run_tests_mkl PRIVATE ${COMPILER_OPTS})
|
441
|
+
target_link_libraries(run_tests_mkl PRIVATE scs::scsmkl)
|
442
|
+
target_include_directories(
|
443
|
+
run_tests_mkl
|
444
|
+
PRIVATE
|
445
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>"
|
446
|
+
)
|
447
|
+
|
448
|
+
add_test(
|
449
|
+
NAME run_tests_mkl
|
450
|
+
COMMAND run_tests_mkl
|
451
|
+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
452
|
+
endif()
|
453
|
+
|
320
454
|
endif()
|