forked from DrTimothyAldenDavis/SuiteSparse
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
641 lines (556 loc) · 23.2 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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
#-------------------------------------------------------------------------------
# SuiteSparse/UMFPACK/CMakeLists.txt: cmake for UMFPACK
#-------------------------------------------------------------------------------
# Copyright (c) 1995-2023, Timothy A. Davis. All Rights Reserved.
# SPDX-License-Identifier: GPL-2.0+
#-------------------------------------------------------------------------------
# get the version
#-------------------------------------------------------------------------------
# cmake 3.22 is required to find the BLAS in SuiteSparse_config
cmake_minimum_required ( VERSION 3.22 )
set ( UMFPACK_DATE "Sept 23, 2024" )
set ( UMFPACK_VERSION_MAJOR 6 CACHE STRING "" FORCE )
set ( UMFPACK_VERSION_MINOR 3 CACHE STRING "" FORCE )
set ( UMFPACK_VERSION_SUB 5 CACHE STRING "" FORCE )
message ( STATUS "Building UMFPACK version: v"
${UMFPACK_VERSION_MAJOR}.
${UMFPACK_VERSION_MINOR}.
${UMFPACK_VERSION_SUB} " (" ${UMFPACK_DATE} ")" )
#-------------------------------------------------------------------------------
# define the project
#-------------------------------------------------------------------------------
project ( UMFPACK
VERSION "${UMFPACK_VERSION_MAJOR}.${UMFPACK_VERSION_MINOR}.${UMFPACK_VERSION_SUB}"
LANGUAGES C )
#-------------------------------------------------------------------------------
# SuiteSparse policies
#-------------------------------------------------------------------------------
set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${PROJECT_SOURCE_DIR}/../CHOLMOD/cmake_modules
${PROJECT_SOURCE_DIR}/../SuiteSparse_config/cmake_modules )
include ( SuiteSparsePolicy )
#-------------------------------------------------------------------------------
# find library dependencies
#-------------------------------------------------------------------------------
if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
find_package ( SuiteSparse_config 7.8.0
PATHS ${CMAKE_SOURCE_DIR}/../SuiteSparse_config/build NO_DEFAULT_PATH )
if ( NOT TARGET SuiteSparse::SuiteSparseConfig )
find_package ( SuiteSparse_config 7.8.0 REQUIRED )
endif ( )
find_package ( AMD 3.3.2
PATHS ${CMAKE_SOURCE_DIR}/../AMD/build NO_DEFAULT_PATH )
if ( NOT TARGET SuiteSparse::AMD )
find_package ( AMD 3.3.2 REQUIRED )
endif ( )
endif ( )
include ( SuiteSparseBLAS ) # requires cmake 3.22
#-------------------------------------------------------------------------------
# find CHOLMOD
#-------------------------------------------------------------------------------
option ( UMFPACK_USE_CHOLMOD "ON (default): use CHOLMOD in UMFPACK. OFF: do not use CHOLMOD in UMFPACK" ON )
if ( SUITESPARSE_ROOT_CMAKELISTS )
# if UMFPACK_USE_CHOLMOD is true, then CHOLMOD has been added to the
# list of packages to compile in the root CMakeLists.txt.
set ( UMFPACK_HAS_CHOLMOD ${UMFPACK_USE_CHOLMOD} )
else ( )
if ( UMFPACK_USE_CHOLMOD )
# look for CHOLMOD (optional fill-reducing orderings)
find_package ( CHOLMOD 5.2.1
PATHS ${CMAKE_SOURCE_DIR}/../CHOLMOD/build NO_DEFAULT_PATH )
if ( NOT TARGET SuiteSparse::CHOLMOD )
find_package ( CHOLMOD 5.2.1 )
endif ( )
if ( NOT CHOLMOD_FOUND )
# CHOLMOD not found so disable it
set ( UMFPACK_HAS_CHOLMOD OFF )
else ( )
set ( UMFPACK_HAS_CHOLMOD ON )
endif ( )
else ( )
set ( UMFPACK_HAS_CHOLMOD OFF )
endif ( )
endif ( )
if ( UMFPACK_HAS_CHOLMOD )
message ( STATUS "Using CHOLMOD for addtional pre-ordering options" )
else ( )
message ( STATUS "CHOLMOD not found or not requested" )
endif ( )
# check for strict usage
if ( SUITESPARSE_USE_STRICT AND UMFPACK_USE_CHOLMOD AND NOT UMFPACK_HAS_CHOLMOD )
message ( FATAL_ERROR "CHOLMOD required for UMFPACK but not found" )
endif ( )
#-------------------------------------------------------------------------------
# configure files
#-------------------------------------------------------------------------------
configure_file ( "Config/umfpack.h.in"
"${PROJECT_SOURCE_DIR}/Include/umfpack.h"
NEWLINE_STYLE LF )
configure_file ( "Config/umfpack_version.tex.in"
"${PROJECT_SOURCE_DIR}/Doc/umfpack_version.tex"
NEWLINE_STYLE LF )
#-------------------------------------------------------------------------------
# include directories
#-------------------------------------------------------------------------------
include_directories ( Source Include )
#-------------------------------------------------------------------------------
# dynamic umfpack library properties
#-------------------------------------------------------------------------------
file ( GLOB UMFPACK_SOURCES "Source2/*.c" )
if ( BUILD_SHARED_LIBS )
add_library ( UMFPACK SHARED ${UMFPACK_SOURCES} )
set_target_properties ( UMFPACK PROPERTIES
VERSION ${UMFPACK_VERSION_MAJOR}.${UMFPACK_VERSION_MINOR}.${UMFPACK_VERSION_SUB}
C_STANDARD 11
C_STANDARD_REQUIRED ON
OUTPUT_NAME umfpack
SOVERSION ${UMFPACK_VERSION_MAJOR}
PUBLIC_HEADER "Include/umfpack.h"
WINDOWS_EXPORT_ALL_SYMBOLS ON )
if ( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.25" )
set_target_properties ( UMFPACK PROPERTIES EXPORT_NO_SYSTEM ON )
endif ( )
target_include_directories ( UMFPACK
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>
$<INSTALL_INTERFACE:${SUITESPARSE_INCLUDEDIR}> )
endif ( )
#-------------------------------------------------------------------------------
# static umfpack library properties
#-------------------------------------------------------------------------------
if ( BUILD_STATIC_LIBS )
add_library ( UMFPACK_static STATIC ${UMFPACK_SOURCES} )
set_target_properties ( UMFPACK_static PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED ON
OUTPUT_NAME umfpack
PUBLIC_HEADER "Include/umfpack.h" )
if ( MSVC OR ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC") )
set_target_properties ( UMFPACK_static PROPERTIES
OUTPUT_NAME umfpack_static )
endif ( )
if ( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.25" )
set_target_properties ( UMFPACK_static PROPERTIES EXPORT_NO_SYSTEM ON )
endif ( )
target_include_directories ( UMFPACK_static
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>
$<INSTALL_INTERFACE:${SUITESPARSE_INCLUDEDIR}> )
endif ( )
#-------------------------------------------------------------------------------
# add the library dependencies
#-------------------------------------------------------------------------------
# SuiteSparseConfig:
if ( BUILD_SHARED_LIBS )
target_link_libraries ( UMFPACK PRIVATE SuiteSparse::SuiteSparseConfig )
target_include_directories ( UMFPACK PUBLIC
"$<TARGET_PROPERTY:SuiteSparse::SuiteSparseConfig,INTERFACE_INCLUDE_DIRECTORIES>" )
endif ( )
if ( BUILD_STATIC_LIBS )
if ( TARGET SuiteSparse::SuiteSparseConfig_static )
target_link_libraries ( UMFPACK_static PUBLIC SuiteSparse::SuiteSparseConfig_static )
else ( )
target_link_libraries ( UMFPACK_static PUBLIC SuiteSparse::SuiteSparseConfig )
endif ( )
endif ( )
# AMD:
if ( BUILD_SHARED_LIBS )
target_link_libraries ( UMFPACK PRIVATE SuiteSparse::AMD )
target_include_directories ( UMFPACK PUBLIC
"$<TARGET_PROPERTY:SuiteSparse::AMD,INTERFACE_INCLUDE_DIRECTORIES>" )
endif ( )
if ( BUILD_STATIC_LIBS )
if ( TARGET SuiteSparse::AMD_static )
target_link_libraries ( UMFPACK_static PUBLIC SuiteSparse::AMD_static )
else ( )
target_link_libraries ( UMFPACK_static PUBLIC SuiteSparse::AMD )
endif ( )
endif ( )
# CHOLMOD:
if ( UMFPACK_HAS_CHOLMOD )
# link with CHOLMOD and its dependencies, both required and optional
if ( BUILD_SHARED_LIBS )
target_link_libraries ( UMFPACK PRIVATE SuiteSparse::CHOLMOD )
endif ( )
if ( BUILD_STATIC_LIBS )
set ( UMFPACK_STATIC_MODULES "${UMFPACK_STATIC_MODULES} CHOLMOD" )
if ( TARGET SuiteSparse::CHOLMOD_static )
target_link_libraries ( UMFPACK_static PRIVATE SuiteSparse::CHOLMOD_static )
else ( )
target_link_libraries ( UMFPACK_static PRIVATE SuiteSparse::CHOLMOD )
endif ( )
endif ( )
else ( )
# tell UMFPACK that CHOLMOD is not available
if ( BUILD_SHARED_LIBS )
target_compile_definitions ( UMFPACK PRIVATE NCHOLMOD )
endif ( )
if ( BUILD_STATIC_LIBS )
target_compile_definitions ( UMFPACK_static PRIVATE NCHOLMOD )
endif ( )
endif ( )
# libm:
include ( CheckSymbolExists )
check_symbol_exists ( fmax "math.h" NO_LIBM )
if ( NOT NO_LIBM )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( UMFPACK PRIVATE m )
endif ( )
if ( BUILD_STATIC_LIBS )
list ( APPEND UMFPACK_STATIC_LIBS "m" )
target_link_libraries ( UMFPACK_static PUBLIC m )
endif ( )
endif ( )
# BLAS:
message ( STATUS "BLAS libraries: ${BLAS_LIBRARIES}" )
message ( STATUS "BLAS include: ${BLAS_INCLUDE_DIRS}" )
message ( STATUS "BLAS linker flags: ${BLAS_LINKER_FLAGS}" )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( UMFPACK PRIVATE ${BLAS_LIBRARIES} )
target_include_directories ( UMFPACK PRIVATE ${BLAS_INCLUDE_DIRS} )
endif ( )
if ( BUILD_STATIC_LIBS )
list ( APPEND UMFPACK_STATIC_LIBS ${BLAS_LIBRARIES} )
target_link_libraries ( UMFPACK_static PUBLIC ${BLAS_LIBRARIES} )
target_include_directories ( UMFPACK_static PRIVATE ${BLAS_INCLUDE_DIRS} )
endif ( )
#-------------------------------------------------------------------------------
# check compiler features
#-------------------------------------------------------------------------------
include ( CheckSourceCompiles )
set ( _orig_CMAKE_C_FLAGS ${CMAKE_C_FLAGS} )
include ( CheckCCompilerFlag )
check_c_compiler_flag ( "-Wunknown-pragmas" HAVE_UNKNOWN_PRAGMAS )
if ( HAVE_UNKNOWN_PRAGMAS )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunknown-pragmas" )
endif ( )
# check syntax for ivdep pragma
set ( _pragma_found OFF )
# GCC compatible
check_source_compiles ( C
"int main(void) {
#pragma GCC ivdep
for (int j = 0; j < 1; j++) { }
return 0;
}"
HAVE_PRAGMA_GCC_IVDEP
FAIL_REGEX "[wW]arning" )
if ( HAVE_PRAGMA_GCC_IVDEP )
if ( BUILD_SHARED_LIBS )
target_compile_definitions ( UMFPACK PRIVATE "HAVE_PRAGMA_GCC_IVDEP" )
endif ( )
if ( BUILD_STATIC_LIBS )
target_compile_definitions ( UMFPACK_static PRIVATE "HAVE_PRAGMA_GCC_IVDEP" )
endif ( )
set ( _pragma_found ON )
endif ( )
# Clang compatible
if ( NOT _pragma_found )
check_source_compiles ( C
"int main(void) {
#pragma clang loop vectorize(enable)
for (int j = 0; j < 1; j++) { }
return 0;
}"
HAVE_PRAGMA_CLANG_LOOP_VECTORIZE
FAIL_REGEX "[wW]arning" )
if ( HAVE_PRAGMA_CLANG_LOOP_VECTORIZE )
# Clang is very verbose if a hint for vectorization cannot be performed.
# Disable the respective warning.
check_c_compiler_flag ( "-Wno-pass-failed" HAVE_NO_PASS_FAILED )
if ( BUILD_SHARED_LIBS )
target_compile_definitions ( UMFPACK PRIVATE "HAVE_PRAGMA_CLANG_LOOP_VECTORIZE" )
if ( HAVE_NO_PASS_FAILED )
target_compile_options ( UMFPACK PRIVATE "-Wno-pass-failed" )
endif ( )
endif ( )
if ( BUILD_STATIC_LIBS )
target_compile_definitions ( UMFPACK_static PRIVATE "HAVE_PRAGMA_CLANG_LOOP_VECTORIZE" )
if ( HAVE_NO_PASS_FAILED )
target_compile_options ( UMFPACK_static PRIVATE "-Wno-pass-failed" )
endif ( )
endif ( )
set ( _pragma_found ON )
endif ( )
endif ( )
# Intel compatible
if ( NOT _pragma_found )
check_source_compiles ( C
"int main(void) {
#pragma ivdep
for (int j = 0; j < 1; j++) { }
return 0;
}"
HAVE_PRAGMA_IVDEP
FAIL_REGEX "[wW]arning" )
if ( HAVE_PRAGMA_IVDEP )
if ( BUILD_SHARED_LIBS )
target_compile_definitions ( UMFPACK PRIVATE "HAVE_PRAGMA_IVDEP" )
endif ( )
if ( BUILD_STATIC_LIBS )
target_compile_definitions ( UMFPACK_static PRIVATE "HAVE_PRAGMA_IVDEP" )
endif ( )
set ( _pragma_found ON )
endif ( )
endif ( )
# MSVC compatible
if ( NOT _pragma_found )
check_source_compiles ( C
"int main(void) {
#pragma loop( ivdep )
for (int j = 0; j < 1; j++) { }
return 0;
}"
HAVE_PRAGMA_LOOP_IVDEP
FAIL_REGEX "[wW]arning" )
if ( HAVE_PRAGMA_LOOP_IVDEP )
if ( BUILD_SHARED_LIBS )
target_compile_definitions ( UMFPACK PRIVATE "HAVE_PRAGMA_LOOP_IVDEP" )
endif ( )
if ( BUILD_STATIC_LIBS )
target_compile_definitions ( UMFPACK_static PRIVATE "HAVE_PRAGMA_LOOP_IVDEP" )
endif ( )
set ( _pragma_found ON )
endif ( )
endif ( )
# check syntax for novector pragma
set ( _pragma_found ${HAVE_PRAGMA_CLANG_LOOP_VECTORIZE} )
# GCC compatible
if ( NOT _pragma_found )
check_source_compiles ( C
"int main(void) {
#pragma GCC novector
for (int j = 0; j < 1; j++) { }
return 0;
}"
HAVE_PRAGMA_GCC_NOVECTOR
FAIL_REGEX "[wW]arning" )
if ( HAVE_PRAGMA_GCC_NOVECTOR )
if ( BUILD_SHARED_LIBS )
target_compile_definitions ( UMFPACK PRIVATE "HAVE_PRAGMA_GCC_NOVECTOR" )
endif ( )
if ( BUILD_STATIC_LIBS )
target_compile_definitions ( UMFPACK_static PRIVATE "HAVE_PRAGMA_GCC_NOVECTOR" )
endif ( )
set ( _pragma_found ON )
endif ( )
endif ( )
# Intel compatible
if ( NOT _pragma_found )
check_source_compiles ( C
"int main(void) {
#pragma novector
for (int j = 0; j < 1; j++) { }
return 0;
}"
HAVE_PRAGMA_NOVECTOR
FAIL_REGEX "[wW]arning" )
if ( HAVE_PRAGMA_NOVECTOR )
if ( BUILD_SHARED_LIBS )
target_compile_definitions ( UMFPACK PRIVATE "HAVE_PRAGMA_NOVECTOR" )
endif ( )
if ( BUILD_STATIC_LIBS )
target_compile_definitions ( UMFPACK_static PRIVATE "HAVE_PRAGMA_NOVECTOR" )
endif ( )
set ( _pragma_found ON )
endif ( )
endif ( )
# MSVC compatible
if ( NOT _pragma_found )
check_source_compiles ( C
"int main(void) {
#pragma loop( no_vector )
for (int j = 0; j < 1; j++) { }
return 0;
}"
HAVE_PRAGMA_LOOP_NO_VECTOR
FAIL_REGEX "[wW]arning" )
if ( HAVE_PRAGMA_LOOP_NO_VECTOR )
if ( BUILD_SHARED_LIBS )
target_compile_definitions ( UMFPACK PRIVATE "HAVE_PRAGMA_LOOP_NO_VECTOR" )
endif ( )
if ( BUILD_STATIC_LIBS )
target_compile_definitions ( UMFPACK_static PRIVATE "HAVE_PRAGMA_LOOP_NO_VECTOR" )
endif ( )
set ( _pragma_found ON )
endif ( )
endif ( )
set ( CMAKE_C_FLAGS ${_orig_CMAKE_C_FLAGS} )
#-------------------------------------------------------------------------------
# UMFPACK installation location
#-------------------------------------------------------------------------------
include ( CMakePackageConfigHelpers )
if ( BUILD_SHARED_LIBS )
install ( TARGETS UMFPACK
EXPORT UMFPACKTargets
LIBRARY DESTINATION ${SUITESPARSE_LIBDIR}
ARCHIVE DESTINATION ${SUITESPARSE_LIBDIR}
RUNTIME DESTINATION ${SUITESPARSE_BINDIR}
PUBLIC_HEADER DESTINATION ${SUITESPARSE_INCLUDEDIR} )
endif ( )
if ( BUILD_STATIC_LIBS )
install ( TARGETS UMFPACK_static
EXPORT UMFPACKTargets
ARCHIVE DESTINATION ${SUITESPARSE_LIBDIR}
PUBLIC_HEADER DESTINATION ${SUITESPARSE_INCLUDEDIR} )
endif ( )
# create (temporary) export target file during build
export ( EXPORT UMFPACKTargets
NAMESPACE SuiteSparse::
FILE ${CMAKE_CURRENT_BINARY_DIR}/UMFPACKTargets.cmake )
# install export target, config and version files for find_package
install ( EXPORT UMFPACKTargets
NAMESPACE SuiteSparse::
DESTINATION ${SUITESPARSE_PKGFILEDIR}/cmake/UMFPACK )
# generate config file to be used in common build tree
set ( SUITESPARSE_IN_BUILD_TREE ON )
configure_package_config_file (
Config/UMFPACKConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/UMFPACKConfig.cmake
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/UMFPACKConfig.cmake )
# generate config file to be installed
set ( SUITESPARSE_IN_BUILD_TREE OFF )
configure_package_config_file (
Config/UMFPACKConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/target/UMFPACKConfig.cmake
INSTALL_DESTINATION ${SUITESPARSE_PKGFILEDIR}/cmake/UMFPACK )
write_basic_package_version_file (
${CMAKE_CURRENT_BINARY_DIR}/UMFPACKConfigVersion.cmake
COMPATIBILITY SameMajorVersion )
install ( FILES
${CMAKE_CURRENT_BINARY_DIR}/target/UMFPACKConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/UMFPACKConfigVersion.cmake
DESTINATION ${SUITESPARSE_PKGFILEDIR}/cmake/UMFPACK )
#-------------------------------------------------------------------------------
# create pkg-config file
#-------------------------------------------------------------------------------
if ( NOT MSVC )
# This might be something like:
# /usr/lib/libgomp.so;/usr/lib/libpthread.a;m
# convert to -l flags for pkg-config, i.e.: "-lgomp -lpthread -lm"
set ( UMFPACK_STATIC_LIBS_LIST ${UMFPACK_STATIC_LIBS} )
set ( UMFPACK_STATIC_LIBS "" )
foreach ( _lib ${UMFPACK_STATIC_LIBS_LIST} )
string ( FIND ${_lib} "." _pos REVERSE )
if ( ${_pos} EQUAL "-1" )
set ( UMFPACK_STATIC_LIBS "${UMFPACK_STATIC_LIBS} -l${_lib}" )
continue ()
endif ( )
set ( _kinds "SHARED" "STATIC" )
if ( WIN32 )
list ( PREPEND _kinds "IMPORT" )
endif ( )
foreach ( _kind IN LISTS _kinds )
set ( _regex ".*\\/(lib)?([^\\.]*)(${CMAKE_${_kind}_LIBRARY_SUFFIX})" )
if ( ${_lib} MATCHES ${_regex} )
string ( REGEX REPLACE ${_regex} "\\2" _libname ${_lib} )
if ( NOT "${_libname}" STREQUAL "" )
set ( UMFPACK_STATIC_LIBS "${UMFPACK_STATIC_LIBS} -l${_libname}" )
break ()
endif ( )
endif ( )
endforeach ( )
endforeach ( )
set ( prefix "${CMAKE_INSTALL_PREFIX}" )
set ( exec_prefix "\${prefix}" )
cmake_path ( IS_ABSOLUTE SUITESPARSE_LIBDIR SUITESPARSE_LIBDIR_IS_ABSOLUTE )
if (SUITESPARSE_LIBDIR_IS_ABSOLUTE)
set ( libdir "${SUITESPARSE_LIBDIR}")
else ( )
set ( libdir "\${exec_prefix}/${SUITESPARSE_LIBDIR}")
endif ( )
cmake_path ( IS_ABSOLUTE SUITESPARSE_INCLUDEDIR SUITESPARSE_INCLUDEDIR_IS_ABSOLUTE )
if (SUITESPARSE_INCLUDEDIR_IS_ABSOLUTE)
set ( includedir "${SUITESPARSE_INCLUDEDIR}")
else ( )
set ( includedir "\${prefix}/${SUITESPARSE_INCLUDEDIR}")
endif ( )
if ( BUILD_SHARED_LIBS )
set ( SUITESPARSE_LIB_BASE_NAME $<TARGET_FILE_BASE_NAME:UMFPACK> )
else ( )
set ( SUITESPARSE_LIB_BASE_NAME $<TARGET_FILE_BASE_NAME:UMFPACK_static> )
endif ( )
configure_file (
Config/UMFPACK.pc.in
UMFPACK.pc.out
@ONLY
NEWLINE_STYLE LF )
file ( GENERATE
OUTPUT UMFPACK.pc
INPUT ${CMAKE_CURRENT_BINARY_DIR}/UMFPACK.pc.out
NEWLINE_STYLE LF )
install ( FILES
${CMAKE_CURRENT_BINARY_DIR}/UMFPACK.pc
DESTINATION ${SUITESPARSE_PKGFILEDIR}/pkgconfig )
endif ( )
#-------------------------------------------------------------------------------
# Demo library and programs
#-------------------------------------------------------------------------------
if ( SUITESPARSE_DEMOS )
#---------------------------------------------------------------------------
# demo library
#---------------------------------------------------------------------------
message ( STATUS "Also compiling the demos in UMFPACK/Demo" )
#---------------------------------------------------------------------------
# Demo programs
#---------------------------------------------------------------------------
add_executable ( umfpack_simple "Demo/umfpack_simple.c" )
add_executable ( umfpack_di_demo "Demo/umfpack_di_demo.c" )
add_executable ( umfpack_dl_demo "Demo/umfpack_dl_demo.c" )
add_executable ( umfpack_zi_demo "Demo/umfpack_zi_demo.c" )
add_executable ( umfpack_zl_demo "Demo/umfpack_zl_demo.c" )
if ( SUITESPARSE_HAS_FORTRAN )
# Fortran demos
add_executable ( umf4 "Demo/umf4.c" )
add_executable ( umfreadhb "Demo/readhb.f" )
set_target_properties ( umfreadhb PROPERTIES OUTPUT_NAME readhb )
add_executable ( umfreadhb_nozeros "Demo/readhb_nozeros.f" )
set_target_properties ( umfreadhb_nozeros PROPERTIES OUTPUT_NAME readhb_nozeros )
add_executable ( umfreadhb_size "Demo/readhb_size.f" )
set_target_properties ( umfreadhb_size PROPERTIES OUTPUT_NAME readhb_size )
add_executable ( umf4hb "Demo/umf4hb.f"
"Demo/umf4_f77wrapper.c" )
add_executable ( umf4zhb "Demo/umf4zhb.f"
"Demo/umf4_f77zwrapper.c" )
add_executable ( umf4hb64 "Demo/umf4hb64.f"
"Demo/umf4_f77wrapper64.c" )
add_executable ( umf4zhb64 "Demo/umf4zhb64.f"
"Demo/umf4_f77zwrapper64.c" )
endif ( )
# Libraries required for Demo programs
if ( BUILD_SHARED_LIBS )
target_link_libraries ( umfpack_simple PUBLIC UMFPACK )
target_link_libraries ( umfpack_di_demo PUBLIC UMFPACK )
target_link_libraries ( umfpack_dl_demo PUBLIC UMFPACK )
target_link_libraries ( umfpack_zi_demo PUBLIC UMFPACK )
target_link_libraries ( umfpack_zl_demo PUBLIC UMFPACK )
else ( )
target_link_libraries ( umfpack_simple PUBLIC UMFPACK_static )
target_link_libraries ( umfpack_di_demo PUBLIC UMFPACK_static )
target_link_libraries ( umfpack_dl_demo PUBLIC UMFPACK_static )
target_link_libraries ( umfpack_zi_demo PUBLIC UMFPACK_static )
target_link_libraries ( umfpack_zl_demo PUBLIC UMFPACK_static )
endif ( )
target_link_libraries ( umfpack_simple PUBLIC SuiteSparse::SuiteSparseConfig )
if ( SUITESPARSE_HAS_FORTRAN )
# Fortran demos
if ( BUILD_SHARED_LIBS )
target_link_libraries ( umf4 PUBLIC UMFPACK )
target_link_libraries ( umf4hb PUBLIC UMFPACK )
target_link_libraries ( umf4zhb PUBLIC UMFPACK )
target_link_libraries ( umf4hb64 PUBLIC UMFPACK )
target_link_libraries ( umf4zhb64 PUBLIC UMFPACK )
else ( )
target_link_libraries ( umf4 PUBLIC UMFPACK_static )
target_link_libraries ( umf4hb PUBLIC UMFPACK_static )
target_link_libraries ( umf4zhb PUBLIC UMFPACK_static )
target_link_libraries ( umf4hb64 PUBLIC UMFPACK_static )
target_link_libraries ( umf4zhb64 PUBLIC UMFPACK_static )
endif ( )
target_link_libraries ( umf4 PUBLIC SuiteSparse::AMD )
endif ( )
else ( )
message ( STATUS "Skipping the demos in UMFPACK/Demo" )
endif ( )
#-------------------------------------------------------------------------------
# report status
#-------------------------------------------------------------------------------
include ( SuiteSparseReport )