forked from opencollab/arpack-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
327 lines (274 loc) · 8.57 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
cmake_minimum_required(VERSION 2.8)
project(arpack)
# Adopted from https://github.com/feymark/arpack.git
enable_language(Fortran)
option(MPI "Enable parallel support" OFF)
#option(SYSTEM_BLAS "Use system BLAS" ON)
#option(SYSTEM_LAPACK "Use system LAPACK" ON)
option(EXAMPLES "Compile ARPACK examples" OFF)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
function(prefixlist list_name prefix)
set(${list_name}_TMP)
foreach(l ${${list_name}})
list(APPEND ${list_name}_TMP ${prefix}${l} )
endforeach()
set(${list_name} "${${list_name}_TMP}" PARENT_SCOPE)
endfunction(prefixlist)
function(examples list_name)
foreach(l ${${list_name}})
get_filename_component(lwe ${l} NAME_WE)
add_executable(${lwe} ${arpackexample_DIR}/${l} ${examples_EXTRA_SRCS})
target_link_libraries(${lwe} arpack ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
endforeach()
endfunction(examples)
function(pexamples list_name)
foreach(l ${${list_name}})
get_filename_component(lwe ${l} NAME_WE)
add_executable(${lwe} ${parpackexample_DIR}/${l} )
target_link_libraries(${lwe} parpack arpack ${MPI_Fortran_LIBRARIES})
endforeach()
endfunction(pexamples)
#if (SYSTEM_BLAS)
find_package(BLAS REQUIRED)
#endif()
#if (BLAS_LIBRARIES)
# set(SYSTEM_BLAS ON)
#endif()
if (MPI)
include(FindMPI)
find_package(MPI REQUIRED)
include_directories(${MPI_Fortran_INCLUDE_PATH})
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${MPI_Fortran_COMPILE_FLAG}")
endif()
#if (SYSTEM_LAPACK)
find_package(LAPACK REQUIRED)
#endif()
#if (BLAS_LIBRARIES)
# set(SYSTEM_LAPACK ON)
#endif()
if (MPI)
set(parpackutil_DIR ${arpack_SOURCE_DIR}/PARPACK/UTIL/)
set(parpacksrc_DIR ${arpack_SOURCE_DIR}/PARPACK/SRC/)
endif()
#if (NOT SYSTEM_BLAS)
# file(GLOB arpackblas_STAT_SRCS blas/*.f)
#endif()
#if (NOT SYSTEM_LAPACK)
# file(GLOB arpacklapack_STAT_SRCS lapack/*.f)
#endif()
#file(GLOB arpackutil_STAT_SRCS util/*.f)
file(GLOB arpacksrc_STAT_SRCS SRC/*.f)
set(arpackutil_STAT_SRCS
UTIL/icnteq.f
UTIL/icopy.f
UTIL/iset.f
UTIL/iswap.f
UTIL/ivout.f
UTIL/second_NONE.f
UTIL/svout.f
UTIL/smout.f
UTIL/dvout.f
UTIL/dmout.f
UTIL/cvout.f
UTIL/cmout.f
UTIL/zvout.f
UTIL/zmout.f )
if (MPI)
file(GLOB parpackutil_STAT_SRCS PARPACK/UTIL/MPI/*.f)
file(GLOB parpacksrc_STAT_SRCS PARPACK/SRC/MPI/*.f)
endif()
#add_library(arpack SHARED
# ${arpackblas_STAT_SRCS}
# ${arpacklapack_STAT_SRCS}
# ${arpackutil_STAT_SRCS}
# ${arpacksrc_STAT_SRCS})
add_library(arpack
${arpackutil_STAT_SRCS}
${arpacksrc_STAT_SRCS})
target_link_libraries(arpack ${BLAS_LIBRARIES})
target_link_libraries(arpack ${LAPACK_LIBRARIES})
set_target_properties(arpack PROPERTIES OUTPUT_NAME arpack)
if (MPI)
# add_library(parpack SHARED
add_library(parpack
${parpacksrc_STAT_SRCS}
${parpackutil_STAT_SRCS})
target_link_libraries(parpack ${MPI_Fortran_LIBRARIES})
set_target_properties(parpack PROPERTIES OUTPUT_NAME parpack)
endif ()
############################
# EXAMPLES
############################
if (EXAMPLES)
############################
# EXAMPLES/BAND
############################
set(arpackexample_DIR ${arpack_SOURCE_DIR}/EXAMPLES/BAND/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Examples/band/)
set(examples_EXTRA_SRCS ${arpackexample_DIR}/cnband.f)
set(examples_STAT_SRCS
cnbdr1.f
cnbdr2.f
cnbdr3.f
cnbdr4.f)
examples(examples_STAT_SRCS)
set(examples_EXTRA_SRCS ${arpackexample_DIR}/dnband.f)
set(examples_STAT_SRCS
dnbdr1.f
dnbdr2.f
dnbdr3.f
dnbdr4.f
dnbdr5.f
dnbdr6.f)
examples(examples_STAT_SRCS)
set(examples_EXTRA_SRCS ${arpackexample_DIR}/dsband.f)
set(examples_STAT_SRCS
dsbdr1.f
dsbdr2.f
dsbdr3.f
dsbdr4.f
dsbdr5.f
dsbdr6.f)
examples(examples_STAT_SRCS)
set(examples_EXTRA_SRCS ${arpackexample_DIR}/snband.f)
set(examples_STAT_SRCS
snbdr1.f
snbdr2.f
snbdr3.f
snbdr4.f
snbdr5.f
snbdr6.f)
examples(examples_STAT_SRCS)
set(examples_EXTRA_SRCS ${arpackexample_DIR}/ssband.f)
set(examples_STAT_SRCS
ssbdr1.f
ssbdr2.f
ssbdr3.f
ssbdr4.f
ssbdr5.f
ssbdr6.f)
examples(examples_STAT_SRCS)
set(examples_EXTRA_SRCS ${arpackexample_DIR}/znband.f)
set(examples_STAT_SRCS
znbdr1.f
znbdr2.f
znbdr3.f
znbdr4.f)
examples(examples_STAT_SRCS)
set(examples_EXTRA_SRCS)
############################
# EXAMPLES/COMPLEX
############################
set(arpackexample_DIR ${arpack_SOURCE_DIR}/EXAMPLES/COMPLEX/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Examples/complex/)
set(examples_STAT_SRCS
cndrv1.f
cndrv2.f
cndrv3.f
cndrv4.f
zndrv1.f
zndrv2.f
zndrv3.f
zndrv4.f)
examples(examples_STAT_SRCS)
############################
# examples/nonsym
############################
set(arpackexample_DIR ${arpack_SOURCE_DIR}/EXAMPLES/NONSYM/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Examples/nonsym/)
set(examples_STAT_SRCS
dndrv1.f
dndrv2.f
dndrv3.f
dndrv4.f
dndrv5.f
dndrv6.f
sndrv1.f
sndrv2.f
sndrv3.f
sndrv4.f
sndrv5.f
sndrv6.f)
examples(examples_STAT_SRCS)
############################
# examples/SIMPLE
############################
set(arpackexample_DIR ${arpack_SOURCE_DIR}/EXAMPLES/SIMPLE/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Examples/simple/)
set(examples_STAT_SRCS
cnsimp.f
dnsimp.f
dssimp.f
snsimp.f
sssimp.f
znsimp.f)
examples(examples_STAT_SRCS)
############################
# examples/svd
############################
set(arpackexample_DIR ${arpack_SOURCE_DIR}/EXAMPLES/SVD/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Examples/svd/)
set(examples_STAT_SRCS
ssvd.f)
examples(examples_STAT_SRCS)
############################
# examples/sym
############################
set(arpackexample_DIR ${arpack_SOURCE_DIR}/EXAMPLES/SYM/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Examples/sym/)
set(examples_STAT_SRCS
dsdrv1.f
dsdrv2.f
dsdrv3.f
dsdrv4.f
dsdrv5.f
dsdrv6.f
ssdrv1.f
ssdrv2.f
ssdrv3.f
ssdrv4.f
ssdrv5.f
ssdrv6.f)
examples(examples_STAT_SRCS)
############################
# parpack/examples
############################
if (MPI)
set(parpackexample_DIR ${arpack_SOURCE_DIR}/PARPACK/EXAMPLES/MPI/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Examples/parpack)
set(pexamples_STAT_SRCS
pcndrv1.f
pdndrv1.f
pdndrv3.f
pdsdrv1.f
psndrv1.f
psndrv3.f
pssdrv1.f
pzndrv1.f)
pexamples(pexamples_STAT_SRCS)
endif()
endif()
############################
# CHECK
############################
enable_testing()
set(CMAKE_CTEST_COMMAND ctest -V)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Tests)
add_executable(dnsimp_test EXCLUDE_FROM_ALL TESTS/dnsimp.f TESTS/mmio.f TESTS/debug.h)
set_target_properties( dnsimp_test PROPERTIES OUTPUT_NAME dnsimp )
target_link_libraries(dnsimp_test arpack ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
add_custom_command(TARGET dnsimp_test POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/TESTS/testA.mtx testA.mtx
)
add_test(dnsimp_test Tests/dnsimp)
add_executable(bug_1315_single EXCLUDE_FROM_ALL TESTS/bug_1315_single.c)
target_link_libraries(bug_1315_single arpack ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
add_test(bug_1315_single Tests/bug_1315_single)
add_executable(bug_1315_double EXCLUDE_FROM_ALL TESTS/bug_1315_double.c)
target_link_libraries(bug_1315_double arpack ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
add_test(bug_1315_double Tests/bug_1315_double)
add_executable(bug_1323 EXCLUDE_FROM_ALL TESTS/bug_1323.f)
target_link_libraries(bug_1323 arpack ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
add_test(bug_1323 Tests/bug_1323)
add_dependencies(check dnsimp_test bug_1315_single bug_1315_double bug_1323)