-
Notifications
You must be signed in to change notification settings - Fork 266
/
Copy pathCMakeLists.txt
160 lines (132 loc) · 5.12 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
# Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
# 2015, 2016, 2017, 2018
# University Corporation for Atmospheric Research/Unidata.
# See netcdf-c/COPYRIGHT file for more info.
set(CMAKE_BUILD_TYPE "")
if(WIN32)
set(PLUGINEXT "dll")
set(PLUGINPRE "__nc")
elseif(CYGWIN)
set(PLUGINEXT "dll")
set(PLUGINPRE "lib__nc")
else()
set(PLUGINPRE "lib__nc")
if(APPLE)
set(PLUGINEXT "dylib")
else()
set(PLUGINEXT "so")
endif()
endif()
file(READ H5Znoop.c NOOP_SOURCE)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/H5Znoop1.c "#define NOOP_INSTANCE 1\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/H5Znoop1.c "${NOOP_SOURCE}")
set(h5misc_SOURCES H5Zmisc.c H5Zutil.c h5misc.h)
set(h5noop_SOURCES H5Znoop.c H5Zutil.c h5noop.h)
set_source_files_properties(H5Znoop.c PROPERTIES COMPILE_OPTIONS -DNOOP_INSTANCE=0)
set(h5noop1_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/H5Znoop1.c H5Zutil.c h5noop.h)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/H5Znoop1.c PROPERTIES COMPILE_OPTIONS -DNOOP_INSTANCE=1)
set(h5unknown_SOURCES H5Zunknown.c)
set(h5shuffle_SOURCES H5Zshuffle.c)
set(h5fletcher32_SOURCES H5Zfletcher32.c H5checksum.c)
set(h5deflate_SOURCES H5Zdeflate.c)
set(nczmisc_SOURCES NCZmisc.c)
set(nczhdf5filters_SOURCES NCZhdf5filters.c)
set(nczstdfilters_SOURCES NCZstdfilters.c)
if(NETCDF_ENABLE_PLUGINS)
# LDFLAGS = -module -avoid-version -shared -export-dynamic -no-undefined
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_BINARY_DIR}")
macro(buildplugin TARGET TARGETLIB)
set(MANGLELIB "${PLUGINPRE}${TARGETLIB}")
add_library(${TARGET} MODULE ${${TARGET}_SOURCES})
set_target_properties(${TARGET} PROPERTIES LIBRARY_OUTPUT_NAME ${MANGLELIB})
set_target_properties(${TARGET} PROPERTIES ARCHIVE_OUTPUT_NAME ${MANGLELIB})
set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_NAME ${MANGLELIB})
set_target_properties(${TARGET} PROPERTIES PREFIX "") # Critical that this be set to ""
set_target_properties(${TARGET} PROPERTIES SUFFIX ".${PLUGINEXT}")
target_link_libraries(${TARGET} PUBLIC ${ALL_TLL_LIBS};${ARGN})
if(MSVC)
target_compile_options(${TARGET} PRIVATE /Zi)
# Tell linker to include symbol data
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF")
# Set file name & location
set_target_properties(${TARGET} PROPERTIES COMPILE_PDB_NAME ${TARGET} COMPILE_PDB_OUTPUT_DIR ${CMAKE_BINARY_DIR})
if(MPI_C_INCLUDE_PATH)
target_include_directories(${TARGET} PRIVATE ${MPI_C_INCLUDE_PATH})
endif(MPI_C_INCLUDE_PATH)
endif()
if(STATUS_PARALLEL)
target_link_libraries(${TARGET} PUBLIC MPI::MPI_C)
endif(STATUS_PARALLEL)
if (USE_HDF5)
target_link_libraries(${TARGET} PRIVATE HDF5::HDF5)
endif(USE_HDF5)
endmacro()
buildplugin(h5misc "h5misc" netcdf)
buildplugin(h5noop "h5noop")
buildplugin(h5noop1 "h5noop1")
buildplugin(h5unknown "h5unknown")
buildplugin(h5shuffle "h5shuffle")
buildplugin(h5fletcher32 "h5fletcher32")
buildplugin(h5deflate "h5deflate")
buildplugin(nczmisc "zmisc")
buildplugin(nczhdf5filters "zhdf5filters" netcdf)
if(NETCDF_ENABLE_BLOSC)
set(h5blosc_SOURCES H5Zblosc.c)
buildplugin(h5blosc "h5blosc" ${Blosc_LIBRARIES})
buildplugin(nczstdfilters "zstdfilters" netcdf;${Blosc_LIBRARIES})
else()
buildplugin(nczstdfilters "zstdfilters" netcdf)
endif()
if(NETCDF_ENABLE_ZSTD)
set(h5zstd_SOURCES H5Zzstd.c H5Zzstd.h)
buildplugin(h5zstd "h5zstd" ${Zstd_LIBRARIES})
endif()
# Need our version of szip if libsz available and we are not using HDF5
if(HAVE_SZ)
set(h5szip_SOURCES H5Zszip.c H5Zszip.h)
buildplugin(h5szip "h5szip" ${Szip_LIBRARIES})
endif()
if(HAVE_LOCAL_BZ2)
set(h5bzip2_SOURCES H5Zbzip2.c blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c bzlib.h bzlib_private.h)
buildplugin(h5bzip2 "h5bzip2")
else()
set(h5bzip2_SOURCES H5Zbzip2.c)
buildplugin(h5bzip2 "h5bzip2" ${Bzip2_LIBRARIES})
endif()
# Installation
if(ENABLE_PLUGIN_INSTALL)
macro(installplugin PLUG)
set(INSTALLED_PLUGIN_LIB "${PLUGINPRE}${PLUG}.${PLUGINEXT}")
message(STATUS "Installing: ${INSTALLED_PLUGIN_LIB} into ${PLUGIN_INSTALL_DIR}")
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${INSTALLED_PLUGIN_LIB} DESTINATION ${PLUGIN_INSTALL_DIR})
endmacro()
install(DIRECTORY DESTINATION ${PLUGIN_INSTALL_DIR})
if(Bzip2_FOUND OR Bz2_FOUND)
installplugin(h5bzip2)
endif()
if(Zstd_FOUND)
installplugin(h5zstd)
endif()
if(Blosc_FOUND)
installplugin(h5blosc)
endif()
if(NETCDF_ENABLE_NCZARR)
installplugin(h5fletcher32)
installplugin(h5shuffle)
installplugin(h5deflate)
installplugin(zhdf5filters)
installplugin(zstdfilters)
if(Szip_FOUND)
installplugin(h5szip)
endif()
endif()
endif(ENABLE_PLUGIN_INSTALL)
endif(NETCDF_ENABLE_PLUGINS)
# Copy some test files from current source dir to out-of-tree build dir.
file(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
if(MSVC)
file(COPY ${COPY_FILES} DESTINATION ${RUNTIME_OUTPUT_DIRECTORY}/)
endif()