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

Brian Panneton's avatar
Brian Panneton committed
4
5
include(SetUpVersion)
if(VERSION_CONTROL_AUTOUPDATE)
6
        VersionCreate("Xdmf" "2" "XDMFCORE_EXPORT" "XdmfCore.hpp")
Brian Panneton's avatar
Brian Panneton committed
7
8
endif(VERSION_CONTROL_AUTOUPDATE)

9
10
set(BUILD_SHARED_LIBS true)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
11
12
13
14
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)
15

16
17
option(XDMF_BUILD_DSM OFF)

18
19
20
find_package(Boost REQUIRED)
if(Boost_FOUND)
	include_directories(${Boost_INCLUDE_DIRS})
21
22
23
    set(XDMF_BOOST_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
    get_filename_component(Boost_ROOT "${Boost_INCLUDE_DIRS}" REALPATH)
    set(XDMF_BOOST_ROOT_DIR ${Boost_ROOT})
24
25
26
27
endif(Boost_FOUND)

find_package(HDF5 REQUIRED)
if(HDF5_FOUND)
28
29
30
31
32
33
34
	include_directories(${HDF5_INCLUDE_DIR})
	if(HDF5_IS_PARALLEL)
		find_package(MPI REQUIRED)
		if(MPI_FOUND)
			include_directories(${MPI_INCLUDE_PATH})
		endif(MPI_FOUND)
	endif(HDF5_IS_PARALLEL)
35
    get_filename_component(HDF5_ROOT "${HDF5_INCLUDE_DIR}/../" REALPATH)
36
    set(HDF5_BINARY_DIRS ${HDF5_ROOT}/bin ${HDF5_ROOT}/dll)
37
38
39
    set(XDMF_HDF5_ROOT_DIR ${HDF5_ROOT})
    set(XDMF_HDF5_INCLUDE_DIR ${HDF5_INCLUDE_DIR})
    set(XDMF_HDF5_LIBRARIES ${HDF5_LIBRARIES})
40
    set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${HDF5_LIBRARIES})
41
    set(XDMF_HDF5_BINARY_DIRS ${HDF5_BINARY_DIRS})
42
    set(XDMF_BINARIES ${XDMF_BINARIES} ${HDF5_BINARY_DIRS})
43
44
endif(HDF5_FOUND)

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
if(XDMF_BUILD_DSM)
	find_path(HDF5DSM_DIR include/H5FDdsm.h)
	if(HDF5DSM_DIR AND EXISTS ${HDF5DSM_DIR}/include/H5FDdsm.h)
	  include_directories(${HDF5DSM_DIR}/include)
	  find_library(HDF5DSM_LIBRARIES H5FDdsm ${HDF5DSM_DIR}/lib)
	else(HDF5DSM_DIR AND EXISTS ${HDF5DSM_DIR}/include/H5FDdsm.h)
	  message(SEND_ERROR "Cannot find HDF5DSM!  Please set HDF5DSM_DIR and configure again.")
	endif(HDF5DSM_DIR AND EXISTS ${HDF5DSM_DIR}/include/H5FDdsm.h)
	
	find_package(MPI REQUIRED)
	if(MPI_FOUND)
		include_directories(${MPI_INCLUDE_PATH})
	endif(MPI_FOUND)
endif(XDMF_BUILD_DSM)

60
61
62
find_package(LibXml2 REQUIRED)
if(LIBXML2_FOUND)
	include_directories(${LIBXML2_INCLUDE_DIR})
63
    get_filename_component(LIBXML2_ROOT "${LIBXML2_INCLUDE_DIR}/../" REALPATH)
64
    set(LIBXML2_BINARY_DIRS ${LIBXML2_ROOT}/bin)
65
66
67
    set(XDMF_LIBXML2_ROOT_DIR ${LIBXML2_ROOT})
    set(XDMF_LIBXML2_INCLUDE_DIR ${LIBXML2_INCLUDE_DIR})
    set(XDMF_LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES})
68
    set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${LIBXML2_LIBRARIES})
69
    set(XDMF_LIBXML2_BINARY_DIRS ${LIBXML2_BINARY_DIRS})
70
    set(XDMF_BINARIES ${XDMF_BINARIES} ${LIBXML2_BINARY_DIRS})
71
72
73
74
75
76
77
78
79
endif(LIBXML2_FOUND)

set(XdmfCoreSources
	XdmfArray
	XdmfArrayType
	XdmfCoreItemFactory
	XdmfCoreReader
	XdmfHDF5Controller
	XdmfHDF5Writer
80
81
	XdmfHeavyDataController
	XdmfHeavyDataWriter
82
	XdmfInformation
83
84
	XdmfItem
	XdmfItemProperty
85
	XdmfSystemUtils
86
    XdmfVersion
87
	XdmfVisitor
88
	XdmfWriter
89
90
)

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

98
add_library(XdmfCore ${XdmfCoreSources})
99
target_link_libraries(XdmfCore ${HDF5_LIBRARIES} ${HDF5DSM_LIBRARIES} ${LIBXML2_LIBRARIES})
100

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

111
if(XDMF_WRAP_JAVA)
112
	XDMF_SWIG_JAVA(XdmfCore)
113
114
endif(XDMF_WRAP_JAVA)

115
if(XDMF_WRAP_PYTHON)
116
	XDMF_SWIG_PYTHON(XdmfCore)
117
118
endif(XDMF_WRAP_PYTHON)

119
if(WIN32)
120
    set(XDMFCORE_LIBRARY_CONFIG ${CMAKE_INSTALL_PREFIX}/lib/XdmfCore.lib)
121
122
123
124
else(WIN32)
    set(XDMFCORE_LIBRARY_CONFIG ${CMAKE_INSTALL_PREFIX}/lib/libXdmfCore.so)
endif(WIN32)

125
file(GLOB_RECURSE XdmfCoreHeaders "*.hpp" "*.tpp" "*.i" "../CMake/VersionSuite/*.hpp")
126
file(GLOB LokiHeaders loki/*.h)
127
install(FILES ${XdmfCoreHeaders} DESTINATION include)
128
install(FILES ${LokiHeaders} DESTINATION include/loki)
129
130
131
132
133
install(TARGETS XdmfCore 
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
)
134

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

137
if(BUILD_TESTING)
138
	add_subdirectory(tests)
139
endif(BUILD_TESTING)
140
141
142

# Since these are not set as of yet, we don't want to remove them from the
# config file
143
144
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${CMAKE_INSTALL_PREFIX}/lib)
set(XDMF_BINARIES ${XDMF_BINARIES} ${CMAKE_INSTALL_PREFIX}/bin)
145
146
147
set(XDMF_LIBRARY_CONFIG "@XDMF_LIBRARY_CONFIG@")
set(XDMF_JAVA_JAR_CONFIG "@XDMF_JAVA_JAR_CONFIG@")
set(XDMF_PYTHON_CONFIG "@XDMF_PYTHON_CONFIG@")