CMakeLists.txt 5.49 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 20
option(XDMF_BUILD_DSM OFF)

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

28 29 30
mark_as_advanced(CLEAR HDF5_C_INCLUDE_DIR)
mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_DEBUG)
mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_RELEASE)
31 32
find_package(HDF5 REQUIRED)
if(HDF5_FOUND)
33 34 35
  mark_as_advanced(FORCE HDF5_C_INCLUDE_DIR)
  mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_DEBUG)
  mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_RELEASE)
36
  include_directories(${HDF5_INCLUDE_DIRS})
37
  include_directories(${HDF5_C_INCLUDE_DIR})
38 39
  get_filename_component(HDF5_LIBRARY_DIR "${HDF5_hdf5_LIBRARY_RELEASE}" PATH)
  set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${HDF5_LIBRARY_DIR})
40
  set(HDF5_LIBRARIES ${HDF5_hdf5_LIBRARY_RELEASE})
41 42
  # FIXME: Would like to get this info from HDF5 so we don't have conflicting
  # MPI versions
43 44 45 46
  if(HDF5_IS_PARALLEL)
    find_package(MPI REQUIRED)
    if(MPI_FOUND)
      include_directories(${MPI_INCLUDE_PATH})
47 48
      get_filename_component(MPI_LIBRARY_DIR ${MPI_LIBRARY} PATH)
      set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${MPI_LIBRARY_DIR})
49 50 51 52
    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)
53
  set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${HDF5_LIBRARIES})
54 55
  set(XDMF_HDF5_BINARY_DIRS ${HDF5_BINARY_DIRS} PARENT_SCOPE)
  set(XDMF_BINARIES ${XDMF_BINARIES} ${HDF5_BINARY_DIRS})
56 57 58 59
endif(HDF5_FOUND)

find_package(LibXml2 REQUIRED)
if(LIBXML2_FOUND)
60
  include_directories(${LIBXML2_INCLUDE_DIR})
61 62 63 64 65
  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})
66 67 68
endif(LIBXML2_FOUND)

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

86
option(XDMF_BUILD_DSM OFF)
87
if(XDMF_BUILD_DSM)
88 89 90 91
  set(XdmfCoreSources
    ${XdmfCoreSources}
    XdmfHDF5ControllerDSM
    XdmfHDF5WriterDSM)
92 93 94 95 96 97 98 99 100 101 102 103 104 105

  find_package(H5FDdsm REQUIRED NO_MODULE)
  if(H5FDdsm_FOUND)
    include_directories(${H5FD_DSM_INCLUDE_DIR})
    get_filename_component(H5FD_DSM_LIBRARY_DIR 
                           "${H5FD_DSM_INCLUDE_DIR}/../lib" REALPATH)
    set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${H5FD_DSM_LIBRARY_DIR})
    get_property(h5fddsm_lib_location TARGET H5FDdsm PROPERTY LOCATION)
    set(H5FD_DSM_LIBRARIES ${h5fddsm_lib_location})
    set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${H5FD_DSM_LIBRARIES})
  else(H5FDdsm_FOUND)
    message(SEND_ERROR
      "Cannot find HDF5 DSM!  Please set H5FDdsm_DIR and configure again.")
  endif(H5FDdsm_FOUND)
106 107
endif(XDMF_BUILD_DSM)

108
add_library(XdmfCore ${XdmfCoreSources})
109 110
link_directories(${XDMF_LIBRARY_DIRS})
target_link_libraries(XdmfCore ${XDMF_LIBRARIES})
111

112
if(WIN32)
113
  add_definitions(-D_HDF5USEDLL_ -D_HDF5USEHLDLL_)
114
  set_target_properties(XdmfCore PROPERTIES 
115 116 117 118 119 120 121 122 123
      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)
124 125
endif(WIN32)

126
if(XDMF_WRAP_JAVA)
127
  XDMF_SWIG_JAVA(XdmfCore)
128 129
endif(XDMF_WRAP_JAVA)

130
if(XDMF_WRAP_PYTHON)
131
  XDMF_SWIG_PYTHON(XdmfCore)
132 133
endif(XDMF_WRAP_PYTHON)

134
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} PARENT_SCOPE)
135
if(WIN32)
136
    set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/XdmfCore.lib PARENT_SCOPE)
137 138 139
endif(WIN32)

if(UNIX)
140 141
    set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfCore.so
        PARENT_SCOPE)
142 143 144 145 146 147
endif(UNIX)

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

149 150 151 152
file(GLOB_RECURSE
  XdmfCoreHeaders
  "*.hpp" "*.tpp" "*.i"
  "../CMake/VersionSuite/*.hpp")
153
file(GLOB LokiHeaders loki/*.h)
154
install(FILES ${XdmfCoreHeaders} DESTINATION include)
155
install(FILES ${LokiHeaders} DESTINATION include/loki)
156 157 158 159 160 161 162 163 164 165 166 167
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 "")
168

169 170 171
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${CMAKE_INSTALL_PREFIX}/lib)
set(XDMF_BINARIES ${XDMF_BINARIES} ${CMAKE_INSTALL_PREFIX}/bin)

172
if(BUILD_TESTING)
173
  add_subdirectory(tests)
174
endif(BUILD_TESTING)
175

176 177
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} PARENT_SCOPE)
set(XDMF_BINARIES ${XDMF_BINARIES} PARENT_SCOPE)
178