File: CMakeLists.txt

package info (click to toggle)
metview 5.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 242,296 kB
  • sloc: cpp: 437,117; ansic: 41,433; xml: 19,944; f90: 13,059; sh: 6,562; python: 3,953; yacc: 1,774; lex: 1,121; perl: 701; makefile: 92
file content (331 lines) | stat: -rw-r--r-- 7,007 bytes parent folder | download | duplicates (4)
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
### config headers

# if we are not building inside the mars-client-bundle we won't have this defined
if(NOT DEFINED MARSCLIENT_VERSION_STR )
  set(MARSCLIENT_VERSION_STR ${MARS_CLIENT_VERSION_STR})
endif()

configure_file( mars_client_version.h.in  mars_client_version.h )
configure_file( mars_client_version.c.in  mars_client_version.c )

# compile definitions

ecbuild_generate_config_headers()

configure_file( mars_client_config.h.in    mars_client_config.h   )

# install generated headers

install(FILES
			${CMAKE_CURRENT_BINARY_DIR}/mars_client_version.h
			${CMAKE_CURRENT_BINARY_DIR}/mars_client_config.h
		DESTINATION
			${INSTALL_INCLUDE_DIR}/marsclient )

add_definitions( -DR64 )

if( ECMWF )
    add_definitions( -DECMWF )
endif()

test_big_endian( _BIG_ENDIAN )

if( _BIG_ENDIAN )
	message( STATUS "System is big endian" )
else()
	message( STATUS "System is little endian" )
	add_definitions(-DLITTLE_END)
endif()

if( NOT HAVE_FDB )
    add_definitions(-DNOFDB)
endif()

if( NOT HAVE_FDB5 )
    add_definitions(-DNOFDB5)
endif()

if( NOT HAVE_ODB )
	add_definitions(-DNOODB)
else()
	add_definitions(-DODB_SUPPORT )
	include_directories( ${ODB_API_INCLUDE_DIRS} ${ECKIT_INCLUDE_DIRS} )
endif()

if( HAVE_PPROC_EMOS )
    list( APPEND mars_client_src_files pproc_emos.cc )
endif()

if( HAVE_PPROC_MIR )
    list( APPEND mars_client_src_files pproc_mir.cc )
endif()

if( NOT HAVE_CURL )
	add_definitions(-DNOCURL)
endif()

if(HAVE_ECMWF_DEVELOPMENT)
  add_definitions(-DECMWF)
  add_definitions(-DNOEMS)
  add_definitions(-DNOAUTH)
  add_definitions(-DNOSCHEDULE)
endif()

# sources

list( APPEND mars_client_src_files
account.c
archive.c
authenticate.c
base.c
bufr.c
calc.c
certify.c
check.c
control.c
cos.c
ecaccess.c
eccert.c
environ.c
expand.c
extargs.c
externf.c
fdb5base.cc
forwardbase.c
feedtask.c
field.c
filebase.c
files.c
flatfilebase.c
free.c
gribbase.c
grib.c
guess.c
handler.c
hash.c
hidden.c
hypercube.c
ibmblk.c
index.c
langy.c
list.c
lock.c
logfile.c
mcs.c
memory.c
dhsbase.c
metadata.c
msbase.c
multibase.c
netbase.c
netcdf.c
hdf5.c
nfdbbase.c
nullbase.c
options.c
pproc.h
pproc.cc
pproc_none.cc
queue.c
rdb.c
remove.c
request.c
restricted.c
retrieve.c
schedule.c
server.c
service.c
sh2ll.c
statistics.c
stream.c
target.c
tcp.c
time.c
timer.c
tools.c
udp.c
variable.c
version.c
json.c
api.c
apibase.c
wind.c)

if(HAVE_UDP_STATS)
  list(APPEND mars_client_src_files udp_statistics.cc)
endif()

if(HAVE_NETCDF)

  list(APPEND mars_client_src_files
    nctarget.c
    nctypes.c
    ncschema.c
    ncmerge.c
    )

endif()

if(HAVE_ODB)
    list(APPEND mars_client_src_files
        odb.cc
    )
endif()

ecbuild_find_lexyacc()
if(FLEX_FOUND)
    set(_lex ${FLEX_EXECUTABLE})
elseif(LEX_FOUND)
    set(_lex ${LEX_EXECUTABLE})
else()
    ecbuild_critical("Found neither flex nor lex")
endif()

if(YACC_FOUND)
    set(_yacc ${YACC_EXECUTABLE})
elseif(BISON_FOUND)
    set(_yacc ${BISON_EXECUTABLE} -y)
else()
    ecbuild_critical("Found neither yacc nor bison")
endif()

if(mars_client_HAVE_RPC)

  list( APPEND mars_client_src_files marsxdr.c )
  list( APPEND mars_client_deps marsxdr )

  if( DEFINED RPCGEN_PATH )
      find_program( RPCGEN_EXECUTABLE NAMES rpcgen PATHS ${RPCGEN_PATH} PATH_SUFFIXES bin NO_DEFAULT_PATH )
  endif()
  find_program( RPCGEN_EXECUTABLE NAMES rpcgen )
  if( NOT RPCGEN_EXECUTABLE )
    ecbuild_critical("Could not find rpcgen. Please provide RPCGEN_PATH.")
  endif()

  # targets

  configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rpcmars.x ${CMAKE_CURRENT_BINARY_DIR}/rpcmars.x COPYONLY )

  add_custom_command(
      OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rpcmars.h
      COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/rpcmars.h
      COMMAND ${RPCGEN_EXECUTABLE} -h -o ${CMAKE_CURRENT_BINARY_DIR}/rpcmars.h ${CMAKE_CURRENT_BINARY_DIR}/rpcmars.x
      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/rpcmars.x )

  add_custom_command(
      OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/marsxdr.c
      COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/marsxdr.c
      COMMAND ${RPCGEN_EXECUTABLE} -c -o ${CMAKE_CURRENT_BINARY_DIR}/marsxdr.c ${CMAKE_CURRENT_BINARY_DIR}/rpcmars.x
      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/rpcmars.x )

  add_custom_target(marsxdr DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/rpcmars.h ${CMAKE_CURRENT_BINARY_DIR}/marsxdr.c)

  list(APPEND _make_cleans rpcmars.h marsxdr.c )

endif()

add_custom_command(
    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/langl.c
	  COMMAND ${_lex} -l ${CMAKE_CURRENT_SOURCE_DIR}/langl.l\; sed -e s/yy/yy_mars/g < lex.yy.c > ${CMAKE_CURRENT_BINARY_DIR}/langl.c
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/langl.l)

add_custom_command(
    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/langy.c
	  COMMAND ${_yacc} -t ${CMAKE_CURRENT_SOURCE_DIR}/langy.y\; sed -e s/yy/yy_mars/g < y.tab.c > ${CMAKE_CURRENT_BINARY_DIR}/langy.c
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/langy.y)

list(APPEND _make_cleans langl.c langy.c )

add_custom_target(marslex DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/langy.c ${CMAKE_CURRENT_BINARY_DIR}/langl.c)
list( APPEND mars_client_deps marslex)

set_directory_properties( ADDITIONAL_MAKE_CLEAN_FILES  ${_make_cleans} )

set( grib_handling_pkg eccodes )

set(MARSC_HEADER_FILES_TO_INSTALL
        api.h
        base.h
        bufr.h
        control.h
        cos.h
        field.h
        globals.h
        grib.h
        hypercube.h
        index.h
        json.h
        lang.h
        mars.h
        nctarget.h
        proto.h
        hash.h
        tools.h
        variable.h
)

if(mars_client_HAVE_RPC)
  list(APPEND MARSC_HEADER_FILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/rpcmars.h)
endif()

ecbuild_add_library(
  TARGET      marsclient
  GENERATED   mars_client_version.c
  INSTALL_HEADERS_LIST ${MARSC_HEADER_FILES_TO_INSTALL}
  HEADER_DESTINATION ${INSTALL_INCLUDE_DIR}/marsclient

	SOURCES
      ${mars_client_src_files}
      mars_client_version.c
	DEPENDS
	${mars_client_deps}
	VERSION 0.0.0
	SOVERSION 0d

  PUBLIC_INCLUDES
       $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>
       $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
       ${RPC_INCLUDE_DIRS}

  PRIVATE_INCLUDES
        ${ECKIT_INCLUDE_DIRS}
        ${MARS_SERVER_INCLUDE_DIRS}
        ${FDB5_INCLUDE_DIRS}
        ${MIR_INCLUDE_DIRS}
        ${CURL_INCLUDE_DIRS}

  PUBLIC_LIBS
        eccodes
        ${RPC_LIBRARIES}

  PRIVATE_LIBS
        ${FDB5_LIBRARIES}
        ${MARS_FEATURE_LIBRARIES}
        ${CURL_LIBRARIES}
        ${CMATH_LIBRARIES}
        ${CMAKE_THREAD_LIBS_INIT}
)

set(_marsbin_noinstall NOINSTALL) # still needed for the tests
if(HAVE_BUILD_TOOLS)
  set(_marsbin_noinstall)
endif()
ecbuild_add_executable(
    TARGET    mars.bin
    INCLUDES  ${MIR_INCLUDE_DIRS} ${LIBEMOS_INCLUDE_DIRS}
    SOURCES   mars.c
    LIBS      marsclient ${MARS_FEATURE_LIBRARIES}
    ${_marsbin_noinstall}
)

ecbuild_add_executable(
    NOINSTALL
    TARGET    test-udp-stats
    SOURCES   test-udp-stats.c
    CONDITION HAVE_UDP_STATS
    LIBS      marsclient
)

if(HAVE_BUILD_TOOLS)
  add_subdirectory( tools )
endif()