-
Notifications
You must be signed in to change notification settings - Fork 262
/
CMakeLists.txt
1947 lines (1651 loc) · 66.3 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
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
## This is a CMake file, part of Unidata's netCDF package.
# Copyright 2012-2018, see the COPYRIGHT file for more information.
#
##################################
# Set Project Properties
##################################
cmake_minimum_required(VERSION 3.20.0)
#Project Name
project(netCDF
LANGUAGES C CXX
HOMEPAGE_URL "https://www.unidata.ucar.edu/software/netcdf/"
DESCRIPTION "NetCDF is a set of software libraries and machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data."
VERSION 4.9.4
)
#####
# Version Info:
#
# Release Version
# Library Version
# SO Version
#
# SO Version is computed from library version. See:
# http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
#####
set(NC_VERSION_NOTE "-development")
set(netCDF_VERSION ${PROJECT_VERSION}${NC_VERSION_NOTE})
set(VERSION ${netCDF_VERSION})
set(NC_VERSION ${netCDF_VERSION})
set(PACKAGE_VERSION ${VERSION})
# These values should match those in configure.ac
set(netCDF_LIB_VERSION 22)
set(netCDF_SO_VERSION 22)
#Add custom CMake Module
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${PROJECT_SOURCE_DIR}/cmake")
set(PACKAGE "netCDF" CACHE STRING "")
include(netcdf_functions_macros)
include(deprecated)
# Backport of built-in `PROJECT_IS_TOP_LEVEL` from CMake 3.21
if (NOT DEFINED NETCDF_IS_TOP_LEVEL)
set(NETCDF_IS_TOP_LEVEL OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(NETCDF_IS_TOP_LEVEL ON)
endif ()
endif ()
################################
# The target
################################
##
# Default building shared libraries.
# BUILD_SHARED_LIBS is provided by/used by
# CMake directly.
##
option(BUILD_SHARED_LIBS "Configure netCDF as a shared library." ON)
if(BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
add_library(netcdf)
add_library(netCDF::netcdf ALIAS netcdf)
# Version of the dispatch table. This must match the value in
# configure.ac.
set(NC_DISPATCH_VERSION 5)
# Get system configuration, Use it to determine osname, os release, cpu. These
# will be used when committing to CDash.
find_program(UNAME NAMES uname)
if(UNAME)
getuname(osname -s)
getuname(osrel -r)
getuname(cpu -m)
getuname(host -n)
set(TMP_BUILDNAME "${osname}-${osrel}-${cpu}")
endif()
find_program(GETFATTR NAMES getfattr)
if(GETFATTR)
set(HAVE_GETFATTR TRUE)
endif()
# Define some Platforms
if(osname MATCHES "CYGWIN.*")
set(ISCYGWIN yes)
endif()
if(osname MATCHES "Darwin.*")
set(ISOSX yes)
endif()
if(MSVC)
set(ISMSVC yes)
endif()
if(osname MATCHES "MINGW.*" OR osname MATCHES "MSYS.*")
set(ISMINGW yes)
set(MINGW yes)
endif()
###
# Allow for some customization of the buildname.
# This will make it easier to identify different builds,
# based on values passed from command line/shell scripts.
#
# For ctest scripts, we can use CTEST_BUILD_NAME.
###
set(BUILDNAME_PREFIX "" CACHE STRING "")
set(BUILDNAME_SUFFIX "" CACHE STRING "")
if(BUILDNAME_PREFIX)
set(TMP_BUILDNAME "${BUILDNAME_PREFIX}-${TMP_BUILDNAME}")
endif()
if(BUILDNAME_SUFFIX)
set(TMP_BUILDNAME "${TMP_BUILDNAME}-${BUILDNAME_SUFFIX}")
endif()
if(NOT BUILDNAME)
set(BUILDNAME "${TMP_BUILDNAME}" CACHE STRING "Build name variable for CDash")
endif()
###
# End BUILDNAME customization.
###
# For CMAKE_INSTALL_LIBDIR
include(GNUInstallDirs)
if(MSVC)
set(GLOBAL PROPERTY USE_FOLDERS ON)
target_compile_options(netcdf PUBLIC "/utf-8")
endif()
# auto-configure style checks, other CMake modules.
include(CheckLibraryExists)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckCXXSourceCompiles)
include(CheckCSourceCompiles)
include(TestBigEndian)
include(CheckSymbolExists)
include(GetPrerequisites)
include(CheckCCompilerFlag)
# A check to see if the system is big endian
TEST_BIG_ENDIAN(BIGENDIAN)
if(${BIGENDIAN})
set(WORDS_BIGENDIAN "1")
endif(${BIGENDIAN})
# Define a function to convert various true or false values
# to either TRUE|FALSE (uppercase).
# If value is not a recognized boolean, then return NOTFOUND
#1, ON, YES, TRUE, Y,
#0, OFF, NO, FALSE, N, IGNORE, NOTFOUND -NOTFOUND ""
set(TRUELIST "on;yes;y;true")
set(FALSELIST "off;no;n;false;0;ignore;notfound")
# Set the build type.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "Choose the type of build, options are: None, Debug, Release."
FORCE)
endif()
# Set build type uppercase
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
# Determine the configure date.
if(DEFINED ENV{SOURCE_DATE_EPOCH})
execute_process(
COMMAND "date" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}"
OUTPUT_VARIABLE CONFIG_DATE
)
else()
execute_process(
COMMAND date
OUTPUT_VARIABLE CONFIG_DATE
)
endif()
if(CONFIG_DATE)
string(STRIP ${CONFIG_DATE} CONFIG_DATE)
endif()
##
# Allow for extra dependencies.
##
set(EXTRA_DEPS "")
################################
# End Project Properties
################################
################################
# Set CTest Properties
################################
enable_testing()
include(CTest)
# Set Memory test program for non-MSVC based builds.
# Assume valgrind for now.
if((NOT MSVC) AND (NOT MINGW) AND (NOT ISCYGWIN))
set(CTEST_MEMORYCHECK_COMMAND valgrind CACHE STRING "")
endif()
# Set variable to define the build type.
include(GenerateExportHeader)
################################
# End CTest Properties
################################
################################
# Compiler and Linker Configuration
################################
# Set in support of https://github.com/Unidata/netcdf-c/issues/2700
if(${CMAKE_C_COMPILER_ID} MATCHES "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fhonor-infinities")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fhonor-infinities")
endif()
option(NETCDF_FIND_SHARED_LIBS "Find dynamically-built versions of dependent libraries" ${BUILD_SHARED_LIBS})
##
# We've had a request to allow for non-versioned shared libraries.
# This seems reasonable enough to accommodate. See
# https://github.com/Unidata/netcdf-c/issues/228 for more info.
##
option(NETCDF_ENABLE_SHARED_LIBRARY_VERSION "Encode the library SO version in the file name of the generated library file." ON)
# Set some default linux gcc & apple compiler options for
# debug builds.
if(CMAKE_COMPILER_IS_GNUCC OR APPLE)
option(NETCDF_ENABLE_COVERAGE_TESTS "Enable compiler flags needed to perform coverage tests." OFF)
option(NETCDF_ENABLE_CONVERSION_WARNINGS "Enable warnings for implicit conversion from 64 to 32-bit datatypes." ON)
option(NETCDF_ENABLE_LARGE_FILE_TESTS "Enable large file tests." OFF)
# Debugging flags
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
# Check to see if -Wl,--no-undefined is supported.
CHECK_C_LINKER_FLAG("-Wl,--no-undefined" LIBTOOL_HAS_NO_UNDEFINED)
if(LIBTOOL_HAS_NO_UNDEFINED)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,--no-undefined")
endif()
set(CMAKE_REQUIRED_FLAGS "${TMP_CMAKE_REQUIRED_FLAGS}")
# Coverage tests need to have optimization turned off.
if(NETCDF_ENABLE_COVERAGE_TESTS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -coverage -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -coverage -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
message(STATUS "Coverage Tests: On.")
endif()
# Warnings for 64-to-32 bit conversions.
if(NETCDF_ENABLE_CONVERSION_WARNINGS)
CHECK_C_COMPILER_FLAG(-Wconversion CC_HAS_WCONVERSION)
CHECK_C_COMPILER_FLAG(-Wshorten-64-to-32 CC_HAS_SHORTEN_64_32)
if(CC_HAS_SHORTEN_64_32)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshorten-64-to-32")
endif()
if(CC_HAS_WCONVERSION)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wconversion")
endif()
endif(NETCDF_ENABLE_CONVERSION_WARNINGS)
endif(CMAKE_COMPILER_IS_GNUCC OR APPLE)
# End default linux gcc & apple compiler options.
# Use relative pathnames in __FILE__ macros on MINGW:
if(MINGW)
CHECK_C_COMPILER_FLAG("-fmacro-prefix-map='${CMAKE_SOURCE_DIR}'=." CC_HAS_MACRO_PREFIX_MAP)
if(CC_HAS_MACRO_PREFIX_MAP)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmacro-prefix-map='${CMAKE_SOURCE_DIR}'=.")
endif()
endif()
# Suppress CRT Warnings.
# Only necessary for Windows
if(MSVC)
target_compile_definitions(netcdf PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
# Support ANSI format specifiers for *printf on MINGW:
if(MINGW)
target_compile_definitions(netcdf PRIVATE __USE_MINGW_ANSI_STDIO=1)
endif()
#####
# System inspection checks
#####
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/oc2)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libsrc)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/libsrc)
################################
# End Compiler Configuration
################################
##
# Configuration for post-install RPath
# Adapted from http://www.cmake.org/Wiki/CMake_RPATH_handling
##
if(NOT WIN32 AND BUILD_SHARED_LIBS)
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
endif(APPLE)
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing,
# but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif("${isSystemDir}" STREQUAL "-1")
endif()
##
# End configuration for post-install RPath
##
################################
# Option checks
################################
# Default Cache variables.
set(DEFAULT_CHUNK_SIZE 16777216 CACHE STRING "Default Chunk Cache Size.")
set(DEFAULT_CHUNK_CACHE_SIZE 16777216U CACHE STRING "Default Chunk Cache Size.")
set(DEFAULT_CHUNKS_IN_CACHE 1000 CACHE STRING "Default number of chunks in cache.")
set(DEFAULT_CHUNK_CACHE_PREEMPTION 0.75 CACHE STRING "Default file chunk cache preemption policy (a number between 0 and 1, inclusive).")
# HDF5 default cache size values
set(CHUNK_CACHE_SIZE ${DEFAULT_CHUNK_CACHE_SIZE} CACHE STRING "Default HDF5 Chunk Cache Size.")
set(CHUNK_CACHE_NELEMS ${DEFAULT_CHUNKS_IN_CACHE} CACHE STRING "Default maximum number of elements in cache.")
set(CHUNK_CACHE_PREEMPTION ${DEFAULT_CHUNK_CACHE_PREEMPTION} CACHE STRING "Default file chunk cache preemption policy for HDf5 files(a number between 0 and 1, inclusive.)")
set(NETCDF_LIB_NAME "" CACHE STRING "Default name of the netcdf library.")
set(TEMP_LARGE "." CACHE STRING "Where to put large temp files if large file tests are run.")
set(NCPROPERTIES_EXTRA "" CACHE STRING "Specify extra pairs for _NCProperties.")
if(NOT NETCDF_LIB_NAME STREQUAL "")
set(MOD_NETCDF_NAME ON)
endif()
# Set the appropriate compiler/architecture for universal OSX binaries.
if(${CMAKE_SYSTEM_NAME} EQUAL "Darwin")
set(CMAKE_OSX_ARCHITECTURES i386;x86_64)
endif(${CMAKE_SYSTEM_NAME} EQUAL "Darwin")
# Option to use Static Runtimes in MSVC
if(MSVC)
option(NETCDF_USE_STATIC_CRT "Use static CRT Libraries ('\\MT')." OFF)
if(NETCDF_USE_STATIC_CRT)
set(USE_STATIC_CRT ON)
specify_static_crt_flag()
endif()
endif()
# Option to build netCDF Version 2
OPTION (NETCDF_ENABLE_V2_API "Build netCDF Version 2." ON)
set(BUILD_V2 ${NETCDF_ENABLE_V2_API})
if(NOT NETCDF_ENABLE_V2_API)
set(NO_NETCDF_2 ON)
else(NOT NETCDF_ENABLE_V2_API)
set(USE_NETCDF_2 TRUE)
endif(NOT NETCDF_ENABLE_V2_API)
# Option to build utilities
option(NETCDF_BUILD_UTILITIES "Build ncgen, ncgen3, ncdump." ON)
option(NETCDF_GENERATE_NCGEN "Automatically regenerate ncgen C files if required" OFF)
# Option to use MMAP
option(NETCDF_ENABLE_MMAP "Use MMAP." ON)
# Option to use examples.
option(NETCDF_ENABLE_EXAMPLES "Build Examples" ON)
###
# Allow the user to specify libraries
# to link against, similar to automakes 'LIBS' variable.
###
set(NC_EXTRA_DEPS "" CACHE STRING "Additional libraries to link against.")
if(NC_EXTRA_DEPS)
string(REPLACE " " ";" DEPS_LIST ${NC_EXTRA_DEPS})
foreach(_DEP ${DEPS_LIST})
string(REGEX REPLACE "^-l" "" _LIB ${_DEP})
FIND_LIBRARY("${_LIB}_DEP" NAMES "${_LIB}" "lib${_LIB}")
message(STATUS ${${_LIB}_DEP})
if("${${_LIB}_DEP}" STREQUAL "${_LIB}_DEP-NOTFOUND")
message(FATAL_ERROR "Error finding ${_LIB}.")
else()
message(STATUS "Found ${_LIB}: ${${_LIB}_DEP}")
endif()
set(EXTRA_DEPS ${EXTRA_DEPS} "${${_LIB}_DEP}")
endforeach()
message(STATUS "Extra deps: ${EXTRA_DEPS}")
list(REMOVE_DUPLICATES EXTRA_DEPS)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${EXTRA_DEPS})
endif()
###
# End user-specified dependent libraries.
###
################################
# Format Option checks
################################
# As a long term goal, and because it is now the case that
# NETCDF_ENABLE_NCZARR => USE_NETCDF4, so make the external options
# NETCDF_ENABLE_NETCDF_4 and NETCDF_ENABLE_NETCDF4 obsolete
# in favor of NETCDF_ENABLE_HDF5.
# We will do the following for one more release cycle.
# 1. Make NETCDF_ENABLE_NETCDF_4 be an alias for NETCDF_ENABLE_NETCDF4.
# 2. Make NETCDF_ENABLE_NETCDF4 an alias for NETCDF_ENABLE_HDF5.
# 3. Internally, convert most (but not all) uses of USE_NETCDF_4 and USE_NETCDF4 to USE_HDF5.
# Collect the values of NETCDF_ENABLE_NETCDF_4, NETCDF_ENABLE_NETCDF4, and NETCDF_ENABLE_HDF5.
# Figure out which options are defined and process options
if(DEFINED NETCDF_ENABLE_NETCDF_4)
set(UNDEF_NETCDF_4 OFF CACHE BOOL "")
option(NETCDF_ENABLE_NETCDF_4 "" ON)
else()
set(UNDEF_NETCDF_4 ON CACHE BOOL "")
endif()
if(DEFINED NETCDF_ENABLE_NETCDF4)
set(UNDEF_NETCDF4 OFF CACHE BOOL "")
option(NETCDF_ENABLE_NETCDF4 "" ON)
else()
set(UNDEF_NETCDF4 ON CACHE BOOL "")
endif()
if(DEFINED NETCDF_ENABLE_HDF5)
set(UNDEF_HDF5 OFF CACHE BOOL "")
option(NETCDF_ENABLE_HDF5 "" ON)
else()
set(UNDEF_HDF5 ON CACHE BOOL "")
endif()
if(NOT UNDEF_NETCDF_4)
message(WARNING "NETCDF_ENABLE_NETCDF_4 is deprecated; please use NETCDF_ENABLE_HDF5")
endif()
if(NOT UNDEF_NETCDF4)
message(WARNING "NETCDF_ENABLE_NETCDF4 is deprecated; please use NETCDF_ENABLE_HDF5")
endif()
# NETCDF_ENABLE_NETCDF_4 overrides NETCDF_ENABLE_NETCDF4 if latter not defined.
if((NOT "${UNDEF_NETCDF_4}") AND UNDEF_NETCDF4)
set(NETCDF_ENABLE_NETCDF4 ${NETCDF_ENABLE_NETCDF_4} CACHE BOOL "" FORCE)
endif()
# NETCDF_ENABLE_NETCDF4 overrides NETCDF_ENABLE_HDF5 if latter not defined.
if((NOT "${UNDEF_NETCDF4}") AND UNDEF_HDF5)
set(NETCDF_ENABLE_HDF5 "${NETCDF_ENABLE_HDF5}" CACHE BOOL "" FORCE)
endif()
# Otherwise, use NETCDF_ENABLE_HDF5 default
if(UNDEF_HDF5)
set(NETCDF_ENABLE_HDF5 ON CACHE BOOL "" FORCE)
endif()
# Turn off NETCDF_ENABLE_NETCDF4 because it will be used
# as a shorthand for NETCDF_ENABLE_HDF5|NETCDF_ENABLE_HDF4|NETCDF_ENABLE_NCZARR
set(NETCDF_ENABLE_NETCDF4 OFF CACHE BOOL "" FORCE)
option(NETCDF_ENABLE_DAP "Enable DAP2 and DAP4 Client." ON)
option(NETCDF_ENABLE_NCZARR "Enable NCZarr Client." ON)
option(NETCDF_ENABLE_PNETCDF "Build with parallel I/O for CDF-1, 2, and 5 files using PnetCDF." OFF)
set(NETCDF_ENABLE_CDF5 AUTO CACHE STRING "AUTO")
option(NETCDF_ENABLE_CDF5 "Enable CDF5 support" ON)
option(NETCDF_ENABLE_HDF4 "Enable HDF4 Read Support" OFF)
option(NETCDF_ENABLE_HDF4_FILE_TESTS "Enable HDF4 File Tests" ${NETCDF_ENABLE_HDF4})
if(NETCDF_ENABLE_HDF4)
set(USE_HDF4 ON)
endif()
# Netcdf-4 support (i.e. libsrc4) is required by more than just HDF5 (e.g. NCZarr)
# So depending on what above formats are enabled, enable netcdf-4
if(NETCDF_ENABLE_HDF5 OR NETCDF_ENABLE_HDF4 OR NETCDF_ENABLE_NCZARR)
set(NETCDF_ENABLE_NETCDF4 ON CACHE BOOL "Enable netCDF-4 API" FORCE)
endif()
# enable|disable all forms of network access
option(NETCDF_ENABLE_REMOTE_FUNCTIONALITY "Enable|disable all forms remote data access (DAP, S3, etc)" ON)
if(NOT NETCDF_ENABLE_REMOTE_FUNCTIONALITY AND NETCDF_ENABLE_DAP)
message(WARNING "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_DAP[4]=NO")
set(NETCDF_ENABLE_DAP OFF CACHE BOOL "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_DAP=NO" FORCE)
set(NETCDF_ENABLE_DAP2 OFF CACHE BOOL "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_DAP2=NO" FORCE)
set(NETCDF_ENABLE_DAP4 OFF CACHE BOOL "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_DAP4=NO" FORCE)
endif()
# Option to Build DLL
if(WIN32)
option(NETCDF_ENABLE_DLL "Build a Windows DLL." ${BUILD_SHARED_LIBS})
if(NETCDF_ENABLE_DLL)
set(BUILD_DLL ON CACHE BOOL "")
target_compile_definitions(netcdf PRIVATE DLL_EXPORT)
target_compile_definitions(netcdf PUBLIC DLL_NETCDF)
endif()
endif()
# Did the user specify a default minimum blocksize for posixio?
set(NCIO_MINBLOCKSIZE 256 CACHE STRING "Minimum I/O Blocksize for netCDF classic and 64-bit offset format files.")
if(NETCDF_ENABLE_NETCDF4)
set(USE_NETCDF4 ON CACHE BOOL "")
set(NETCDF_ENABLE_NETCDF4 ON CACHE BOOL "")
else()
set(USE_HDF4_FILE_TESTS OFF)
set(USE_HDF4 OFF)
set(NETCDF_ENABLE_HDF4_FILE_TESTS OFF)
set(NETCDF_ENABLE_HDF4 OFF)
endif()
# Option legacy macros
# Do we want to enable unsafe macros, e.g. _FillValue in addition to NC_FillValue.
# See https://github.com/Unidata/netcdf-c/issues/3029
option(NETCDF_ENABLE_LEGACY_MACROS "Enable legacy macros for backwards compatibility. Use with Caution." ON)
# Option Logging, only valid for netcdf4 dispatchers.
option(NETCDF_ENABLE_LOGGING "Enable Logging." OFF)
if(NOT NETCDF_ENABLE_NETCDF4)
set(NETCDF_ENABLE_LOGGING OFF)
endif()
set(LOGGING ${NETCDF_ENABLE_LOGGING})
set(NETCDF_ENABLE_SET_LOG_LEVEL ${NETCDF_ENABLE_LOGGING})
# Option to allow for strict null file padding.
# See https://github.com/Unidata/netcdf-c/issues/657 for more information
option(NETCDF_ENABLE_STRICT_NULL_BYTE_HEADER_PADDING "Enable strict null byte header padding." OFF)
if(NETCDF_ENABLE_STRICT_NULL_BYTE_HEADER_PADDING)
set(USE_STRICT_NULL_BYTE_HEADER_PADDING ON CACHE BOOL "")
endif(NETCDF_ENABLE_STRICT_NULL_BYTE_HEADER_PADDING)
# Note that szip management is tricky.
# This is because we have three things to consider:
# 1. is libsz available?
# 2. is szip enabled in HDF5?
# 3. is nczarr enabled?
# We need separate flags for cases 1 and 2
set(USE_HDF5 ${NETCDF_ENABLE_HDF5})
if(NETCDF_ENABLE_DAP)
set(USE_DAP ON CACHE BOOL "")
set(NETCDF_ENABLE_DAP2 ON CACHE BOOL "")
if(NETCDF_ENABLE_HDF5)
message(STATUS "Enabling DAP4")
set(NETCDF_ENABLE_DAP4 ON CACHE BOOL "")
else()
message(STATUS "Disabling DAP4")
set(NETCDF_ENABLE_DAP4 OFF CACHE BOOL "")
endif(NETCDF_ENABLE_HDF5)
else()
set(NETCDF_ENABLE_DAP2 OFF CACHE BOOL "")
set(NETCDF_ENABLE_DAP4 OFF CACHE BOOL "")
endif()
# Option to support byte-range reading of remote datasets
option(NETCDF_ENABLE_BYTERANGE "Enable byte-range access to remote datasets.." ${NETCDF_ENABLE_DAP})
if(NOT NETCDF_ENABLE_REMOTE_FUNCTIONALITY AND NETCDF_ENABLE_BYTERANGE)
message(WARNING "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_BYTERANGE=NO")
set(NETCDF_ENABLE_BYTERANGE OFF CACHE BOOL "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_BYTERANGE=NO" FORCE)
endif()
# Option to Enable DAP long tests, remote tests.
option(NETCDF_ENABLE_DAP_REMOTE_TESTS "Enable DAP remote tests." ON)
option(NETCDF_ENABLE_EXTERNAL_SERVER_TESTS "Enable external Server remote tests." OFF)
option(NETCDF_ENABLE_DAP_LONG_TESTS "Enable DAP long tests." OFF)
if(NOT NETCDF_ENABLE_DAP)
set(NETCDF_ENABLE_DAP_REMOTE_TESTS OFF CACHE BOOL "" FORCE)
set(NETCDF_ENABLE_EXTERNAL_SERVER_TESTS OFF CACHE BOOL "" FORCE)
set(NETCDF_ENABLE_DAP_LONG_TESTS OFF CACHE BOOL "" FORCE)
endif()
# Provide a global control for remotetest.
if ("$ENV{REMOTETESTDOWN}" STREQUAL "yes" AND NETCDF_ENABLE_DAP_REMOTE_TESTS)
message(WARNING "ENV(REMOTETESTDOWN) => NETCDF_ENABLE_DAP_REMOTE_TESTS == OFF")
set(NETCDF_ENABLE_DAP_REMOTE_TESTS OFF CACHE BOOL "" FORCE)
endif()
set(REMOTETESTSERVERS "remotetest.unidata.ucar.edu" CACHE STRING "test servers to use for remote test")
set(REMOTETESTSERVERS "remotetest.unidata.ucar.edu" CACHE STRING "test servers to use for remote test")
# Locate some compressors
option(NETCDF_ENABLE_PLUGINS "Enable netCDF Plugins." ON)
option(NETCDF_ENABLE_FILTER_SZIP "Enable use of Szip compression library if it is available. Required if NETCDF_ENABLE_NCZARR is true." ON)
option(NETCDF_ENABLE_FILTER_BZ2 "Enable use of Bz2 compression library if it is available." ON)
option(NETCDF_ENABLE_FILTER_BLOSC "Enable use of blosc compression library if it is available." ON)
option(NETCDF_ENABLE_FILTER_ZSTD "Enable use of Zstd compression library if it is available." ON)
# If user wants, then install selected plugins (default off)
option(NETCDF_PLUGIN_INSTALL "Enable plugin installation" NO)
# Note: the term PLATFORMDEFAULT stands for:
# -- /usr/loca/hdf5/lib/plugin If on a *nix* machine
# -- %ALLUSERSPROFILE%/hdf5/lib/plugins If on a windows or Mingw platform
if(ISMSVC OR ISMINGW)
set(PLATFORMDEFAULT "$ENV{ALLUSERSPROFILE}\\hdf5\\lib\\plugin")
set(PLATFORMSEP ";")
else()
set(PLATFORMDEFAULT "/usr/local/hdf5/lib/plugin")
set(PLATFORMSEP ":")
endif()
# Internally, the variable DEFAULT_PLUGIN_INSTALL_DIR is the default
# directory into which plugins are installed; this may be undefined if
# plugin installation is disabled (the usual case). It is exported as
# NETCDF_DEFAULT_PLUGIN_INSTALL_DIR.
#
# Similarly the variable DEFAULT_PLUGIN_SEARCH_PATH is the default list
# of directories to search to locate plugins.
#
# See configure.ac to see a table defining the rules for computing these two variables.
# Inferences about plugins
if(NETCDF_WITH_PLUGIN_DIR)
set(NETCDF_ENABLE_PLUGINS yes)
endif()
# canonical form is all forward slashes
string(REPLACE "\\" "/" DEFAULT_PLUGIN_INSTALL_DIR "${DEFAULT_PLUGIN_INSTALL_DIR}")
string(REPLACE "\\" "/" DEFAULT_PLUGIN_SEARCH_PATH "${DEFAULT_PLUGIN_SEARCH_PATH}")
if(NOT NETCDF_ENABLE_PLUGINS)
unset(NETCDF_PLUGIN_INSTALL)
unset(NETCDF_WITH_PLUGIN_DIR)
endif()
if (DEFINED NETCDF_WITH_PLUGIN_DIR) # Table row 3
set(DEFAULT_PLUGIN_INSTALL_DIR "${NETCDF_WITH_PLUGIN_DIR}")
set(DEFAULT_PLUGIN_SEARCH_PATH "${NETCDF_WITH_PLUGIN_DIR}${PLATFORMSEP}${PLATFORMDEFAULT}")
elseif (DEFINED CMAKE_INSTALL_PREFIX) # Table row 2
set(DEFAULT_PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/hdf5/lib/plugin")
set(DEFAULT_PLUGIN_SEARCH_PATH "${DEFAULT_PLUGIN_INSTALL_DIR}${PLATFORMSEP}${PLATFORMDEFAULT}")
else() # Table row 1
unset(DEFAULT_PLUGIN_INSTALL_DIR)
set(DEFAULT_PLUGIN_SEARCH_PATH "${PLATFORMDEFAULT}")
endif()
# canonical form is all forward slashes
string(REPLACE "\\" "/" DEFAULT_PLUGIN_INSTALL_DIR "${DEFAULT_PLUGIN_INSTALL_DIR}")
string(REPLACE "\\" "/" DEFAULT_PLUGIN_SEARCH_PATH "${DEFAULT_PLUGIN_SEARCH_PATH}")
# Inferences
if (DEFINED DEFAULT_PLUGIN_INSTALL_DIR)
set(ENABLE_PLUGIN_DIR yes)
else()
set(ENABLE_PLUGIN_DIR no)
endif()
set(NETCDF_PLUGIN_INSTALL_DIR "${DEFAULT_PLUGIN_INSTALL_DIR}")
set(NETCDF_PLUGIN_SEARCH_PATH "${DEFAULT_PLUGIN_SEARCH_PATH}")
# Try to enable NCZarr zip support
option(NETCDF_ENABLE_NCZARR_ZIP "Enable NCZarr ZIP support." ${NETCDF_ENABLE_NCZARR})
include(CMakeDependentOption)
# libdl is always available; built-in in Windows and OSX
cmake_dependent_option(NETCDF_ENABLE_PLUGINS "Enable dynamically loaded plugins (default on)."
ON "BUILD_SHARED_LIBS" OFF)
MESSAGE(STATUS "NETCDF_ENABLE_PLUGINS: ${NETCDF_ENABLE_PLUGINS}")
if(NOT WIN32)
if(HAVE_DLFCN_H)
include_directories("dlfcn.h")
endif()
endif()
if(NETCDF_ENABLE_PLUGINS)
set(USEPLUGINS yes)
endif()
# Enable some developer-only tests
option(NETCDF_ENABLE_EXTRA_TESTS "Enable Extra tests. Some may not work because of known issues. Developers only." OFF)
if(NETCDF_ENABLE_EXTRA_TESTS)
set(EXTRA_TESTS ON)
endif()
# Option to use bundled XGetopt in place of getopt(). This is mostly useful
# for MSVC builds. If not building utilities or some tests,
# getopt() isn't required at all.
if(MSVC)
option(NETCDF_ENABLE_XGETOPT "Enable bundled XGetOpt instead of external getopt()." ON)
if(NETCDF_ENABLE_XGETOPT)
set(USE_X_GETOPT ON CACHE BOOL "")
endif()
endif()
set(MATH "")
if(NOT WIN32)
# STDIO instead of posixio.
option(NETCDF_ENABLE_STDIO "If true, use stdio instead of posixio (ex. on the Cray)" OFF)
if(NETCDF_ENABLE_STDIO)
set(USE_STDIO ON CACHE BOOL "")
endif()
# FFIO insteaad of PosixIO
option(NETCDF_ENABLE_FFIO "If true, use ffio instead of posixio" OFF)
if(NETCDF_ENABLE_FFIO)
set(USE_FFIO ON CACHE BOOL "")
endif()
endif()
# Options for S3 Support
option(NETCDF_ENABLE_S3_AWS "Enable S3 support via AWS-CPP-SDK" OFF)
option(NETCDF_ENABLE_S3_INTERNAL "Enable S3 Internal support." OFF)
#option(NETCDF_ENABLE_S3 "Enable S3 support." OFF)
cmake_dependent_option(NETCDF_ENABLE_S3 "Enable S3 Support" ON "NETCDF_ENABLE_S3_AWS OR NETCDF_ENABLE_S3_INTERNAL" OFF)
option(NETCDF_ENABLE_NCZARR_S3 "Enable NCZarr S3 support; Deprecated in favor of NETCDF_ENABLE_S3" ${NETCDF_ENABLE_S3})
if(NOT NETCDF_ENABLE_REMOTE_FUNCTIONALITY)
set(NETCDF_ENABLE_S3 OFF CACHE BOOL "" FORCE)
set(NETCDF_ENABLE_S3_INTERNAL OFF CACHE BOOL "" FORCE)
set(NETCDF_ENABLE_S3_AWS OFF CACHE BOOL "" FORCE)
set(NETCDF_ENABLE_NCZARR_S3 OFF CACHE BOOL "" FORCE)
endif()
# Control S3 Testing: Multi-valued option
set(WITH_S3_TESTING OFF CACHE STRING "Control S3 Testing: ON (i.e. all) OFF (i.e. none) PUBLIC")
SET_PROPERTY(CACHE WITH_S3_TESTING PROPERTY STRINGS ON OFF PUBLIC) #
if(WITH_S3_TESTING STREQUAL "")
set(WITH_S3_TESTING OFF CACHE STRING "") # Default
endif()
if(WITH_S3_TESTING)
message(WARNING "**** DO NOT USE WITH_S3_TESTING=ON UNLESS YOU HAVE ACCESS TO THE UNIDATA S3 BUCKET! ***")
endif()
# NETCDF_ENABLE_NCZARR_S3 is now an alias for NETCDF_ENABLE_S3 (but...)
if (NOT NETCDF_ENABLE_S3 AND NETCDF_ENABLE_NCZARR_S3)
set(NETCDF_ENABLE_S3 ON CACHE BOOL "NCARR S3" FORCE) # For back compatibility
endif()
unset(NETCDF_ENABLE_NCZARR_S3)
if(NOT NETCDF_ENABLE_REMOTE_FUNCTIONALITY)
message(WARNING "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => disable all s3 functionality")
set(NETCDF_ENABLE_S3 OFF CACHE BOOL "" FORCE)
set(NETCDF_ENABLE_S3_INTERNAL OFF CACHE BOOL "" FORCE)
set(NETCDF_ENABLE_NCZARR_S3 OFF CACHE BOOL "" FORCE)
set(NETCDF_ENABLE_HDF5_ROS3 OFF CACHE BOOL "Use ROS3" FORCE)
set(WITH_S3_TESTING OFF CACHE STRING "" FORCE)
endif()
if(NETCDF_ENABLE_S3)
if(NOT NETCDF_ENABLE_S3_AWS AND NOT NETCDF_ENABLE_S3_INTERNAL)
message(FATAL_ERROR "S3 support library not found; please specify option -DNETCDF_ENABLE_S3=NO")
set(NETCDF_ENABLE_S3 OFF CACHE BOOL "S3 support" FORCE)
endif()
if(NETCDF_ENABLE_S3_AWS AND NETCDF_ENABLE_S3_INTERNAL)
message(WARNING "Both aws-sdk-cpp and s3-internal enabled => use s3-internal")
set(NETCDF_ENABLE_S3_AWS OFF CACHE BOOL "S3 AWS" FORCE)
endif()
endif()
if(NOT NETCDF_ENABLE_S3)
if(WITH_S3_TESTING STREQUAL "PUBLIC" OR WITH_S3_TESTING)
message(WARNING "S3 support is disabled => WITH_S3_TESTING=OFF")
set(WITH_S3_TESTING OFF CACHE STRING "" FORCE)
endif()
endif()
option(NETCDF_ENABLE_LIBXML2 "Link against libxml2 if it is available, use the packaged tinyxml2 parser otherwise." ON)
set(XMLPARSER "tinyxml2 (bundled)")
if(NOT NETCDF_ENABLE_BYTERANGE AND NETCDF_ENABLE_HDF5_ROS3)
message(WARNING "ROS3 support requires NETCDF_ENABLE_BYTERANGE=TRUE; disabling ROS3 support")
set(NETCDF_ENABLE_HDF5_ROS3 OFF CACHE BOOL "ROS3 support" FORCE)
endif()
##
# Enable Tests
##
option(NETCDF_ENABLE_TESTS "Enable basic tests, run with 'make test'." ON)
if(NETCDF_ENABLE_TESTS)
set(BUILD_TESTSETS ON CACHE BOOL "")
# Options for CTest-based tests, dashboards.
set(NC_CTEST_PROJECT_NAME "netcdf-c" CACHE STRING "Project Name for CTest-based testing purposes.")
set(NC_CTEST_DROP_SITE "cdash.unidata.ucar.edu:443" CACHE STRING "Dashboard location for CTest-based testing purposes.")
set(NC_CTEST_DROP_LOC_PREFIX "" CACHE STRING "Prefix for Dashboard location on remote server when using CTest-based testing.")
set(SUBMIT_URL "https://cdash.unidata.ucar.edu:443")
if("${host}" STREQUAL "")
find_program(HOSTNAME_CMD NAMES hostname)
if(NOT WIN32)
set(HOSTNAME_ARG "-s")
endif()
if(HOSTNAME_CMD)
execute_process(COMMAND ${HOSTNAME_CMD} "${HOSTNAME_ARG}" OUTPUT_VARIABLE HOSTNAME OUTPUT_STRIP_TRAILING_WHITESPACE)
set(NC_CTEST_SITE "${HOSTNAME}" CACHE STRING "Hostname of test machine.")
endif()
else()
set(NC_CTEST_SITE "${host}" CACHE STRING "Hostname of test machine.")
endif()
if(NC_CTEST_SITE)
set(SITE "${NC_CTEST_SITE}" CACHE STRING "")
endif()
###
# This option dictates whether or not to turn on
# tests which are known to fail. This is not the
# same thing as an 'expected failure'. Rather, these
# are tests that will need to be fixed eventually.
#
# By placing them here, we can occasionally turn this
# flag on and see if any known failures have been
# fixed in the course of code improvement/other bug
# fixes.
#
# To use this, simply add as a fencepost around tests
# which are known to fail.
###
option(NETCDF_ENABLE_FAILING_TESTS "Run tests which are known to fail, check to see if any have been fixed." OFF)
###
# Option to turn on unit testing. See
# https://github.com/Unidata/netcdf-c/pull/1472 for more information.
###
option(NETCDF_ENABLE_UNIT_TESTS "Run Unit Tests." ON)
###
# Option to turn on performance testing.
# See https://github.com/Unidata/netcdf-c/issues/2627 for more information.
###
option(NETCDF_ENABLE_BENCHMARKS "Run benchmark Tests." OFF)
set(BUILD_BENCHMARKS ${NETCDF_ENABLE_BENCHMARKS} CACHE BOOL "alias for NETCDF_ENABLE_BENCHMARKS")
###
# End known-failures.
###
MARK_AS_ADVANCED(NETCDF_ENABLE_FAILING_TESTS)
endif()
###
# Option to enable extreme numbers during testing.
###
option(NETCDF_ENABLE_EXTREME_NUMBERS "Enable extreme numbers during testing, such as MAX_INT-1" ON)
if(NETCDF_ENABLE_EXTREME_NUMBERS)
set(USE_EXTREME_NUMBERS ON)
endif()
# Enable Large file tests
if(NETCDF_ENABLE_LARGE_FILE_TESTS)
set(LARGE_FILE_TESTS ON)
endif()
option(NETCDF_ENABLE_METADATA_PERF_TESTS "Enable test of metadata performance." OFF)
if(NETCDF_ENABLE_METADATA_PERF_TESTS)
set(ENABLE_METADATA_PERF ON)
endif()
# Location for large file tests.
set(TEMP_LARGE "." CACHE STRING "Location to store large file tests.")
option(NETCDF_ENABLE_FSYNC "Enable experimental fsync code." OFF)
if(NETCDF_ENABLE_FSYNC)
set(USE_FSYNC ON)
endif()
# Linux specific large file support flags.
# Modelled after check in CMakeLists.txt for hdf5.
option(NETCDF_ENABLE_LARGE_FILE_SUPPORT "Enable large file support." ON)
if(NETCDF_ENABLE_LARGE_FILE_SUPPORT)
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /LARGEADDRESSAWARE")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64")
endif()
endif()
option(NETCDF_ENABLE_EXAMPLE_TESTS "Run extra example tests. Requires GNU Sed. Ignored if HDF5 is not Enabled" OFF)
if(NOT NETCDF_ENABLE_HDF5 AND NETCDF_ENABLE_EXAMPLE_TESTS)
set(NETCDF_ENABLE_EXAMPLE_TESTS OFF)
endif()
##################################
# Dependencies
##################################
include(cmake/dependencies.cmake)
################################
# End Dependencies
################################
# Enable Parallel IO with netCDF-4/HDF5 files using HDF5 parallel I/O.
set(STATUS_PARALLEL "OFF")
set(IMPORT_MPI "")
option(NETCDF_ENABLE_PARALLEL4 "Build netCDF-4 with parallel IO" "${HDF5_PARALLEL}")
option(NETCDF_MPIEXEC "Command to use instead of mpiexec to launch parallel I/O tests" OFF)
if(NETCDF_ENABLE_PARALLEL4 AND NETCDF_ENABLE_HDF5)
if(NOT HDF5_PARALLEL)
set(USE_PARALLEL OFF CACHE BOOL "")
message(STATUS "Cannot find HDF5 library built with parallel support. Disabling parallel build.")
else()
set(HDF5_PARALLEL ON CACHE BOOL "")
set(USE_PARALLEL ON CACHE BOOL "")
set(USE_PARALLEL4 ON CACHE BOOL "")
set(STATUS_PARALLEL "ON")
if(NETCDF_MPIEXEC)
set(MPIEXEC "${NETCDF_MPIEXEC}")
endif()
message(STATUS "MPIEXEC command will be ${MPIEXEC}")
configure_file("${netCDF_SOURCE_DIR}/nc_test4/run_par_test.sh.in"
"${netCDF_BINARY_DIR}/tmp/run_par_test.sh" @ONLY NEWLINE_STYLE LF)
file(COPY "${netCDF_BINARY_DIR}/tmp/run_par_test.sh"
DESTINATION ${netCDF_BINARY_DIR}/nc_test4
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
configure_file("${netCDF_SOURCE_DIR}/nc_test4/run_par_warn_test.sh.in"
"${netCDF_BINARY_DIR}/tmp/run_par_warn_test.sh" @ONLY NEWLINE_STYLE LF)
file(COPY "${netCDF_BINARY_DIR}/tmp/run_par_warn_test.sh"
DESTINATION ${netCDF_BINARY_DIR}/nc_test4
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
configure_file("${netCDF_SOURCE_DIR}/h5_test/run_par_tests.sh.in"
"${netCDF_BINARY_DIR}/tmp/run_par_tests.sh" @ONLY NEWLINE_STYLE LF)
file(COPY "${netCDF_BINARY_DIR}/tmp/run_par_tests.sh"
DESTINATION ${netCDF_BINARY_DIR}/h5_test
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
set(IMPORT_MPI "include(CMakeFindDependencyMacro)\nfind_dependency(MPI COMPONENTS C)")
endif()
endif()
# Options to enable parallel IO for classic formats with PnetCDF library.
set(STATUS_PNETCDF ${NETCDF_ENABLE_PNETCDF})
set(USE_PNETCDF ${NETCDF_ENABLE_PNETCDF})
if(NETCDF_ENABLE_PNETCDF)
set(STATUS_PARALLEL ON)
set(USE_PARALLEL ON CACHE BOOL "")
###
# Generate pnetcdf test
###
configure_file("${netCDF_SOURCE_DIR}/nc_test/run_pnetcdf_tests.sh.in"
"${netCDF_BINARY_DIR}/nc_test/run_pnetcdf_tests.sh")
endif()
# Options to enable use of fill values for elements causing NC_ERANGE
set(NETCDF_ENABLE_ERANGE_FILL AUTO CACHE STRING "AUTO")
option(NETCDF_ENABLE_ERANGE_FILL "Enable use of fill value when out-of-range type conversion causes NC_ERANGE error." OFF)
if(NETCDF_ENABLE_ERANGE_FILL) # enable or auto
string(TOUPPER ${NETCDF_ENABLE_ERANGE_FILL} NETCDF_ENABLE_ERANGE_FILL)
if(NETCDF_ENABLE_ERANGE_FILL AND NOT NETCDF_ENABLE_ERANGE_FILL STREQUAL "AUTO")
# explicitly enabled
set(NETCDF_ENABLE_ERANGE_FILL ON)
else()
if(NOT NETCDF_ENABLE_ERANGE_FILL STREQUAL "AUTO")
set(NETCDF_ENABLE_ERANGE_FILL OFF)
endif()
endif()
endif(NETCDF_ENABLE_ERANGE_FILL)
# Now NETCDF_ENABLE_ERANGE_FILL is either AUTO, ON, or OFF
# More relaxed coordinate check is now mandatory for all builds.
set(ENABLE_ZERO_LENGTH_COORD_BOUND ON)
# check and conform with PnetCDF settings on ERANGE_FILL and RELAX_COORD_BOUND
if(USE_PNETCDF)
if(NETCDF_ENABLE_ERANGE_FILL STREQUAL "AUTO") # not set on command line