CMakeLists.txt 4.78 KB
Newer Older
1
2
3
project(XdmfCore)
cmake_minimum_required(VERSION 2.6)

Brian Panneton's avatar
Brian Panneton committed
4
include(SetUpVersion)
5
6
if(VERSION_CONTROL_AUTOUPDATE OR 
    NOT EXISTS ${CMAKE_BINARY_DIR}/XdmfVersion.hpp)
7
  VersionCreate("Xdmf" "2" "XDMFCORE_EXPORT" "XdmfCore.hpp")
8
9
endif(VERSION_CONTROL_AUTOUPDATE OR 
    NOT EXISTS ${CMAKE_BINARY_DIR}/XdmfVersion.hpp)
Brian Panneton's avatar
Brian Panneton committed
10

11
12
set(BUILD_SHARED_LIBS true)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
13
14
15
16
17
include_directories(${CMAKE_BINARY_DIR})
set(CMAKE_SKIP_BUILD_RPATH  FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
18

19
mark_as_advanced(CLEAR Boost_INCLUDE_DIR)
20
21
find_package(Boost REQUIRED)
if(Boost_FOUND)
22
23
  include_directories(${Boost_INCLUDE_DIRS})
  mark_as_advanced(FORCE Boost_INCLUDE_DIR)
24
25
endif(Boost_FOUND)

26
27
28
mark_as_advanced(CLEAR HDF5_C_INCLUDE_DIR)
mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_DEBUG)
mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_RELEASE)
29
30
find_package(HDF5 REQUIRED)
if(HDF5_FOUND)
31
32
33
  mark_as_advanced(FORCE HDF5_C_INCLUDE_DIR)
  mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_DEBUG)
  mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_RELEASE)
34
35
36
  include_directories(${HDF5_INCLUDE_DIR})
#  set(HDF5_LIBRARIES hdf5)
  option(HDF5_IS_PARALLEL "Whether or not HDF5 has parallel IO support." OFF)
37
38
39
40
41
  if(HDF5_IS_PARALLEL)
    find_package(MPI REQUIRED)
    if(MPI_FOUND)
      include_directories(${MPI_INCLUDE_PATH})
    endif(MPI_FOUND)
42
43
44
45
46
47
48
49
50
51
52
    option(XDMF_BUILD_DSM OFF)
    if(XDMF_BUILD_DSM)
      find_package(H5FDdsm REQUIRED NO_MODULE)
      if(H5FDdsm_FOUND)
        include_directories(${H5FD_DSM_INCLUDE_DIR})
        set(H5FD_DSM_LIBRARIES H5FDdsm)
      else(H5FDdsm_FOUND)
        message(SEND_ERROR
          "Cannot find HDF5 DSM!  Please set H5FDdsm_DIR and configure again.")
      endif(H5FDdsm_FOUND)
    endif(XDMF_BUILD_DSM)
53
54
55
  endif(HDF5_IS_PARALLEL)
  get_filename_component(HDF5_ROOT "${HDF5_INCLUDE_DIR}/../" REALPATH)
  set(HDF5_BINARY_DIRS ${HDF5_ROOT}/bin ${HDF5_ROOT}/dll)
56
  set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${HDF5_LIBRARIES} ${H5FD_DSM_LIBRARIES})
57
58
  set(XDMF_HDF5_BINARY_DIRS ${HDF5_BINARY_DIRS} PARENT_SCOPE)
  set(XDMF_BINARIES ${XDMF_BINARIES} ${HDF5_BINARY_DIRS})
59
60
endif(HDF5_FOUND)

61

62
63
find_package(LibXml2 REQUIRED)
if(LIBXML2_FOUND)
64
  include_directories(${LIBXML2_INCLUDE_DIR})
65
66
67
68
69
  get_filename_component(LIBXML2_ROOT "${LIBXML2_INCLUDE_DIR}/../" REALPATH)
  set(LIBXML2_BINARY_DIRS ${LIBXML2_ROOT}/bin)
  set(LIBXML2_BINARY_DIRS ${LIBXML2_BINARY_DIRS} PARENT_SCOPE)
  set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${LIBXML2_LIBRARIES})
  set(XDMF_BINARIES ${XDMF_BINARIES} ${LIBXML2_BINARY_DIRS})
70
71
72
endif(LIBXML2_FOUND)

set(XdmfCoreSources
73
74
75
76
  XdmfArray
  XdmfArrayType
  XdmfCoreItemFactory
  XdmfCoreReader
77
  XdmfError
78
79
80
81
82
83
84
85
86
87
88
  XdmfHDF5Controller
  XdmfHDF5Writer
  XdmfHeavyDataController
  XdmfHeavyDataWriter
  XdmfInformation
  XdmfItem
  XdmfItemProperty
  XdmfSystemUtils
  ${CMAKE_BINARY_DIR}/XdmfVersion
  XdmfVisitor
  XdmfWriter)
89

90
if(XDMF_BUILD_DSM)
91
92
93
94
  set(XdmfCoreSources
    ${XdmfCoreSources}
    XdmfHDF5ControllerDSM
    XdmfHDF5WriterDSM)
95
96
endif(XDMF_BUILD_DSM)

97
add_library(XdmfCore ${XdmfCoreSources})
98
target_link_libraries(XdmfCore
99
  ${XDMF_LIBRARIES})
100

101
if(WIN32)
102
  add_definitions(-D_HDF5USEDLL_ -D_HDF5USEHLDLL_)
103
  set_target_properties(XdmfCore PROPERTIES 
104
105
106
107
108
109
110
111
112
      DEFINE_SYMBOL XdmfCore_EXPORTS)
  if(NOT MSVC10)
	set_target_properties(XdmfCore PROPERTIES
      PREFIX ../
      IMPORT_PREFIX ../
      RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
      LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
      ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
  endif(NOT MSVC10)
113
114
endif(WIN32)

115
if(XDMF_WRAP_JAVA)
116
  XDMF_SWIG_JAVA(XdmfCore)
117
118
endif(XDMF_WRAP_JAVA)

119
if(XDMF_WRAP_PYTHON)
120
  XDMF_SWIG_PYTHON(XdmfCore)
121
122
endif(XDMF_WRAP_PYTHON)

123
if(WIN32)
124
    set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/XdmfCore.lib PARENT_SCOPE)
125
126
127
endif(WIN32)

if(UNIX)
128
129
    set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfCore.so
        PARENT_SCOPE)
130
131
132
133
134
135
endif(UNIX)

if(APPLE)
    set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfCore.dylib
        PARENT_SCOPE)
endif(APPLE)
136

137
138
139
140
file(GLOB_RECURSE
  XdmfCoreHeaders
  "*.hpp" "*.tpp" "*.i"
  "../CMake/VersionSuite/*.hpp")
141
file(GLOB LokiHeaders loki/*.h)
142
install(FILES ${XdmfCoreHeaders} DESTINATION include)
143
install(FILES ${LokiHeaders} DESTINATION include/loki)
144
145
146
147
148
149
150
151
152
153
154
155
install(TARGETS XdmfCore
  RUNTIME DESTINATION bin
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib)

set(XdmfCore_INCLUDE_DIRS
  ${Boost_INCLUDE_DIRS}
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${HDF5_INCLUDE_DIR}
  ${LIBXML2_INCLUDE_DIR}
  ${PYTHON_INCLUDE_DIRS}
  CACHE INTERNAL "")
156

157
158
159
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${CMAKE_INSTALL_PREFIX}/lib)
set(XDMF_BINARIES ${XDMF_BINARIES} ${CMAKE_INSTALL_PREFIX}/bin)

160
if(BUILD_TESTING)
161
  add_subdirectory(tests)
162
endif(BUILD_TESTING)
163

164
165
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} PARENT_SCOPE)
set(XDMF_BINARIES ${XDMF_BINARIES} PARENT_SCOPE)
166