forked from robertu94/libpressio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
697 lines (629 loc) · 26.5 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
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(libpressio VERSION "0.83.4" LANGUAGES CXX C)
#correct was to set a default build type
# https://blog.kitware.com/cmake-and-the-default-build-type/
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type was set. Setting build type to ${default_build_type}.")
set(CMAKE_BUILD_TYPE ${default_build_type} CACHE
STRING "Choose the type to build" FORCE)
endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
include(CTest)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(BUILD_SHARED_LIBS "build libpressio as a shared library" ON)
include(GNUInstallDirs)
include(CheckCXXCompilerFlag)
include(CMakeDependentOption)
if(NOT USE_SANITIZER)
set(USE_SANITIZER "" CACHE STRING "use a build sanitizer" FORCE)
endif()
set_property(CACHE USE_SANITIZER PROPERTY STRINGS "" "Address" "Thread" "Undefined" "Leak" "Memory")
if (USE_SANITIZER STREQUAL "Address")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
elseif (USE_SANITIZER STREQUAL "Thread")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
elseif (USE_SANITIZER STREQUAL "Undefined")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
elseif (USE_SANITIZER STREQUAL "Leak")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=leak")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
elseif (USE_SANITIZER STREQUAL "Memory")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory")
endif()
check_cxx_compiler_flag("-fno-omit-frame-pointer" HAVE_NO_OMIT_FRAME_POINTER)
set(NO_OMIT_FRAME_POINTER_FLAG "")
if(HAVE_NO_OMIT_FRAME_POINTER)
set(NO_OMIT_FRAME_POINTER_FLAG "-fno-omit-frame-pointer")
endif()
set(LIBPRESSIO_FEATURES "")
set(LIBPRESSIO_COMPRESSORS "noop")
add_library(libpressio
#core implementation
./src/pressio.cc
./src/pressio_posix.cc
./src/pressio_configurable.cc
./src/pressio_versionable.cc
./src/pressio_errorable.cc
./src/pressio_compressor.cc
./src/pressio_data.cc
./src/pressio_dtype.cc
./src/pressio_metrics.cc
./src/pressio_option.cc
./src/pressio_options.cc
./src/pressio_options_iter.cc
#plugins
./src/plugins/compressors/compressor_base.cc
./src/plugins/compressors/noop.cc
./src/plugins/compressors/pressio.cc
./src/plugins/metrics/composite.cc
./src/plugins/metrics/external.cc
./src/plugins/metrics/metrics_base.cc
./src/plugins/launch/external_forkexec.cc
./src/plugins/metrics/noop.cc
./src/plugins/io/noop.cc
./src/plugins/io/io.cc
./src/plugins/io/posix.cc
./src/iless.cc
#public headers
include/libpressio.h
include/libpressio_ext/cpp/compressor.h
include/libpressio_ext/cpp/configurable.h
include/libpressio_ext/cpp/data.h
include/libpressio_ext/cpp/errorable.h
include/libpressio_ext/cpp/io.h
include/libpressio_ext/cpp/libpressio.h
include/libpressio_ext/cpp/metrics.h
include/libpressio_ext/cpp/options.h
include/libpressio_ext/cpp/pressio.h
include/libpressio_ext/cpp/printers.h
include/libpressio_ext/cpp/subgroup_manager.h
include/libpressio_ext/cpp/versionable.h
include/libpressio_ext/io/posix.h
include/libpressio_ext/io/pressio_io.h
include/pressio.h
include/pressio_compressor.h
include/pressio_data.h
include/pressio_dtype.h
include/pressio_metrics.h
include/pressio_option.h
include/pressio_options.h
include/pressio_options_iter.h
)
if(NOT LIBPRESSIO_BUILD_MODE)
set(LIBPRESSIO_BUILD_MODE FULL CACHE STRING "enable sets of plugins" FORCE)
set_property(CACHE LIBPRESSIO_BUILD_MODE PROPERTY STRINGS "CORE" "FULL")
else()
set(LIBPRESSIO_BUILD_MODE ${LIBPRESSIO_BUILD_MODE} CACHE STRING "enable sets of plugins" FORCE)
set_property(CACHE LIBPRESSIO_BUILD_MODE PROPERTY STRINGS "CORE" "FULL")
endif()
#optional components created with libpressio_optional_component don't require dependencies
#they can be enabled in two (non-exclusive) ways:
# 1 by 1 using -DLIBPRESSIO_HAS_${NAME}=ON
# enabling sets of plugins organized by level LIBPRESSIO_BUILD_MODE=${level}
# CORE -- build no plugins except noop's and the composite metric
# FULL -- build all optional plugins that don't have additional dependencies
function(libpressio_optional_component name description file_names)
string(TOUPPER "${name}" name_upper)
option("LIBPRESSIO_HAS_${name_upper}" ${description} OFF)
if(LIBPRESSIO_HAS_${name_upper} OR LIBPRESSIO_BUILD_MODE STREQUAL FULL)
foreach(file_name IN LISTS file_names)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/${file_name}
)
endforeach()
endif()
endfunction()
libpressio_optional_component(pw_rel "build the pw_rel compressor plugin" /compressors/pw_rel.cc)
libpressio_optional_component(csv "build the CSV io plugin" /io/csv.cc)
libpressio_optional_component(numpy "build the numpy io plugin" /io/numpy.cc)
libpressio_optional_component(size "build the size metrics plugin" /metrics/size.cc)
libpressio_optional_component(time "build the time metrics plugin" /metrics/time.cc)
libpressio_optional_component(autocorr "build the autocorr metrics plugin" /metrics/autocorr.cc)
libpressio_optional_component(chunking "build the chunking compressor plugin" "/compressors/chunking.cc;/compressors/chunking_impl.cc")
libpressio_optional_component(delta_encoding "build the delta_encoding compressor plugin" /compressors/delta_encoding.cc)
libpressio_optional_component(diff_pdf "build the difference probability distribution function metric" /metrics/diff_pdf.cc)
libpressio_optional_component(empty "build the empty IO plugin" /io/empty.cc)
libpressio_optional_component(entropy "build the entropy metrics plugin" /metrics/entropy.cc)
libpressio_optional_component(error_stat "build the error_stat metrics plugin" /metrics/error_stat.cc)
libpressio_optional_component(historian "build the historian metrics plugin" /metrics/historian.cc)
libpressio_optional_component(input_stats "build the input_stats metrics plugin" /metrics/input_stats.cc)
libpressio_optional_component(iota "build the iota io plugin" /io/iota.cc)
libpressio_optional_component(kl_divergance "build the kl_divergance plugin" /metrics/kl_divergance.cc)
libpressio_optional_component(ks_test "build the KS test metrics plugin" /metrics/ks_test.cc)
libpressio_optional_component(kth_error "build the kth error metrics plugin" /metrics/kth_error.cc)
libpressio_optional_component(linear_quantizer "build the linear quantizer compressor plugin" /compressors/linear_quantizer.cc)
libpressio_optional_component(log_transform "build the log_transform compressor plugin" /compressors/log_transform.cc)
libpressio_optional_component(mask1d "build the mask1d metrics plugin" /metrics/mask1d.cc)
libpressio_optional_component(pearsons "build the pearsons metrics plugin" /metrics/pearsons.cc)
libpressio_optional_component(printer "build the printer metrics plugin" /metrics/printer.cc)
libpressio_optional_component(region_of_interest "build the region_of_interest metrics plugin" /metrics/region_of_interest.cc)
libpressio_optional_component(resize "build the resize compressor plugin" /compressors/resize.cc)
libpressio_optional_component(sampling "build the sampling compressors plugin" /compressors/sampling.cc)
libpressio_optional_component(select "build the io selection plugin" /io/select.cc)
libpressio_optional_component(switch "build the switch comprssor plugin" /compressors/switch.cc)
libpressio_optional_component(transpose "build the transpose compressor plugin" /compressors/transpose.cc)
libpressio_optional_component(print_options "print the options passed to set_options" /metrics/print_options.cc)
set(roibin_sources /compressors/roibin.cc /compressors/binning.cc)
libpressio_optional_component(roibin "build the roibin metacompressor" "${roibin_sources}")
option(LIBPRESSIO_INTERPROCEDURAL_OPTIMIZATION "Use interprocedural optimization (LTO)" OFF)
if(LIBPRESSIO_INTERPROCEDURAL_OPTIMIZATION)
cmake_policy(CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERR_MSG LANGUAGES CXX)
if(IPO_SUPPORTED)
set_target_properties(libpressio PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(ERROR "IPO was not supported: ${IPO_ERR_MSG}")
endif()
endif()
target_include_directories(libpressio
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
)
target_include_directories(libpressio
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpressio>
)
target_compile_options(libpressio PRIVATE
$<$<CONFIG:Debug>: -Wall -Wextra -Wpedantic>
$<$<CONFIG:RelWithDebInfo>: ${NO_OMIT_FRAME_POINTER_FLAG}>
)
option(LIBPRESSIO_TREAT_WARNINGS_AS_ERRORS "treat compiler warnings as errors" OFF)
if(LIBPRESSIO_TREAT_WARNINGS_AS_ERRORS)
target_compile_options(libpressio PRIVATE -Werror)
endif()
find_package(PkgConfig REQUIRED)
find_package(std_compat REQUIRED)
target_link_libraries(libpressio PUBLIC std_compat::std_compat)
option(LIBPRESSIO_HAS_OPENMP "accerate some plugins with OpenMP" OFF)
if(LIBPRESSIO_HAS_OPENMP)
find_package(OpenMP)
target_link_libraries(libpressio PRIVATE OpenMP::OpenMP_CXX)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/metrics/spatial_error.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/many_independent_threaded.cc
)
endif()
option(LIBPRESSIO_HAS_LINUX "plugins that depend on various unixisms" OFF)
if(LIBPRESSIO_HAS_LINUX)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/metrics/rusage.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/io/mmap.cc
)
endif()
option(LIBPRESSIO_HAS_ARC "build the ARC plugin" OFF)
if(LIBPRESSIO_HAS_ARC)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} ARC")
find_package(ARC REQUIRED)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/arc.cc
)
target_link_libraries(libpressio PRIVATE ARC::arc)
endif()
option(LIBPRESSIO_HAS_DIGIT_ROUNDING "build the DIGIT ROUNDING plugin" OFF)
if(LIBPRESSIO_HAS_DIGIT_ROUNDING)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} DR")
find_package(dround REQUIRED)
find_package(ZLIB REQUIRED)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/digit_rounding_plugin.cc
)
target_link_libraries(libpressio PRIVATE dround ZLIB::ZLIB)
endif()
option(LIBPRESSIO_HAS_BZIP2 "build the BZIP plugin" OFF)
if(LIBPRESSIO_HAS_BZIP2)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} BZIP2")
find_package(BZip2 REQUIRED)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/bzip2.cc
)
target_link_libraries(libpressio PRIVATE BZip2::BZip2)
endif()
option(LIBPRESSIO_HAS_BIT_GROOMING "build the BIT GROOMING plugin" OFF)
if(LIBPRESSIO_HAS_BIT_GROOMING)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} BG")
find_package(bg REQUIRED)
find_package(ZLIB REQUIRED)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/bit_groooming_plugin.cc
)
target_link_libraries(libpressio PRIVATE bg ZLIB::ZLIB)
endif()
option(LIBPRESSIO_HAS_SZ_AUTO "build the SZauto plugin" OFF)
if(LIBPRESSIO_HAS_SZ_AUTO)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} SZauto")
find_package(szauto REQUIRED)
pkg_search_module(ZSTD IMPORTED_TARGET GLOBAL libzstd)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/sz_auto_plugin.cc
)
target_link_libraries(libpressio PRIVATE szauto::sz_cpp)
endif()
option(LIBPRESSIO_HAS_MGARDx "build the MGARDx plugin" OFF)
if(LIBPRESSIO_HAS_MGARDx)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} MGARDx")
find_package(MGARDx)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/MGARDx_plugin.cc
)
target_link_libraries(libpressio PRIVATE MGARDx::MGARDx)
endif()
option(LIBPRESSIO_HAS_MGARD "build the MGARD plugin" OFF)
if(LIBPRESSIO_HAS_MGARD)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} mgard")
find_package(mgard REQUIRED)
if(DEFINED mgard_VERSION_MAJOR AND ${mgard_VERSION_MAJOR} GREATER_EQUAL 1)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/mgard-1.0_plugin.cc
)
target_link_libraries(libpressio PRIVATE mgard::mgard)
else()
find_file(LIBPRESSIO_MGARD_NEED_FLOAT_HEADER mgard_api_float.h)
find_file(LIBPRESSIO_MGARD_HAS_CONFIG_HEADER MGARDConfig.h)
find_file(LIBPRESSIO_MGARD_HAS_CONFIG_HEADER_HPP MGARDConfig.hpp PATH_SUFFIXES mgard)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/mgard_plugin.cc
)
if(TARGET mgard::mgard)
target_link_libraries(libpressio PRIVATE mgard::mgard)
elseif(TARGET mgard::mgard_library)
target_link_libraries(libpressio PRIVATE mgard::mgard_library)
endif()
endif()
endif()
option(LIBPRESSIO_HAS_ZFP "build the ZFP plugin" OFF)
if(LIBPRESSIO_HAS_ZFP)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} zfp")
find_package(ZFP REQUIRED)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/zfp_plugin.cc
)
target_link_libraries(libpressio PRIVATE zfp::zfp)
endif()
option(LIBPRESSIO_HAS_SZ3 "build the SZ3 plugin" OFF)
if(LIBPRESSIO_HAS_SZ3)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} sz3")
find_package(SZ3 REQUIRED)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/sz3.cc
)
target_link_libraries(libpressio PRIVATE SZ3::SZ3)
endif()
option(LIBPRESSIO_HAS_SZ "build the SZ plugin" OFF)
if(LIBPRESSIO_HAS_SZ)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} sz")
find_package(SZ REQUIRED)
find_package(ZLIB REQUIRED)
pkg_search_module(ZSTD IMPORTED_TARGET GLOBAL libzstd)
pkg_search_module(FFTW3 QUIET IMPORTED_TARGET GLOBAL fftw3)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/sz_plugin.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/sz_omp.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/sz_threadsafe_plugin.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/sz_common.cc
)
target_link_libraries(libpressio PRIVATE SZ)
target_include_directories(libpressio PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors)
endif()
option(LIBPRESSIO_HAS_BLOSC "build the BLOSC plugin" OFF)
if(LIBPRESSIO_HAS_BLOSC)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} blosc")
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/blosc_plugin.cc
)
pkg_search_module(BLOSC IMPORTED_TARGET GLOBAL blosc)
if(BLOSC_FOUND)
target_link_libraries(libpressio PRIVATE PkgConfig::BLOSC)
else()
find_library(BLOSC_LIBRARIES blosc)
find_file(BLOSC_INCLUDE_FILE blosc.h)
if(NOT BLOSC_LIBRARIES)
message(FATAL_ERROR "Failed to find blosc and it was enabled")
endif()
get_filename_component(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_FILE} DIRECTORY)
target_link_libraries(libpressio PRIVATE ${BLOSC_LIBRARIES})
target_include_directories(libpressio PRIVATE ${BLOSC_INCLUDE_DIRS})
endif()
endif()
option(LIBPRESSIO_HAS_MAGICK "build the image magick plugin" OFF)
if(LIBPRESSIO_HAS_MAGICK)
pkg_search_module(Magick++ IMPORTED_TARGET GLOBAL Magick++)
try_compile(
LIBPRESSIO_COMPAT_HAS_IMAGEMAGICK_LONGLONG
${CMAKE_BINARY_DIR}
SOURCES "${CMAKE_SOURCE_DIR}/checks/imagemagick_longlong.cc"
LINK_LIBRARIES PkgConfig::Magick++
)
message(STATUS "Checking for Magick::LongLong: ${LIBPRESSIO_COMPAT_HAS_IMAGEMAGICK_LONGLONG}")
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} magick")
target_link_libraries(libpressio PRIVATE PkgConfig::Magick++)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/magick++.cc
)
endif()
option(LIBPRESSIO_HAS_NETCDF "build the netcdf io plugin" OFF)
if(LIBPRESSIO_HAS_NETCDF)
set(LIBPRESSIO_FEATURES "${LIBPRESSIO_FEATURES} netcdf")
find_package(PkgConfig)
pkg_search_module(NetCDF REQUIRED IMPORTED_TARGET GLOBAL netcdf)
target_link_libraries(libpressio PRIVATE PkgConfig::NetCDF)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/io/netcdf.cc
)
endif()
option(LIBPRESSIO_HAS_CUFILE "build the cufile io plugin" OFF)
if(LIBPRESSIO_HAS_CUFILE)
set(LIBPRESSIO_FEATURES "${LIBPRESSIO_FEATURES} cufile")
find_package(CUDAToolkit REQUIRED)
find_library(CUFile_LIBRARY cufile PATHS ${CUDAToolkit_LIBRARY_DIR} REQUIRED)
target_link_libraries(libpressio PRIVATE CUDA::cuda_driver CUDA::cudart ${CUFile_LIBRARY})
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/io/cufile.cc
)
endif()
option(LIBPRESSIO_HAS_HDF "build the hdf5 io plugin" OFF)
if(LIBPRESSIO_HAS_HDF)
set(LIBPRESSIO_FEATURES "${LIBPRESSIO_FEATURES} hdf5")
find_package(HDF5 REQUIRED COMPONENTS C)
target_link_libraries(libpressio PRIVATE ${HDF5_C_LIBRARIES})
target_include_directories(libpressio PRIVATE ${HDF5_C_INCLUDE_DIRS})
target_compile_definitions(libpressio PRIVATE ${HDF5_C_DEFINITIONS})
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/io/hdf5.cc
${CMAKE_CURRENT_SOURCE_DIR}/include/libpressio_ext/io/hdf5.h
)
endif()
option(LIBPRESSIO_HAS_NDZIP "build the ndzip plugin" OFF)
if(LIBPRESSIO_HAS_NDZIP)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} ndzip")
find_package(NDZip)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/ndzip.cc
)
target_link_libraries(libpressio PRIVATE NDZip::ndzip)
if(TARGET NDZip::ndzip-cuda)
target_link_libraries(libpressio PRIVATE NDZip::ndzip-cuda)
endif()
if(TARGET NDZip::ndzip-sycl)
target_link_libraries(libpressio PRIVATE NDZip::ndzip-sycl)
endif()
endif()
option(LIBPRESSIO_HAS_FPZIP "build the fpzip plugin" OFF)
if(LIBPRESSIO_HAS_FPZIP)
set(LIBPRESSIO_COMPRESSORS "${LIBPRESSIO_COMPRESSORS} fpzip")
find_package(fpzip)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/fpzip_plugin.cc
)
target_link_libraries(libpressio PRIVATE fpzip::fpzip)
endif()
option(LIBPRESSIO_HAS_MPI "build MPI spawn external method" OFF)
cmake_dependent_option(LIBPRESSIO_HAS_MPI4PY "build mpi support for the python binding" OFF "LIBPRESSIO_HAS_MPI" OFF)
if(LIBPRESSIO_HAS_MPI)
set(LIBPRESSIO_FEATURES "${LIBPRESSIO_FEATURES} mpi")
find_package(MPI COMPONENTS CXX)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/launch/external_mpispawn.cc
)
target_link_libraries(libpressio PRIVATE MPI::MPI_CXX)
endif()
option(LIBPRESSIO_HAS_PETSC "build the petsc io plugin" OFF)
if(LIBPRESSIO_HAS_PETSC)
set(LIBPRESSIO_FEATURES "${LIBPRESSIO_FEATURES} petsc")
pkg_search_module(PETSc IMPORTED_TARGET PETSc)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/io/petsc.cc
)
target_link_libraries(libpressio PRIVATE PkgConfig::PETSc)
endif()
option(LIBPRESSIO_HAS_LUA "build multi-objective code" OFF)
if(LIBPRESSIO_HAS_LUA)
set(LIBPRESSIO_FEATURES "${LIBPRESSIO_FEATURES} lua")
find_package(sol2 REQUIRED)
pkg_search_module(Lua IMPORTED_TARGET lua luajit)
if(Lua_FOUND)
message(INFO "lua from pkgconfig")
target_link_libraries(libpressio PRIVATE PkgConfig::Lua)
else()
message(INFO "lua from cmake")
find_package(Lua)
target_link_libraries(libpressio PRIVATE ${LUA_LIBRARIES})
target_include_directories(libpressio PRIVATE ${LUA_INCLUDE_DIR})
endif()
target_sources(libpressio PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/lambda_fn.cc
)
endif()
option(LIBPRESSIO_HAS_LIBDISTRIBUTED "build plugins based on distributed work queues" OFF)
if(LIBPRESSIO_HAS_LIBDISTRIBUTED)
set(LIBPRESSIO_FEATURES "${LIBPRESSIO_FEATURES} distributed")
find_package(LibDistributed)
target_link_libraries(libpressio PRIVATE LibDistributed::libdistributed)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/many_dependent.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/many_independent.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/serializable.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/pressio_distributed_manager.cc
${CMAKE_CURRENT_SOURCE_DIR}/include/libpressio_ext/cpp/distributed_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/include/libpressio_ext/cpp/serializable.h
)
endif()
option(LIBPRESSIO_HAS_JSON "build the options json serialization support" OFF)
if(LIBPRESSIO_HAS_JSON)
set(LIBPRESSIO_FEATURES "${LIBPRESSIO_FEATURES} json")
find_package(nlohmann_json REQUIRED)
target_link_libraries(libpressio PRIVATE nlohmann_json::nlohmann_json)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/pressio_options_json.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/compressors/manifest.cc
${CMAKE_CURRENT_SOURCE_DIR}/include/libpressio_ext/json/pressio_options_json.h
${CMAKE_CURRENT_SOURCE_DIR}/include/libpressio_ext/cpp/json.h
)
endif()
option(LIBPRESSIO_HAS_REMOTELAUNCH "build the remote external launch plugin" OFF)
if(LIBPRESSIO_HAS_REMOTELAUNCH)
set(LIBPRESSIO_FEATURES "${LIBPRESSIO_FEATURES} remotelaunch")
find_package(nlohmann_json REQUIRED)
find_package(CURL REQUIRED)
target_link_libraries(libpressio PRIVATE nlohmann_json::nlohmann_json CURL::libcurl)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/launch/external_remotelaunch.cc
)
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/pressio_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/include/pressio_version.h
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/libpressio.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libpressio.pc
@ONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/libpressio_cxx.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libpressio_cxx.pc
@ONLY
)
target_sources(libpressio
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include/pressio_version.h
)
option(USE_CLANG_TIDY "include clang-tidy warnings in the build log" OFF)
if(USE_CLANG_TIDY)
find_program(CLANG_TIDY clang-tidy)
set_target_properties(libpressio PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
set_target_properties(libpressio PROPERTIES C_CLANG_TIDY "${CLANG_TIDY}")
endif()
option(USE_INCLUDE_WHAT_YOU_USE "include include-what-you-use warnings in the build log" OFF)
if(USE_INCLUDE_WHAT_YOU_USE)
find_program(INCLUDE_WHAT_YOU_USE include-what-you-use)
set_target_properties(libpressio PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "${INCLUDE_WHAT_YOU_USE}")
set_target_properties(libpressio PROPERTIES C_INCLUDE_WHAT_YOU_USE "${INCLUDE_WHAT_YOU_USE}")
endif()
export(TARGETS libpressio NAMESPACE LibPressio:: FILE LibPressio.cmake)
install(TARGETS libpressio EXPORT LibPressioConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(EXPORT LibPressioConfig NAMESPACE LibPressio:: DESTINATION share/LibPressio/cmake)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libpressio)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/pressio_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libpressio)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpressio.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pkgconfig)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpressio_cxx.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pkgconfig)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
option(BUILD_PYTHON_WRAPPER "build python wrapper" OFF)
if(BUILD_PYTHON_WRAPPER)
add_subdirectory(tools/swig)
endif()
if(LIBPRESSIO_HAS_JSON AND LIBPRESSIO_HAS_HDF)
add_subdirectory(tools/hdf5_filter)
endif()
option(BUILD_DOCS "build the documetation" OFF)
if(BUILD_DOCS)
add_subdirectory(tools/docs)
option(BUILD_DOCS_LINKS "build the documetation" ON)
find_package(Doxygen REQUIRED dot)
if(BUILD_DOCS_LINKS)
set(DOXYGEN_MAN_LINKS YES)
else()
set(DOXYGEN_MAN_LINKS NO)
endif()
set(DOXYGEN_GENERATE_MAN YES)
set(DOXYGEN_GENERATE_HTML YES)
set(DOXYGEN_EXTRACT_LOCAL_METHODS YES)
set(DOXYGEN_EXTRACT_STATIC YES)
set(DOXYGEN_MACRO_EXPANSION YES)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
option(LIBPRESSIO_INSTALL_DOCS "build the documetation by default" OFF)
if(LIBPRESSIO_INSTALL_DOCS)
set(LIBPRESSIO_BUILD_DOCS_DEFAULT "ALL")
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/" DESTINATION "${CMAKE_INSTALL_DOCDIR}")
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/man/" DESTINATION "${CMAKE_INSTALL_MANDIR}")
else()
set(LIBPRESSIO_BUILD_DOCS_DEFAULT "")
endif()
add_custom_command(
OUTPUT "IO.md"
COMMAND generate_docs -m i -o "${CMAKE_BINARY_DIR}/IO.md"
DEPENDS generate_docs libpressio
COMMENT "Documenting IO"
)
add_custom_command(
OUTPUT "Compressors.md"
COMMAND generate_docs -m c -o "${CMAKE_BINARY_DIR}/Compressors.md"
DEPENDS generate_docs libpressio
COMMENT "Documenting Compressors"
)
add_custom_command(
OUTPUT "Metrics.md"
COMMAND generate_docs -m m -o "${CMAKE_BINARY_DIR}/Metrics.md"
DEPENDS generate_docs libpressio
COMMENT "Documenting Metrics"
)
doxygen_add_docs(
docs
${PROJECT_SOURCE_DIR}/README.md
${PROJECT_SOURCE_DIR}/CONTRIBUTORS.md
${PROJECT_SOURCE_DIR}/docs
${PROJECT_BINARY_DIR}/Compressors.md
${PROJECT_BINARY_DIR}/Metrics.md
${PROJECT_BINARY_DIR}/IO.md
${PROJECT_SOURCE_DIR}/include
${LIBPRESSIO_BUILD_DOCS_DEFAULT}
COMMENT "Generate Documenation"
)
endif()
option(BUILD_DOCKER_CONTAINERS "build docker containers for testing" OFF)
if(BUILD_DOCKER_CONTAINERS)
foreach(CONTAINER Fedora Ubuntu18.04 CentOS)
set(BuildSentinel ${CMAKE_BINARY_DIR}/${CONTAINER}-built)
set(Dockerfile docker/Dockerfile-${CONTAINER})
string(TOLOWER "libpressio-${CONTAINER}" CONTAINER_TAG)
add_custom_command(OUTPUT ${BuildSentinel}
COMMAND docker build -t ${CONTAINER_TAG} -f ${Dockerfile} .
COMMAND touch ${BuildSentinel}
MAIN_DEPENDENCY ${Dockerfile}
DEPENDS libpressio
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "DOCKER ${Dockerfile}"
)
list(APPEND DOCKER_CONTAINERS ${BuildSentinel})
endforeach()
add_custom_target(docker DEPENDS ${DOCKER_CONTAINERS} COMMENT "building docker containers")
endif()