CMakeLists.txt 5.88 KB
Newer Older
1
2
project(XdmfCore)
cmake_minimum_required(VERSION 2.6)
3
4
5
if (POLICY CMP0015)
  cmake_policy(SET CMP0015 NEW)
endif (POLICY CMP0015)
6

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

14
15
set(BUILD_SHARED_LIBS true)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
16
17
18
19
20
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)
21

22
23
option(XDMF_BUILD_DSM OFF)

24
mark_as_advanced(CLEAR Boost_INCLUDE_DIR)
25
26
find_package(Boost REQUIRED)
if(Boost_FOUND)
27
28
  include_directories(${Boost_INCLUDE_DIRS})
  mark_as_advanced(FORCE Boost_INCLUDE_DIR)
29
30
endif(Boost_FOUND)

31
32
33
mark_as_advanced(CLEAR HDF5_C_INCLUDE_DIR)
mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_DEBUG)
mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_RELEASE)
34
35
find_package(HDF5 REQUIRED)
if(HDF5_FOUND)
36
37
38
  mark_as_advanced(FORCE HDF5_C_INCLUDE_DIR)
  mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_DEBUG)
  mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_RELEASE)
39
  include_directories(${HDF5_INCLUDE_DIRS})
40
  include_directories(${HDF5_C_INCLUDE_DIR})
41
42
  get_filename_component(HDF5_LIBRARY_DIR "${HDF5_hdf5_LIBRARY_RELEASE}" PATH)
  set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${HDF5_LIBRARY_DIR})
43
  set(HDF5_LIBRARIES ${HDF5_hdf5_LIBRARY_RELEASE})
44
45
  # FIXME: Would like to get this info from HDF5 so we don't have conflicting
  # MPI versions
46
47
48
49
  if(HDF5_IS_PARALLEL)
    find_package(MPI REQUIRED)
    if(MPI_FOUND)
      include_directories(${MPI_INCLUDE_PATH})
50
      set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY})
51
52
      get_filename_component(MPI_LIBRARY_DIR ${MPI_LIBRARY} PATH)
      set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${MPI_LIBRARY_DIR})
53
54
55
56
    endif(MPI_FOUND)
  endif(HDF5_IS_PARALLEL)
  get_filename_component(HDF5_ROOT "${HDF5_INCLUDE_DIR}/../" REALPATH)
  set(HDF5_BINARY_DIRS ${HDF5_ROOT}/bin ${HDF5_ROOT}/dll)
57
  set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${HDF5_LIBRARIES})
58
59
  set(XDMF_HDF5_BINARY_DIRS ${HDF5_BINARY_DIRS} PARENT_SCOPE)
  set(XDMF_BINARIES ${XDMF_BINARIES} ${HDF5_BINARY_DIRS})
60
61
62
63
endif(HDF5_FOUND)

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
option(XDMF_BUILD_DSM OFF)
91
if(XDMF_BUILD_DSM)
92
93
94
95
  set(XdmfCoreSources
    ${XdmfCoreSources}
    XdmfHDF5ControllerDSM
    XdmfHDF5WriterDSM)
96
97
98

  find_package(H5FDdsm REQUIRED NO_MODULE)
  if(H5FDdsm_FOUND)
99
100
101
102
    include_directories(${H5FDdsm_INCLUDE_DIR})
    get_filename_component(H5FDdsm_LIBRARY_DIR 
                           "${H5FDdsm_INCLUDE_DIR}/../lib" REALPATH)
    set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${H5FDdsm_LIBRARY_DIR})
103
    get_property(h5fddsm_lib_location TARGET H5FDdsm PROPERTY LOCATION)
104
105
    set(H5FDdsm_LIBRARIES ${h5fddsm_lib_location})
    set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${H5FDdsm_LIBRARIES})
106
107
108
109
  else(H5FDdsm_FOUND)
    message(SEND_ERROR
      "Cannot find HDF5 DSM!  Please set H5FDdsm_DIR and configure again.")
  endif(H5FDdsm_FOUND)
110
111
endif(XDMF_BUILD_DSM)

112
add_library(XdmfCore ${XdmfCoreSources})
113
114
link_directories(${XDMF_LIBRARY_DIRS})
target_link_libraries(XdmfCore ${XDMF_LIBRARIES})
115

116
if(WIN32)
117
  add_definitions(-D_HDF5USEDLL_ -D_HDF5USEHLDLL_)
118
  set_target_properties(XdmfCore PROPERTIES 
119
120
121
122
123
124
125
126
127
      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)
128
129
endif(WIN32)

130
if(XDMF_WRAP_JAVA)
131
  XDMF_SWIG_JAVA(XdmfCore)
132
133
endif(XDMF_WRAP_JAVA)

134
if(XDMF_WRAP_PYTHON)
135
  XDMF_SWIG_PYTHON(XdmfCore)
136
137
endif(XDMF_WRAP_PYTHON)

138
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} PARENT_SCOPE)
139
if(WIN32)
140
    set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/XdmfCore.lib PARENT_SCOPE)
141
142
143
endif(WIN32)

if(UNIX)
144
145
    set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfCore.so
        PARENT_SCOPE)
146
147
148
149
150
151
endif(UNIX)

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

153
154
155
156
file(GLOB_RECURSE
  XdmfCoreHeaders
  "*.hpp" "*.tpp" "*.i"
  "../CMake/VersionSuite/*.hpp")
157
file(GLOB LokiHeaders loki/*.h)
158
install(FILES ${XdmfCoreHeaders} DESTINATION include)
159
install(FILES ${LokiHeaders} DESTINATION include/loki)
160
161
162
163
164
install(TARGETS XdmfCore
  RUNTIME DESTINATION bin
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib)

165
if(XDMF_BUILD_DSM)
166
167
168
169
set(XdmfCore_INCLUDE_DIRS
  ${Boost_INCLUDE_DIRS}
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${HDF5_INCLUDE_DIR}
170
  ${H5FDdsm_INCLUDE_DIR}
171
172
173
  ${LIBXML2_INCLUDE_DIR}
  ${PYTHON_INCLUDE_DIRS}
  CACHE INTERNAL "")
174
175
176
177
178
179
180
181
182
else(XDMF_BUILD_DSM)
set(XdmfCore_INCLUDE_DIRS
  ${Boost_INCLUDE_DIRS}
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${HDF5_INCLUDE_DIR}
  ${LIBXML2_INCLUDE_DIR}
  ${PYTHON_INCLUDE_DIRS}
  CACHE INTERNAL "")
endif(XDMF_BUILD_DSM)
183

184
185
186
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${CMAKE_INSTALL_PREFIX}/lib)
set(XDMF_BINARIES ${XDMF_BINARIES} ${CMAKE_INSTALL_PREFIX}/bin)

187
if(BUILD_TESTING)
188
  add_subdirectory(tests)
189
endif(BUILD_TESTING)
190

191
192
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} PARENT_SCOPE)
set(XDMF_BINARIES ${XDMF_BINARIES} PARENT_SCOPE)
193