File: CMakeLists.txt

package info (click to toggle)
magics++ 2.30.0-5
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 105,040 kB
  • ctags: 32,903
  • sloc: cpp: 185,631; xml: 18,565; ansic: 11,002; perl: 6,357; python: 4,065; sh: 802; f90: 278; asm: 271; makefile: 157
file content (349 lines) | stat: -rw-r--r-- 11,263 bytes parent folder | download
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
############################################################################################
# cmake options:
#
#       -DCMAKE_BUILD_TYPE=Debug|RelWithDebInfo|Release|Production
#
#       -DCMAKE_MODULE_PATH=/path/to/ecbuild/cmake
#
#       -DCMAKE_C_COMPILER=gcc
#       -DCMAKE_C_COMPILER=g++
#
#       -DCMAKE_PREFIX_PATH=/path/to/jasper:/path/to/any/package/out/of/place
#       -DBUILD_SHARED_LIBS=OFF

# TODO:
#  * fix python module generation Magics.py to __init__.py
#  * cpack ecbuild/cmake macros into tar.gz
#  * unit tests check that certain files are produced and not empty
#  * pkg-config needed for metview

# Missing dependencies:
#   * ghostscript ( is it really needed? -- to confirm )

cmake_minimum_required( VERSION 2.8.11 FATAL_ERROR )

project( magics CXX )

# make sure that the header files are installed into include/magics
# note that this needs to be done before ecbuild_declare_project()
# to ensure that the ecbuild header files are also put there
# note also that we need to CACHE this so that ecbuild_declare_project() does not overwrite it
set(MAGICS_INSTALL_INCLUDE_DIR include/magics CACHE PATH "Magics installation directory for header files")
set(INSTALL_INCLUDE_DIR include/magics CACHE PATH "Magics installation directory for header files")

set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild/cmake")

include( ecbuild_system NO_POLICY_SCOPE )

ecbuild_requires_macro_version( 1.9 )

###############################################################################
# some variables of this project

ecbuild_add_option( FEATURE ECCODES DESCRIPTION "" DEFAULT ON )

if( HAVE_ECCODES )
  ecbuild_use_package( PROJECT eccodes VERSION 0.14 REQUIRED )
  set( GRIB_API_INCLUDE_DIRS ${ECCODES_INCLUDE_DIRS} )
  set( GRIB_API_LIBRARIES    ${ECCODES_LIBRARIES} )
  set( GRIB_API_DEFINITIONS  ${ECCODES_DEFINITIONS} )
  set( grib_api_BASE_DIR     ${eccodes_BASE_DIR} )
  set( grib_handling_pkg eccodes )
else()
  ecbuild_use_package(PROJECT grib_api VERSION 1.14.6 REQUIRED)
  set( grib_handling_pkg grib_api )
endif()


# grib_api is required for now
set( HAVE_GRIB 1 )

ecbuild_add_option( FEATURE BUFR
                    DEFAULT ON
                    DESCRIPTION "BUFR support"
                    REQUIRED_PACKAGES "PROJECT libemos VERSION 4.0.5" )

ecbuild_add_option( FEATURE ODB
                    DEFAULT ON
                    DESCRIPTION "ODB support"
                    REQUIRED_PACKAGES "PROJECT odb_api VERSION 0.10.2")
					#	"PROJECT eckit   VERSION 0.9.0" )

ecbuild_add_option( FEATURE CAIRO
                    DEFAULT ON
                    DESCRIPTION "cairo support[png/jpeg]"
                    REQUIRED_PACKAGES PangoCairo )

ecbuild_add_option( FEATURE GEOTIFF
                    DEFAULT OFF
                    DESCRIPTION "geotiff support [implies cairo]"
                    CONDITION HAVE_CAIRO
                    REQUIRED_PACKAGES GeoTIFF )

ecbuild_add_option( FEATURE NETCDF
                    DEFAULT ON
                    DESCRIPTION "enable netcdf support"
                    REQUIRED_PACKAGES "NetCDF 4 COMPONENTS C CXX" )

ecbuild_add_option( FEATURE SPOT
                    DEFAULT OFF
                    DESCRIPTION "enable spot support"
                    REQUIRED_PACKAGES "PROJECT spot" )

ecbuild_add_option( FEATURE PYTHON
                    DEFAULT ON
                    DESCRIPTION "enable python interface"
                    REQUIRED_PACKAGES "Python NO_LIBS" SWIG NumPy )

ecbuild_add_option( FEATURE FORTRAN
                    DEFAULT ON
                    DESCRIPTION "enable Fortran interface" )

if( HAVE_FORTRAN )
	ecbuild_enable_fortran( REQUIRED )
endif()

ecbuild_add_option( FEATURE METVIEW
                    DEFAULT OFF
                    DESCRIPTION "enable Metview interface" )

ecbuild_add_option( FEATURE METVIEW_NO_QT
                    DEFAULT OFF
                    DESCRIPTION "enable Metview interface without Qt" )

ecbuild_add_option( FEATURE QT5
                    DEFAULT OFF
                    DESCRIPTION "use Qt5 instead of version 4" )

ecbuild_add_option( FEATURE PNG
                    DESCRIPTION "support for PNG decoding/encoding"
                    DEFAULT ON
                    REQUIRED_PACKAGES PNG
)

if( HAVE_PNG )
    add_definitions( ${PNG_DEFINITIONS} )
endif()

option( BUILD_SHARED_LIBS  "Set to BOTH to build static library in addition to shared"  ON )
option( ENABLE_REGRESSION        "Internal use only: enable regression test"  OFF  )
option( ENABLE_REGRESSION_UPLOAD "Internal use only : enable upload of reference image"  OFF  )

set( MAGICS_NAME          "Magics" )
set( MAGICS_EXCEPTION     "ON" )
set( MAGICS_SITE          "ecmwf" )
set( MAGICS_INSTALL_PATH  ${CMAKE_INSTALL_PREFIX} )

set( MAGICS_REFERENCE_VERSIONS            "2.29.6" )
set( MAGICS_HTML_ROOT        "${CMAKE_BINARY_DIR}/regression/html")
file(MAKE_DIRECTORY ${MAGICS_HTML_ROOT} )

set( MAG_PYTHON_PATH ${CMAKE_CURRENT_BINARY_DIR}/python )

###############################################################################
# projects

# ecbuild_use_package( PROJECT eckit VERSION 0.3 REQUIRED )

#ecbuild_add_cxx_flags("-gdwarf-2")
ecbuild_add_c_flags("-std=c99")

### Metview and Qt

if(HAVE_METVIEW AND HAVE_METVIEW_NO_QT)
    message(FATAL_ERROR "Do not set both HAVE_METVIEW and HAVE_METVIEW_NO_QT - only set one. You may have to remove your CMakeCache.txt to clear these settings.")
endif()

set( qt no )
set( metview no )

if( HAVE_METVIEW_NO_QT )
	set( metview yes )
	unset(MAGICS_ONLY)
endif()

if( HAVE_METVIEW )
    set ( metview yes)
    message(STATUS "TESTING for Metview ...")
    unset(MAGICS_ONLY)

    if( HAVE_QT5 )
      find_package(Qt5Widgets REQUIRED)
      if( Qt5Widgets_FOUND )
          message(STATUS "Qt5 was found ... ${Qt5Widgets_VERSION_STRING}")
          include_directories(${Qt5Widgets_INCLUDE_DIRS})
          set( MAGICS_QT 1)
          set( MAGICS_QT5 1)
          set( qt yes)
          add_definitions( -DMAGICS_QT5 )
      else()
          message(FATAL_ERROR "Qt5 was NOT found ...")
      endif()
    else()
    find_package(Qt4 4.4.3 REQUIRED QtCore QtGui QtXml )
    if( QT_FOUND )
		  include( ${QT_USE_FILE} )
		  set( MAGICS_QT 1)
		  set( qt yes)
    endif()
    endif()
endif()

ecbuild_declare_project()

###############################################################################
# find extra packages

set( CMAKE_THREAD_PREFER_PTHREAD 1 )
find_package( Threads ) 

# set(Boost_USE_STATIC_LIBS        ON)
# set(Boost_NO_SYSTEM_PATHS        ON)
# set(Boost_USE_MULTITHREADED      ON)
#ecbuild_add_extra_search_paths( boost )

find_package( Boost 1.49.0 REQUIRED)
find_package( Proj4 REQUIRED )
find_package( EXPAT REQUIRED )

###############################################################################
# contents

set( MAGICS_TPLS grib_api spot EXPAT NetCDF PNG Proj4 libemos )

set( MAGICS_INCLUDE_DIRS 
     ${CMAKE_CURRENT_SOURCE_DIR}/src 
     ${CMAKE_BINARY_SOURCE_DIR}/src 
     ${CMAKE_CURRENT_SOURCE_DIR}/src/common 
     ${CMAKE_CURRENT_BINARY_DIR}/src/params 
     ${CMAKE_CURRENT_BINARY_DIR}/src 
     ${CMAKE_CURRENT_SOURCE_DIR}/src/common  
     ${CMAKE_CURRENT_SOURCE_DIR}/src/basic
     ${CMAKE_CURRENT_SOURCE_DIR}/src/web
     ${CMAKE_CURRENT_SOURCE_DIR}/src/visualisers
     ${CMAKE_CURRENT_SOURCE_DIR}/src/drivers
     ${CMAKE_CURRENT_SOURCE_DIR}/src/drivers/MgQ
     ${CMAKE_CURRENT_SOURCE_DIR}/src/eckit_readers
     ${CMAKE_CURRENT_SOURCE_DIR}/src/decoders
     ${CMAKE_CURRENT_SOURCE_DIR}/src/terralib
     ${CMAKE_CURRENT_SOURCE_DIR}/src/terralib/kernel
     ${CMAKE_CURRENT_SOURCE_DIR}/src/libMagWrapper
     ${Boost_INCLUDE_DIRS} )

if( HAVE_CAIRO )
  list( APPEND MAGICS_TPLS PangoCairo )
  list( APPEND MAGICS_INCLUDE_DIRS ${PANGOCAIRO_INCLUDE_DIRS} )
endif()

if( HAVE_ODB )
  list( APPEND MAGICS_TPLS odb_api )
  list( APPEND MAGICS_INCLUDE_DIRS
        ${CMAKE_CURRENT_SOURCE_DIR}/src/oda
        ${ODB_API_INCLUDE_DIRS}
		${ECKIT_INCLUDE_DIRS} )
endif()

set( MAGICS_LIBRARIES    MagPlus )

foreach( _tpl ${MAGICS_TPLS} )
    string( TOUPPER ${_tpl} TPL )
    if( NOT ${TPL} STREQUAL "LIBEMOS" ) # don't add libemos definitions
    list( APPEND MAGICS_EXTRA_DEFINITIONS   ${${TPL}_DEFINITIONS}  )
    endif()
    list( APPEND MAGICS_EXTRA_INCLUDE_DIRS  ${${TPL}_INCLUDE_DIRS} )
    list( APPEND MAGICS_EXTRA_LIBRARIES     ${${TPL}_LIBRARIES} )
endforeach()

if( HAVE_BUFR )
	list( APPEND MAGICS_EXTRA_DEFINITIONS   fortfloat=double fortint=int )
    ecbuild_find_fortranlibs()
	list( APPEND MAGICS_EXTRA_LIBRARIES ${FORTRAN_LIBRARIES} )
endif()
if( WITH_QT_DEBUG )
	list( APPEND MAGICS_EXTRA_DEFINITIONS QT_NO_DEBUG_OUTPUT )
endif()

if( MAGICS_QT )
  if( MAGICS_QT5 )
    list( APPEND MAGICS_EXTRA_INCLUDE_DIRS  ${Qt5Widgets_INCLUDE_DIR} )
    list( APPEND MAGICS_EXTRA_LIBRARIES     ${Qt5Widgets_LIBRARIES} )
  else()
	list( APPEND MAGICS_EXTRA_INCLUDE_DIRS  ${QT_INCLUDE_DIR} )
	list( APPEND MAGICS_EXTRA_LIBRARIES     ${QT_LIBRARIES} )
endif()
endif()

if( HAVE_GEOTIFF )
	list( APPEND MAGICS_EXTRA_INCLUDE_DIRS  ${GEOTIFF_INCLUDE_DIR} )
	list( APPEND MAGICS_EXTRA_LIBRARIES  ${GEOTIFF_LIBRARY} )
  list( APPEND MAGICS_EXTRA_DEFINITIONS HAVE_GEOTIFF )
endif()

list( APPEND MAGICS_EXTRA_LIBRARIES     ${CMAKE_THREAD_LIBS_INIT} )

ecbuild_debug("MAGICS_EXTRA_DEFINITIONS  => ${MAGICS_EXTRA_DEFINITIONS}")
ecbuild_debug("MAGICS_EXTRA_INCLUDE_DIRS => ${MAGICS_EXTRA_INCLUDE_DIRS}")
ecbuild_debug("MAGICS_EXTRA_LIBRARIES    => ${MAGICS_EXTRA_LIBRARIES}")

# set_directory_properties( PROPERTIES COMPILE_DEFINITIONS "${ECKIT_DEFINITIONS}" )
get_directory_property( MAGICS_DEFINITIONS COMPILE_DEFINITIONS )

include_directories( ${MAGICS_INCLUDE_DIRS} ${MAGICS_EXTRA_INCLUDE_DIRS} )

# scripts
add_subdirectory( tools )

# source files
add_subdirectory( src )

# shared files
add_subdirectory( share )

# python interface 
add_subdirectory( python )

# apps directory
add_subdirectory( apps )

# Test directory
add_subdirectory( test )
if( ENABLE_REGRESSION )
    add_subdirectory( regression )
endif()

# Directories not need in the distribution tar ball!
ecbuild_add_resources( TARGET old_src DONT_PACK_DIRS src/MvObs src/libTable src/xml src/terralib/functions)
ecbuild_add_resources( TARGET bamboo DONT_PACK_DIRS bamboo)
ecbuild_add_resources( TARGET old_ressources 
		DONT_PACK_DIRS tools/versioncmp 
		tools/regression 
		regression
		docs
		toolsjs
		test/old
		tools/xml 
		tools/use_scripts
		tools/versioncmp_folders)

ecbuild_add_resources( TARGET internal 
		DONT_PACK configure.lxab
		configure.local
		configure.ecgb
		configure.ecmwf
)

############################################################################################
# finalize

set( MAGICS_DESCRIPTION "Multi-platform meteorological graphics library" )
set( MAGICS_URL "https://software.ecmwf.int/wiki/display/MAGP/Magics" )
ecbuild_pkgconfig(
  NAME magics
  URL         "https://software.ecmwf.int/wiki/display/MAGP/Magics"
  DESCRIPTION "ECMWF meteorological plotting software library"
  LANGUAGES   C++
  LIBRARIES   MagPlusShared MagPlusSingleShared MagPlusDoubleShared MagPlusStatic MagPlusSingleStatic MagPlusDoubleStatic MagWrappe )

ecbuild_install_project( NAME Magics )

ecbuild_print_summary()