CMakeLists.txt 18.7 KB
Newer Older
1
2
3
4
5
6
#-----------------------------------------------------------------------------
# Does Xdmf require support for 64 bit file systems
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CheckCXXSourceRuns.cmake)
FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/vtkRequireLargeFilesSupport.cxx"
  XDMF_REQUIRE_LARGE_FILE_SUPPORT_FILE)
CHECK_CXX_SOURCE_RUNS("${XDMF_REQUIRE_LARGE_FILE_SUPPORT_FILE}"
Alexander Neundorf's avatar
   
Alexander Neundorf committed
7
8
  CMAKE_REQUIRE_LARGE_FILE_SUPPORT "Xdmf support for 64 bit file systems")
SET(XDMF_REQUIRE_LARGE_FILE_SUPPORT ${CMAKE_REQUIRE_LARGE_FILE_SUPPORT})
9
10
11
12
13
14
15
16
17
# This Needs to be done since Xdmf/CMakeLists.txt != PV/Utils/Xdmf2/CMakeLists.txt
# Because INSTALL_* commands require a leading / and because INSTALL (cmake 2.4
# and newer) requires no leading / to install under INSTALL_PREFIX, we
# are stripping the leading /. In the future, there should be no leading
# / in any install directory variables
STRING(REGEX REPLACE "^/" "" VTK_INSTALL_LIB_DIR_CM24 "${XDMF_INSTALL_LIB_DIR}")
STRING(REGEX REPLACE "^/" "" VTK_INSTALL_BIN_DIR_CM24 "${XDMF_INSTALL_BIN_DIR}")
STRING(REGEX REPLACE "^/" "" VTK_INSTALL_INCLUDE_DIR_CM24 "${XDMF_INSTALL_INCLUDE_DIR}")
STRING(REGEX REPLACE "^/" "" VTK_INSTALL_PACKAGE_DIR_CM24 "${XDMF_LIB_INCLUDE_DIR}/vtk")
18
19
20
21
22
23
#
SET(XDMF_INSTALL_LIB_DIR_CM24 ${VTK_INSTALL_LIB_DIR_CM24})
SET(XDMF_INSTALL_BIN_DIR_CM24 ${VTK_INSTALL_BIN_DIR_CM24})
SET(XDMF_INSTALL_INCLUDE_DIR_CM24 ${VTK_INSTALL_INCLUDE_DIR_CM24})
SET(XDMF_INSTALL_PACKAGE_DIR_CM24 ${VTK_INSTALL_PACKAGE_DIR_CM24})

24
25
26
27
IF(NOT XDMF_INSTALL_EXPORT_NAME)
  SET(XDMF_INSTALL_EXPORT_NAME XdmfTargets)
ENDIF()

28
SET( XdmfFormatSource
29
  XdmfArray
Jerry Clarke's avatar
fixing    
Jerry Clarke committed
30
  XdmfDOM
31
32
  XdmfDataDesc
  XdmfExpression
33
34
  XdmfValues
  XdmfValuesXML
35
  XdmfValuesHDF
36
  XdmfValuesBinary
37
38
39
40
  XdmfHeavyData
  XdmfHDF
  XdmfHDFSupport
  XdmfLightData
Jerry Clarke's avatar
Jerry Clarke committed
41
  XdmfInformation
Jerry Clarke's avatar
fixing    
Jerry Clarke committed
42
  XdmfDataItem
43
  XdmfDataStructure
44
  XdmfDataTransform
Jerry Clarke's avatar
Jerry Clarke committed
45
  XdmfElement
46
47
  XdmfObject
  )
Jerry Clarke's avatar
Jerry Clarke committed
48

Jerry Clarke's avatar
Jerry Clarke committed
49
SET( XdmfExtraSource
50
51
52
  XdmfExprLex
  XdmfExprYacc
  )
Jerry Clarke's avatar
Jerry Clarke committed
53

54
SET( XdmfModelSource
Jerry Clarke's avatar
Jerry Clarke committed
55
  XdmfRoot
56
  XdmfDomain
57
58
59
  XdmfAttribute
  XdmfGrid
  XdmfTopology
60
  XdmfTime
61
  XdmfRegion
Jerry Clarke's avatar
Jerry Clarke committed
62
63
  XdmfSet
  XdmfMap
64
  XdmfGeometry
65
  XdmfH5Driver
66
67
68
69
  XdmfDsm
  XdmfDsmBuffer
  XdmfDsmComm
  XdmfDsmMsg
70
71
  )

Jerry Clarke's avatar
Jerry Clarke committed
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
SET(CSHARP_SOURCES 
	SWIGTYPE_p_double.cs
	SWIGTYPE_p_float.cs
	SWIGTYPE_p_hid_t.cs
	SWIGTYPE_p_int.cs
	SWIGTYPE_p_istream.cs
	SWIGTYPE_p_long_long.cs
	SWIGTYPE_p_ostream.cs
	SWIGTYPE_p_p__xmlDoc.cs
	SWIGTYPE_p_void.cs
	SWIGTYPE_p__xmlNode.cs
	XdmfArray.cs
	XdmfArrayList.cs
	XdmfAttribute.cs
	XdmfCSharp.cs
	XdmfCSharpPINVOKE.cs
	XdmfDataDesc.cs
	XdmfDataItem.cs
	XdmfDataStructure.cs
	XdmfDomain.cs
	XdmfDOM.cs
	XdmfDsmComm.cs
	XdmfDsmCommMpi.cs
	XdmfDsm.cs
	XdmfElement.cs
	XdmfGeometry.cs
	XdmfGrid.cs
	XdmfHDF.cs
	XdmfHeavyData.cs
	XdmfInformation.cs
	XdmfLightData.cs
	XdmfMap.cs
	XdmfObject.cs
	XdmfRegion.cs
	XdmfRoot.cs
	XdmfSet.cs
	XdmfTime.cs
	XdmfTopology.cs
	XdmfValues.cs
	XdmfValuesHDF.cs
	XdmfValuesXML.cs
 	XdmfDsmBuffer.cs
	XdmfDsmMsg.cs
	XdmfOpenCallback.cs
	XdmfCloseCallback.cs
	XdmfReadCallback.cs
	XdmfWriteCallback.cs 
	)

Jerry Clarke's avatar
Jerry Clarke committed
121
122
123
124
SET( XdmfGzipSource
  gzstream
   )

125
126
127
128
129
130
IF(XDMF_BUILD_VTK)
  IF(NOT VTK_USE_SYSTEM_ZLIB)
    ADD_DEFINITIONS(-DXDMF_USE_VTK_ZLIB)
  ENDIF(NOT VTK_USE_SYSTEM_ZLIB)
ENDIF(XDMF_BUILD_VTK)

131
132
133
134
135
# IF(XDMF_BUILD_MPI)
#     SET(XdmfModelSource ${XdmfModelSource} XdmfH5Driver)
# ENDIF(XDMF_BUILD_MPI) 

SET( XdmfMpiSource
136
  XdmfDsmCommMpi
137
  )
Jerry Clarke's avatar
Jerry Clarke committed
138

Jerry Clarke's avatar
Jerry Clarke committed
139
140
141
142
SET( XdmfMySQLSource
    XdmfValuesMySQL
    )

143
SET( XdmfPythonSource
144
145
  XdmfPython
  )
Jerry Clarke's avatar
Jerry Clarke committed
146

147
148
149
150
SET( XdmfPythonSourceNoMpi
  XdmfPythonNoMpi
  )

Kenneth Leiter's avatar
ENH:    
Kenneth Leiter committed
151
152
153
154
155
156
IF(XDMF_BUILD_MPI)
  SET(XDMF_PYTHON_FILE ${Xdmf_SOURCE_DIR}/libsrc/Xdmf.py)
ELSE(XDMF_BUILD_MPI)
  SET(XDMF_PYTHON_FILE ${Xdmf_SOURCE_DIR}/libsrc/XdmfNoMpi.py)
ENDIF(XDMF_BUILD_MPI)

157
OPTION(XDMF_REGENERATE_WRAPPERS
158
  "Regenerate XdmfPython.cxx" OFF)
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
MARK_AS_ADVANCED(XDMF_REGENERATE_WRAPPERS)
IF(XDMF_REGENERATE_WRAPPERS)
  FIND_PROGRAM(SWIG_EXECUTABLE 
    NAMES swig-1.3 swig
    PATHS /usr/bin
    DOC "Swig executable for generating wrapped files")
  MARK_AS_ADVANCED(SWIG_EXECUTABLE)
  IF(SWIG_EXECUTABLE)
    SET(XDMF_SWIG_INCLUDES 
      -I${Xdmf_SOURCE_DIR} 
      -I${Xdmf_SOURCE_DIR}/libsrc 
      -I${Xdmf_BINARY_DIR}/libsrc 
      -I${Xdmf_SOURCE_DIR}/Ice/libsrc
      -I${Xdmf_BINARY_DIR}/Ice/libsrc
      )
174
175
    GET_FILENAME_COMPONENT(SWIG_EXE_PATH ${SWIG_EXECUTABLE}
      PATH)
Jerry Clarke's avatar
Jerry Clarke committed
176
    SET(SWIG_LIB_PATH "${SWIG_EXE_PATH}/Lib")
177
    # MESSAGE("SWIG_LIB_PATH ${SWIG_LIB_PATH}")
178
179
180
181
182
183
184
185
    IF(EXISTS "${SWIG_LIB_PATH}")
      SET(XDMF_SWIG_INCLUDES
        ${XDMF_SWIG_INCLUDES}
        -I${SWIG_LIB_PATH}
        -I${SWIG_LIB_PATH}/tcl
        -I${SWIG_LIB_PATH}/python
        )
    ENDIF(EXISTS "${SWIG_LIB_PATH}")
186
    FOREACH(LANGUAGE Python)
187
      STRING(TOLOWER ${LANGUAGE} lang)
Jerry Clarke's avatar
Jerry Clarke committed
188
#      SET(swigtarget ${Xdmf_BINARY_DIR}/libsrc/Xdmf${LANGUAGE}.cxx)
189
      IF(XDMF_BUILD_MPI)
Jerry Clarke's avatar
Jerry Clarke committed
190
        SET(swigtarget ${Xdmf_BINARY_DIR}/libsrc/Xdmf${LANGUAGE}.cxx)
191
192
193
194
195
196
        ADD_CUSTOM_COMMAND(
         OUTPUT ${swigtarget}
         DEPENDS ${Xdmf_SOURCE_DIR}/libsrc/Xdmf.i
         COMMAND ${SWIG_EXECUTABLE}
         ARGS -v -c++ -make_default -includeall "-${lang}" ${swig_extra_args} ${XDMF_SWIG_INCLUDES} -o "${swigtarget}" Xdmf.i)
      ELSE(XDMF_BUILD_MPI) 
Jerry Clarke's avatar
Jerry Clarke committed
197
        SET(swigtarget ${Xdmf_BINARY_DIR}/libsrc/Xdmf${LANGUAGE}NoMpi.cxx)
198
199
200
201
202
203
        ADD_CUSTOM_COMMAND(
         OUTPUT ${swigtarget}
         DEPENDS ${Xdmf_SOURCE_DIR}/libsrc/Xdmf.i
         COMMAND ${SWIG_EXECUTABLE}
         ARGS -v -c++ -DXDMF_NO_MPI -make_default -includeall "-${lang}" ${swig_extra_args} ${XDMF_SWIG_INCLUDES} -o "${swigtarget}" Xdmf.i)
      ENDIF(XDMF_BUILD_MPI) 
204
205
206
207
208
209

    ENDFOREACH(LANGUAGE)
    ADD_CUSTOM_TARGET(RerunSwig DEPENDS 
      ${Xdmf_BINARY_DIR}/libsrc/XdmfPython.cxx
      )
  ENDIF(SWIG_EXECUTABLE)
210
  SET(XDMF_PYTHON_FILE ${Xdmf_BINARY_DIR}/libsrc/Xdmf.py)
211
212
ENDIF(XDMF_REGENERATE_WRAPPERS)

Jerry Clarke's avatar
Jerry Clarke committed
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
OPTION(XDMF_REGENERATE_YACCLEX
  "Regenerate XdmfExprYacc.cxx and XdmfExprLex.cxx" OFF)
MARK_AS_ADVANCED(XDMF_REGENERATE_YACCLEX)
IF(XDMF_REGENERATE_YACCLEX)
  FIND_PROGRAM(YACC_EXECUTABLE
    NAMES yacc bison
    PATHS /usr/bin
    DOC "Yacc or Bison executable")
  FIND_PROGRAM(FLEX_EXECUTABLE
    NAMES flex
    PATHS /usr/bin
    DOC "Flex executable")
  MARK_AS_ADVANCED(YACC_EXECUTABLE FLEX_EXECUTABLE)
  IF(YACC_EXECUTABLE)
    SET(BISON_FLAGS)
    IF(YACC_EXECUTABLE MATCHES "bison")
      SET(BISON_FLAGS "-y")
    ENDIF(YACC_EXECUTABLE MATCHES "bison")
    ADD_CUSTOM_COMMAND(
      OUTPUT ${Xdmf_BINARY_DIR}/libsrc/XdmfExprYacc.tab.c
      DEPENDS ${Xdmf_SOURCE_DIR}/libsrc/XdmfExpr.y
      COMMAND ${YACC_EXECUTABLE}
      ARGS ${BISON_FLAGS} -d -b ${Xdmf_BINARY_DIR}/libsrc/XdmfExprYacc
      -p dice_yy
      ${Xdmf_SOURCE_DIR}/libsrc/XdmfExpr.y
      )
    ADD_CUSTOM_COMMAND(
      OUTPUT ${Xdmf_BINARY_DIR}/libsrc/XdmfExprYacc.tab.h
      DEPENDS ${Xdmf_SOURCE_DIR}/libsrc/XdmfExpr.y
      COMMAND ${YACC_EXECUTABLE}
      ARGS ${BISON_FLAGS} -d -b ${Xdmf_BINARY_DIR}/libsrc/XdmfExprYacc
      -p dice_yy
      ${Xdmf_SOURCE_DIR}/libsrc/XdmfExpr.y
      )
    ADD_CUSTOM_COMMAND(
      OUTPUT ${Xdmf_BINARY_DIR}/libsrc/XdmfExprYacc.cxx
      DEPENDS ${Xdmf_BINARY_DIR}/libsrc/XdmfExprYacc.tab.c
      COMMAND ${CMAKE_COMMAND}
      ARGS -E copy ${Xdmf_BINARY_DIR}/libsrc/XdmfExprYacc.tab.c
      ${Xdmf_BINARY_DIR}/libsrc/XdmfExprYacc.cxx
      )
    ADD_CUSTOM_TARGET(RerunYacc DEPENDS
      ${Xdmf_BINARY_DIR}/libsrc/XdmfExprYacc.cxx)
  ENDIF(YACC_EXECUTABLE)
  IF(FLEX_EXECUTABLE)
    ADD_CUSTOM_COMMAND(
      OUTPUT ${Xdmf_BINARY_DIR}/libsrc/XdmfExprLex.cxx
      DEPENDS ${Xdmf_SOURCE_DIR}/libsrc/XdmfExpr.l
      COMMAND ${FLEX_EXECUTABLE}
      ARGS -Pdice_yy -o${Xdmf_BINARY_DIR}/libsrc/XdmfExprLex.cxx 
      ${Xdmf_SOURCE_DIR}/libsrc/XdmfExpr.l)
    ADD_CUSTOM_TARGET(RerunLex DEPENDS
      ${Xdmf_BINARY_DIR}/libsrc/XdmfExprLex.cxx)
  ENDIF(FLEX_EXECUTABLE)

ENDIF(XDMF_REGENERATE_YACCLEX)

Jerry Clarke's avatar
Jerry Clarke committed
271

272
273
274
275
276
IF (VTK_USE_MPI)
  # Needed for mpich 2
  ADD_DEFINITIONS("-DMPICH_IGNORE_CXX_SEEK")
ENDIF (VTK_USE_MPI)

277
INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
278
IF(WIN32)
279
  CHECK_TYPE_SIZE(__int64        SIZEOF___INT64)
280
ENDIF(WIN32)
281
CHECK_TYPE_SIZE("long long"    SIZEOF_LONG_LONG)
Jerry Clarke's avatar
Jerry Clarke committed
282

283
284
285
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
CHECK_INCLUDE_FILE(malloc.h XDMF_HAVE_MALLOC_H)

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
# System to Build
STRING(REGEX REPLACE "-" "_" XDMF_SYSTEM ${CMAKE_SYSTEM_NAME})

SET(ARCH_TO_BUILD ${XDMF_SYSTEM} CACHE INTERNAL "Host Arcitecture : Linux IRIXN32 IRIX64 AIX CYGWIN")
# Allow the user to customize their build with some local options
#
ADD_DEFINITIONS(-D${ARCH_TO_BUILD})

SET(XDMF_SIZEOF_CHAR   ${CMAKE_SIZEOF_CHAR})
SET(XDMF_SIZEOF_DOUBLE ${CMAKE_SIZEOF_DOUBLE})
SET(XDMF_SIZEOF_FLOAT  ${CMAKE_SIZEOF_FLOAT})
SET(XDMF_SIZEOF_INT    ${CMAKE_SIZEOF_INT})
SET(XDMF_SIZEOF_LONG   ${CMAKE_SIZEOF_LONG})
SET(XDMF_SIZEOF_SHORT  ${CMAKE_SIZEOF_SHORT})
INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
IF(WIN32)
  CHECK_TYPE_SIZE(__int64        SIZEOF___INT64)
ENDIF(WIN32)
CHECK_TYPE_SIZE("long long"    SIZEOF_LONG_LONG)
CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)

# Don't Really Need to check these ...
SET(XDMF_VOID_VALID 1)
SET(XDMF_VOID "void")
SET(XDMF_PTR_VALID 1)
SET(XDMF_PTR "void *")
SET(XDMF_CHAR_VALID 1)
SET(XDMF_CHAR "char")
SET(XDMF_8_INT_VALID 1)
SET(XDMF_8_INT  "char")
SET(XDMF_8_U_INT  "unsigned char")
SET(XDMF_16_INT_VALID 1)
SET(XDMF_16_INT "short")
SET(XDMF_16_U_INT "unsigned short")
# These should be Valid
IF(${XDMF_SIZEOF_FLOAT} MATCHES 4)
  SET(XDMF_32_FLOAT_VALID 1)
  SET(XDMF_FLOAT "float")
  SET(XDMF_32_FLOAT "float")
ELSE (${XDMF_SIZEOF_FLOAT} MATCHES 4)
  MESSAGE(SEND_ERROR "Can't Find a 32 Bit Float")
ENDIF (${XDMF_SIZEOF_FLOAT} MATCHES 4)
IF(${XDMF_SIZEOF_DOUBLE} MATCHES 8)
  SET(XDMF_64_FLOAT_VALID 1)
  SET(XDMF_DOUBLE "double")
  SET(XDMF_64_FLOAT "double")
ELSE (${XDMF_SIZEOF_DOUBLE} MATCHES 8)
  MESSAGE(SEND_ERROR "Can't Find a 64 Bit Float")
ENDIF (${XDMF_SIZEOF_DOUBLE} MATCHES 8)
# These are sometimes different
IF(${XDMF_SIZEOF_INT} MATCHES 4)
  SET(XDMF_32_INT_VALID 1)
  SET(XDMF_32_INT "int")
  SET(XDMF_32_U_INT "unsigned int")
  SET(XDMF_32_S_INT "int")
ELSE (${XDMF_SIZEOF_INT} MATCHES 4)
  IF(${XDMF_SIZEOF_LONG} MATCHES 4)
    SET(XDMF_32_INT_VALID 1)
    SET(XDMF_32_INT "long")
    SET(XDMF_32_U_INT "unsigned long")
    SET(XDMF_32_S_INT "long")
  ELSE(${XDMF_SIZEOF_LONG} MATCHES 4)
    MESSAGE(SEND_ERROR "Can't Find a 32 Bit Integer")
  ENDIF(${XDMF_SIZEOF_LONG} MATCHES 4)
ENDIF(${XDMF_SIZEOF_INT} MATCHES 4)

INCLUDE(${Xdmf_SOURCE_DIR}/CMake/CheckFor64BitStreams.cmake)
CHECK_FOR_64BIT_STREAMS(XDMF_HAVE_64BIT_STREAMS)

# Find include files
FIND_PATH(XDMF_HAVE_FCNTL fcntl.h /usr/include /usr/include/sys)
FIND_PATH(XDMF_HAVE_NETINET in.h /usr/include/netinet /usr/include /usr/include/sys)
FIND_PATH(XDMF_HAVE_MMAN mman.h /usr/include/sys /usr/include)
MARK_AS_ADVANCED(XDMF_HAVE_FCNTL XDMF_HAVE_NETINET XDMF_HAVE_MMAN)

Jerry Clarke's avatar
Jerry Clarke committed
362

363
##
364
CONFIGURE_FILE(${Xdmf_SOURCE_DIR}/libsrc/XdmfConfig.h.in
365
  ${Xdmf_BINARY_DIR}/libsrc/XdmfConfig.h)
366

367
368
369
370
IF(NOT WIN32)
  ADD_DEFINITIONS(-D_HPUX_SOURCE)
ENDIF(NOT WIN32)

Andy Cedilnik's avatar
Andy Cedilnik committed
371
SET(XdmfSources ${XdmfFormatSource} ${XdmfExtraSource} ${XdmfModelSource})
Jerry Clarke's avatar
Jerry Clarke committed
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392

OPTION(XDMF_USE_MYSQL
    "Build Support for MySQL DataItems" OFF)
MARK_AS_ADVANCED(XDMF_USE_MYSQL)
IF(XDMF_USE_MYSQL)
    FIND_PATH(MYSQL_INCLUDE_PATH
        mysql.h
        /usr/include
        /usr/include/mysql
        /usr/local/include
        /usr/local/include/mysql)
    FIND_LIBRARY(MYSQL_CLIENT_LIBRARY
        mysqlclient
        /usr/lib
        /usr/lib/mysql
        /usr/local/lib
        /usr/local/lib/mysql)
    SET(XdmfSources ${XdmfSources} ${XdmfMySQLSource})
    ADD_DEFINITIONS("-DXDMF_USE_MYSQL")
    INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_PATH})
ENDIF(XDMF_USE_MYSQL)
Jerry Clarke's avatar
Jerry Clarke committed
393
# gzip
Jerry Clarke's avatar
Jerry Clarke committed
394
395
OPTION(XDMF_USE_GZIP "Build GZip Compression" OFF)
IF(XDMF_USE_GZIP)
Jerry Clarke's avatar
Jerry Clarke committed
396
SET(XdmfSources ${XdmfSources} ${XdmfGzipSource})
Jerry Clarke's avatar
Jerry Clarke committed
397
398
    ADD_DEFINITIONS("-DXDMF_USE_GZIP")
ENDIF(XDMF_USE_GZIP)
Jerry Clarke's avatar
Jerry Clarke committed
399
400
401
402
403
404
405
406
407
408
# bz2lib
OPTION(XDMF_USE_BZIP2 "Use bzip2" OFF)
IF(XDMF_USE_BZIP2)
  FIND_PACKAGE(BZip2)
  SET(XDMF_BZIP2_LIBRARIES ${BZIP2_LIBRARIES})
  SET(XDMF_BZIP2_INCLUDE_DIR ${BZIP2_INCLUDE_DIR})
  INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
  ADD_DEFINITIONS("-DXDMF_USE_BZIP2")
ENDIF(XDMF_USE_BZIP2)

Jerry Clarke's avatar
Jerry Clarke committed
409
410
411
412
413
414
## MPI ###
IF(XDMF_BUILD_MPI)
    SET(XdmfSources ${XdmfSources} ${XdmfMpiSource})
ELSE(XDMF_BUILD_MPI)
    ADD_DEFINITIONS("-DXDMF_NO_MPI")
ENDIF(XDMF_BUILD_MPI)
Andy Cedilnik's avatar
Andy Cedilnik committed
415

416
417
418
419
420
421
422
IF(VTK_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
  SET(LIBTYPE SHARED)
ELSE(VTK_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
  SET(LIBTYPE STATIC)
ENDIF(VTK_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)

ADD_LIBRARY(Xdmf ${LIBTYPE} ${XdmfSources})
423

Jerry Clarke's avatar
Jerry Clarke committed
424
425
426
427
428
429
IF(XDMF_USE_MYSQL)
    ADD_DEFINITIONS("-DXDMF_USE_MYSQL")
    INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_PATH})
    TARGET_LINK_LIBRARIES(Xdmf ${MYSQL_CLIENT_LIBRARY} )
ENDIF(XDMF_USE_MYSQL)

430
IF(XDMF_BUILD_MPI)
431
432
433
434
  IF(MPI_EXTRA_LIBRARY)
    TARGET_LINK_LIBRARIES(Xdmf ${MPI_EXTRA_LIBRARY})
  ENDIF(MPI_EXTRA_LIBRARY)
  TARGET_LINK_LIBRARIES(Xdmf ${MPI_LIBRARY} )
435
436
ENDIF(XDMF_BUILD_MPI)

437
438
439
440
TARGET_LINK_LIBRARIES(Xdmf 
  ${HDF5_LIBRARY} 
  ${XDMF_MPI_LIBRARIES} 
  ${LIBXML2_LIBRARY} 
Jerry Clarke's avatar
Jerry Clarke committed
441
442
  ${XDMF_ZLIB_LIBRARIES}
  ${XDMF_BZIP2_LIBRARIES})
443

444
OPTION(XDMF_WRAP_PYTHON "Build a Python wrapping interface" OFF)
445
446
447
448
449
450
SET (temp_VTK_PYTHON FALSE)
IF (VTK_WRAP_PYTHON AND NOT PARAVIEW_ENABLE_PYTHON)
  SET (temp_VTK_PYTHON TRUE)
ENDIF (VTK_WRAP_PYTHON AND NOT PARAVIEW_ENABLE_PYTHON)

IF(XDMF_WRAP_PYTHON OR temp_VTK_PYTHON)
451
  FIND_PACKAGE(PythonInterp)
452
  FIND_PACKAGE(PythonLibs)
453
ENDIF(XDMF_WRAP_PYTHON OR temp_VTK_PYTHON)
454
455

IF(XDMF_WRAP_PYTHON)
456
  IF(NOT BUILD_SHARED_LIBS)
457
    MESSAGE("Python wrapping only works on shared libraries")
458
  ENDIF(NOT BUILD_SHARED_LIBS)
459
  INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
460
  ADD_DEFINITIONS(-DSWIG_TYPE_TABLE=Xdmf)
461
462
463
464
465
  IF(XDMF_BUILD_MPI)
    ADD_LIBRARY(_Xdmf MODULE ${XdmfPythonSource})
  ELSE(XDMF_BUILD_MPI)
    ADD_LIBRARY(_Xdmf MODULE ${XdmfPythonSourceNoMpi})
  ENDIF(XDMF_BUILD_MPI)
Jerry Clarke's avatar
Jerry Clarke committed
466
  TARGET_LINK_LIBRARIES(_Xdmf Xdmf ${HDF5_LIBRARY} ${XDMF_ZLIB_LIBRARIES} ${XDMF_BZIP2_LIBRARIES})
467
  IF(WIN32 OR APPLE)
468
    TARGET_LINK_LIBRARIES(_Xdmf ${PYTHON_LIBRARY})
469
  ENDIF(WIN32 OR APPLE)
Kenneth Leiter's avatar
ENH:    
Kenneth Leiter committed
470
471

  # Get the install path for python modules
472
473
474
475
  if(NOT XDMF_WRAP_PYTHON_INSTALL_DIR)
    EXEC_PROGRAM("${PYTHON_EXECUTABLE}" "${Xdmf_SOURCE_DIR}/CMake/"
      ARGS "setup_install_paths.py" "purelib" --prefix=""
      OUTPUT_VARIABLE XDMF_WRAP_PYTHON_INSTALL_DIR)
Kenneth Leiter's avatar
ENH:    
Kenneth Leiter committed
476

477
478
    SET(XDMF_WRAP_PYTHON_INSTALL_DIR ${XDMF_WRAP_PYTHON_INSTALL_DIR}/Xdmf)
  endif()
Kenneth Leiter's avatar
ENH:    
Kenneth Leiter committed
479
480
481
482
483
484
485

  # Replace backslashes with forward slashes
  IF(WIN32)
    STRING(REGEX REPLACE "\\\\" "/" XDMF_WRAP_PYTHON_INSTALL_DIR
      "${XDMF_WRAP_PYTHON_INSTALL_DIR}")
  ENDIF(WIN32)

486
  SET_TARGET_PROPERTIES(_Xdmf PROPERTIES PREFIX "")
487
  ADD_DEPENDENCIES(_Xdmf Xdmf)
Kenneth Leiter's avatar
ENH:    
Kenneth Leiter committed
488
489
490
491
492
493
494
495
496
497
498
499
  
  SET(XDMF_PYTHON_INIT_COMMANDS "from Xdmf import *\n")
  IF(XDMF_BUILD_UTILS)
    SET(XDMF_PYTHON_INIT_COMMANDS "${XDMF_PYTHON_INIT_COMMANDS}from XdmfUtils import *\n")
  ENDIF(XDMF_BUILD_UTILS)

  IF(XDMF_BUILD_VTK)
    IF(VTK_WRAP_PYTHON)
      SET(XDMF_PYTHON_INIT_COMMANDS "${XDMF_PYTHON_INIT_COMMANDS}from libvtkXdmfPython import *\n")
    ENDIF(VTK_WRAP_PYTHON)
  ENDIF(XDMF_BUILD_VTK)

500
  CONFIGURE_FILE(__init__.py ${Xdmf_BINARY_DIR}/libsrc/__init__.py @ONLY)
Kenneth Leiter's avatar
ENH:    
Kenneth Leiter committed
501
502
  CONFIGURE_FILE(${XDMF_PYTHON_FILE} ${CMAKE_BINARY_DIR}/libsrc/Xdmf.py COPYONLY)

503
  INSTALL(FILES ${Xdmf_BINARY_DIR}/libsrc/__init__.py 
Kenneth Leiter's avatar
ENH:    
Kenneth Leiter committed
504
505
506
507
    DESTINATION ${XDMF_WRAP_PYTHON_INSTALL_DIR}
    COMPONENT Runtime)
  INSTALL(FILES ${XDMF_PYTHON_FILE}
      DESTINATION ${XDMF_WRAP_PYTHON_INSTALL_DIR}
508
      COMPONENT Runtime
Kenneth Leiter's avatar
ENH:    
Kenneth Leiter committed
509
      RENAME Xdmf.py) # always named the same regardless of build with or without mpi
510
511
512
513
514

  # Compile Byte Code
  INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${Xdmf_SOURCE_DIR}/CMake/CompileXdmfByteCode.py 
    ${CMAKE_INSTALL_PREFIX}/${XDMF_WRAP_PYTHON_INSTALL_PY_DIR})")
  
515
516
ENDIF(XDMF_WRAP_PYTHON)

Jerry Clarke's avatar
Jerry Clarke committed
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
OPTION(XDMF_WRAP_CSHARP "Build a C# wrapping interface" OFF)
IF(XDMF_WRAP_CSHARP)
  IF(NOT BUILD_SHARED_LIBS)
    MESSAGE("C# wrapping only works on shared libraries")
  ENDIF(NOT BUILD_SHARED_LIBS)

  FIND_PROGRAM(SWIG_EXECUTABLE 
    NAMES swig-1.3 swig
    PATHS /usr/bin
    DOC "Swig executable for generating wrapped files")
  MARK_AS_ADVANCED(SWIG_EXECUTABLE)
  SET(SWIG_WRAPPER_CXX ${Xdmf_BINARY_DIR}/libsrc/XdmfCSharp.cxx)
  IF(SWIG_EXECUTABLE)
    SET(XDMF_SWIG_INCLUDES 
      -I${Xdmf_SOURCE_DIR} 
      -I${Xdmf_SOURCE_DIR}/libsrc 
      -I${Xdmf_BINARY_DIR}/libsrc 
      -I${Xdmf_SOURCE_DIR}/Ice/libsrc
      -I${Xdmf_BINARY_DIR}/Ice/libsrc
      )
    GET_FILENAME_COMPONENT(SWIG_EXE_PATH ${SWIG_EXECUTABLE}
      PATH)
    SET(SWIG_LIB_PATH "${SWIG_EXE_PATH}/Lib")
    IF(EXISTS "${SWIG_LIB_PATH}")
      SET(XDMF_SWIG_INCLUDES
        ${XDMF_SWIG_INCLUDES}
        -I${SWIG_LIB_PATH}
        )
    ENDIF(EXISTS "${SWIG_LIB_PATH}")
	IF(XDMF_BUILD_MPI)
	  ADD_CUSTOM_COMMAND(
	   OUTPUT ${SWIG_WRAPPER_CXX}
	   DEPENDS ${Xdmf_SOURCE_DIR}/libsrc/Xdmf.i
	   COMMAND ${SWIG_EXECUTABLE}
	   ARGS -module XdmfCSharp -namespace Xdmf  -v -c++ -make_default -includeall "-csharp" ${swig_extra_args} ${XDMF_SWIG_INCLUDES} -o "${SWIG_WRAPPER_CXX}"  Xdmf.i)
	ELSE(XDMF_BUILD_MPI) 
	  ADD_CUSTOM_COMMAND(
	   OUTPUT ${SWIG_WRAPPER_CXX}
	   DEPENDS ${Xdmf_SOURCE_DIR}/libsrc/Xdmf.i
	   COMMAND ${SWIG_EXECUTABLE}
	   ARGS -module XdmfCSharp -namespace Xdmf   -v -c++ -DXDMF_NO_MPI -make_default -includeall "-csharp" ${swig_extra_args} ${XDMF_SWIG_INCLUDES} -o "${SWIG_WRAPPER_CXX}" Xdmf.i)
	ENDIF(XDMF_BUILD_MPI) 
	
    ADD_CUSTOM_TARGET(RerunSwigCSharp DEPENDS 
      ${SWIG_WRAPPER_CXX}
      )

  ELSE(SWIG_EXECUTABLE)
    MESSAGE("Wrappers generation is disabled, because SWIG executable is not found")
  ENDIF(SWIG_EXECUTABLE)

  ADD_LIBRARY(XdmfCSharp SHARED ${SWIG_WRAPPER_CXX})
Jerry Clarke's avatar
Jerry Clarke committed
569
  TARGET_LINK_LIBRARIES(XdmfCSharp Xdmf XdmfUtils ${HDF5_LIBRARY} ${XDMF_ZLIB_LIBRARIES})
Jerry Clarke's avatar
Jerry Clarke committed
570
  ADD_CUSTOM_COMMAND (TARGET XdmfCSharp
571
572
573
		      POST_BUILD
		      COMMAND csc -target:library -out:../bin/XmdfCSharpBindings.dll ${CSHARP_SOURCES}
		      WORKING_DIRECTORY ${XDMF_INSTALL_DIR})
Jerry Clarke's avatar
Jerry Clarke committed
574
  ADD_DEPENDENCIES(XdmfCSharp Xdmf XdmfUtils )
Jerry Clarke's avatar
Jerry Clarke committed
575
576
ENDIF(XDMF_WRAP_CSHARP)

577
IF(NOT XDMF_INSTALL_NO_DEVELOPMENT)
Burlen Loring's avatar
   
Burlen Loring committed
578
579
580
  FILE(GLOB devFiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
  INSTALL(
      FILES ${devFiles}
581
582
      DESTINATION ${XDMF_INSTALL_INCLUDE_DIR_CM24}
	  COMPONENT Development)
Jerry Clarke's avatar
Jerry Clarke committed
583
584
  INSTALL(
      FILES ${Xdmf_BINARY_DIR}/libsrc/XdmfConfig.h
585
586
      DESTINATION ${XDMF_INSTALL_INCLUDE_DIR_CM24}
	  COMPONENT Development)
587
ENDIF(NOT XDMF_INSTALL_NO_DEVELOPMENT)
Andy Cedilnik's avatar
Andy Cedilnik committed
588

589
IF(NOT XDMF_INSTALL_NO_LIBRARIES)
590
  INSTALL(TARGETS Xdmf
591
    EXPORT ${XDMF_INSTALL_EXPORT_NAME}
Burlen Loring's avatar
   
Burlen Loring committed
592
    RUNTIME DESTINATION ${XDMF_INSTALL_BIN_DIR_CM24} COMPONENT Runtime
593
594
    LIBRARY DESTINATION ${XDMF_INSTALL_LIB_DIR_CM24} COMPONENT Runtime
    ARCHIVE DESTINATION ${XDMF_INSTALL_LIB_DIR_CM24} COMPONENT Development)
Andy Cedilnik's avatar
Andy Cedilnik committed
595
  IF(XDMF_WRAP_PYTHON)
596
    INSTALL(TARGETS _Xdmf
597
        EXPORT ${XDMF_INSTALL_EXPORT_NAME}
598
599
        RUNTIME DESTINATION ${XDMF_WRAP_PYTHON_INSTALL_DIR} COMPONENT Runtime
        LIBRARY DESTINATION ${XDMF_WRAP_PYTHON_INSTALL_DIR} COMPONENT Runtime)
Andy Cedilnik's avatar
Andy Cedilnik committed
600
  ENDIF(XDMF_WRAP_PYTHON)
601
ENDIF(NOT XDMF_INSTALL_NO_LIBRARIES)
602

603
604
605
606
607
OPTION(XDMF_BUILD_UTILS "Build Xdmf Utilities" OFF)
IF(XDMF_BUILD_UTILS)
   ADD_SUBDIRECTORY(utils)
ENDIF(XDMF_BUILD_UTILS)

608
609
610
IF(BUILD_TESTING)
  ADD_SUBDIRECTORY(test)
ENDIF(BUILD_TESTING)