CMakeLists.txt 8.02 KB
Newer Older
Radu Popescu's avatar
Radu Popescu committed
1
2
3
4
5
# CMake options
include (CheckIncludeFiles)
cmake_minimum_required (VERSION 2.6)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

6
7
8
9
10
11
12
13
# Default compilers
set (CMAKE_C_COMPILER "mpicc" CACHE STRING "Default C compiler")
set (CMAKE_CXX_COMPILER "mpicxx" CACHE STRING "Default C++ compiler")

# Default build type
set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Default build type")

# Default value for TPL flags
Radu Popescu's avatar
Radu Popescu committed
14
15
16
17
18
19
20
21
set (LIFE_USE_HDF5 FALSE CACHE BOOL "By default, don't use HDF5")
set (LIFE_USE_QHULL FALSE CACHE BOOL "By default, don't use QHULL")
set (LIFE_USE_SuperLU FALSE CACHE BOOL "By default, don't use SuperLU")
set (LIFE_USE_SuperLUMT FALSE CACHE BOOL "By default, don't use SuperLUMT")
set (LIFE_USE_SuperLUDist FALSE CACHE BOOL "By default, don't use SuperLUDist")
set (LIFE_USE_UMFPACK FALSE CACHE BOOL "By default, don't use UMFPACK")
set (LIFE_USE_MPI_WRAPPER TRUE CACHE BOOL "By default, use the MPI wrappers")
set (LIFE_USE_SPIRIT_PARSER TRUE CACHE BOOL "By default, use the Boost Spirit parser")
22
23

# Put some other variables in the cache so they can be set with ccmake
Radu Popescu's avatar
Radu Popescu committed
24
25
26
27
28
29
30
31
set (PARMETIS_ROOT "PARMETIS_ROOT-NOTFOUND" CACHE PATH "Location of ParMETIS")
set (UMFPACK_ROOT "UMFPACK_ROOT-NOTFOUND" CACHE PATH "Location of UMFPACK")
set (HDF5_ROOT "HDF5_ROOT-NOTFOUND" CACHE PATH "Location of HDF5")
set (QHULL_ROOT "QHULL_ROOT-NOTFOUND" CACHE PATH "Location of QHULL")
set (SuperLU_ROOT "SuperLU_ROOT-NOTFOUND" CACHE PATH "Location of SuperLU")
set (SuperLUMT_ROOT "SuperLUMT_ROOT-NOTFOUND" CACHE PATH "Location of SuperLUMT")
set (SuperLUDist_ROOT "SuperLUDist_ROOT-NOTFOUND" CACHE PATH "Location of SuperLUDist")
set (BOOST_ROOT "BOOST_ROOT-NOTFOUND" CACHE PATH "Location of Boost")
32
set (Trilinos_ROOT "Trilinos_ROOT-NOTFOUND" CACHE PATH "Location of Trilinos")
33
34
set (BLAS_LIBRARIES "BLAS_LIBRARIES-NOTFOUND" CACHE STRING "BLAS libraries")
set (LAPACK_LIBRARIES "LAPACK_LIBRARIES-NOTFOUND" CACHE STRING "LAPACK libraries")
35

Radu Popescu's avatar
Radu Popescu committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Project options
project (LifeV)
set (PROJECT_SHORT_NAME "lifev")
set (LifeV_VERSION_MAJOR 2)
set (LifeV_VERSION_MINOR 0)
set (LifeV_VERSION_PATCH 0)
set (PROJECT_BUGREPORT "lifev-user@googlegroups.com")
set (PROJECT_HOMEPAGE "www.lifev.org")

# Languages
enable_language (C CXX Fortran)

# Here we add CXXFLAGS, LDFLAGS that are set by the user
# It's a peculiar hack: needed to reset the CMAKE_LANG_FLAGS
# variables in order to place user specified flags at the end
# (this is useful for overriding an optimization level and
# possibly other things)
set (CMAKE_C_FLAGS_SAVED ${CMAKE_C_FLAGS})
set (CMAKE_C_FLAGS "")
set (CMAKE_CXX_FLAGS_SAVED ${CMAKE_CXX_FLAGS})
set (CMAKE_CXX_FLAGS "")

set (CMAKE_C_FLAGS_DEBUG "-Wall -g")
set (CMAKE_C_FLAGS_RELEASE "-O2")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS_SAVED}")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS_SAVED}")
set (CMAKE_CXX_FLAGS_DEBUG "-Wall -g")
set (CMAKE_CXX_FLAGS_RELEASE "-O2")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_SAVED}")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_SAVED}")

add_definitions (-DTHREEDIM)

# Dependencies

# The list of dependencies will end up being quite long, as it will contain all
# the dependencies of LifeV. Current list:
#   * MPI (v)
#   * Trilinos (v)
#   * ParMETIS (v)
#   * UMFPACK (should be optional) (v)
#   * HDF5 (should be optional) (v)
#   * BLAS, LAPACK (v)
#   * Boost (v)
#   * Qhull (should be optional) (v)

# MPI
if (NOT LIFE_USE_MPI_WRAPPER)
    find_package (MPI REQUIRED)
    if (MPI_FOUND)
        include_directories (${MPI_CXX_INCLUDE_PATH})
        set (LIBS ${LIBS} ${MPI_CXX_LIBRARIES})
    endif()
endif()

# Trilinos
92
find_package (Trilinos REQUIRED)
Radu Popescu's avatar
Radu Popescu committed
93
94
95
96
97
98
if (Trilinos_FOUND)
    include_directories (${Trilinos_INCLUDE_DIR})
    set (LIBS ${LIBS} ${Trilinos_LIBRARIES})
endif()

# ParMETIS
99
if( NOT PARMETIS_IS_IN_TRILINOS)
Radu Popescu's avatar
Radu Popescu committed
100
101
102
103
104
find_package (PARMETIS REQUIRED)
if (PARMETIS_FOUND)
    include_directories (${PARMETIS_INCLUDE_DIR})
    set (LIBS ${LIBS} ${PARMETIS_LIBRARIES})
endif()
105
endif()
Radu Popescu's avatar
Radu Popescu committed
106
107

# UMFPACK (optional)
108
if( NOT UMFPACK_IS_IN_TRILINOS)
Radu Popescu's avatar
Radu Popescu committed
109
110
111
112
113
114
115
116
117
118
if (LIFE_USE_UMFPACK)
    find_package (UMFPACK)
    if (UMFPACK_FOUND)
        set (HAVE_UMFPACK TRUE)
        set (HAVE_UMFPACK_H TRUE)
        set (HAVE_AMD_H TRUE)
        include_directories (${UMFPACK_INCLUDE_DIR})
        set (LIBS ${LIBS} ${UMFPACK_LIBRARIES})
    endif()
endif(LIFE_USE_UMFPACK)
119
endif()
Radu Popescu's avatar
Radu Popescu committed
120

121
# SuperLU (optional)
122
if( NOT SUPERLU_IS_IN_TRILINOS)
123
124
125
126
127
128
129
130
if (LIFE_USE_SuperLU)
    find_package (SuperLU)
    if (SuperLU_FOUND)
        set (HAVE_SuperLU TRUE)
        include_directories (${SuperLU_INCLUDE_DIRS})
        set (LIBS ${LIBS} ${SuperLU_LIBRARIES})
    endif()
endif(LIFE_USE_SuperLU)
131
endif()
132

Radu Popescu's avatar
Radu Popescu committed
133
# SuperLUMT (optional)
134
if (NOT SUPERLUMT_IS_IN_TRILINOS)
Radu Popescu's avatar
Radu Popescu committed
135
136
137
138
139
140
141
142
if (LIFE_USE_SuperLUMT)
    find_package (SuperLUMT)
    if (SuperLUMT_FOUND)
        set (HAVE_SuperLUMT TRUE)
        include_directories (${SuperLUMT_INCLUDE_DIRS})
        set (LIBS ${LIBS} ${SuperLUMT_LIBRARIES})
    endif()
endif(LIFE_USE_SuperLUMT)
143
endif()
Radu Popescu's avatar
Radu Popescu committed
144

145
# SuperLUDist (optional)
146
if (NOT SUPERLUDIST_IS_IN_TRILINOS)
147
148
149
150
151
152
153
154
if (LIFE_USE_SuperLUDist)
    find_package (SuperLUDist)
    if (SuperLUDist_FOUND)
        set (HAVE_SuperLUDist TRUE)
        include_directories (${SuperLUDist_INCLUDE_DIRS})
        set (LIBS ${LIBS} ${SuperLUDist_LIBRARIES})
    endif()
endif(LIFE_USE_SuperLUDist)
155
endif()
156

Radu Popescu's avatar
Radu Popescu committed
157
# LAPACK
158
if (NOT LAPACK_IS_IN_TRILINOS)
Radu Popescu's avatar
Radu Popescu committed
159
160
161
162
163
find_package (LAPACK REQUIRED)
if (LAPACK_FOUND)
    include_directories (${LAPACK_INCLUDE_DIR})
    set (LIBS ${LIBS} ${LAPACK_LIBRARIES})
endif()
164
endif()
Radu Popescu's avatar
Radu Popescu committed
165
166

# BLAS
167
if (NOT BLAS_IS_IN_TRILINOS)
Radu Popescu's avatar
Radu Popescu committed
168
169
170
171
172
find_package (BLAS REQUIRED)
if (BLAS_FOUND)
    include_directories (${BLAS_INCLUDE_DIR})
    set (LIBS ${LIBS} ${BLAS_LIBRARIES})
endif()
173
endif()
Radu Popescu's avatar
Radu Popescu committed
174
175

# HDF5 (optional)
176
if (NOT HDF5_IS_IN_TRILINOS)
Radu Popescu's avatar
Radu Popescu committed
177
178
179
if (LIFE_USE_HDF5)
    if (HDF5_ROOT)
        set (HDF5_INCLUDE_DIRS ${HDF5_ROOT}/include)
180
        set (HDF5_INCLUDE_DIR ${HDF5_ROOT}/include)
Radu Popescu's avatar
Radu Popescu committed
181
        set (HDF5_LIBRARIES "-L${HDF5_ROOT}/lib -lhdf5 -lz -lm")
Radu Popescu's avatar
Radu Popescu committed
182
183
184
185
186
187
188
189
190
    endif()
    find_package (HDF5)
    if (HDF5_FOUND)
        set (HAVE_HDF5 TRUE)
        include_directories (${HDF5_INCLUDE_DIRS})
        link_directories (${HDF5_LIBRARY_DIRS})
        set (LIBS ${LIBS} ${HDF5_LIBRARIES})
    endif()
endif(LIFE_USE_HDF5)
191
endif()
Radu Popescu's avatar
Radu Popescu committed
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

# Boost
find_package (Boost REQUIRED)
if (Boost_FOUND)
    set (HAVE_BOOST TRUE)
    set (HAVE_BOOST_VERSION ${Boost_VERSION})
    if (Boost_MINOR_VERSION GREATER 39)
        set (HAVE_BOOST_GT_1_39 TRUE)
    endif(Boost_MINOR_VERSION GREATER 39)
    if (Boost_MINOR_VERSION GREATER 40)
        set (HAVE_BOOST_SPIRIT_QI TRUE)
    endif(Boost_MINOR_VERSION GREATER 40)
    include_directories (${Boost_INCLUDE_DIR})
    link_directories (${Boost_LIBRARY_DIRS})
    set (LIBS ${LIBS} ${Boost_LIBRARIES})
207
208
209
    if (NOT LIFE_USE_SPIRIT_PARSER)
        set (DISABLE_SPIRIT_PARSER TRUE)
    endif()
Radu Popescu's avatar
Radu Popescu committed
210
211
212
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
endif()

# QHULL (optional)
if (LIFE_USE_QHULL)
    find_package (QHULL)
    if (QHULL_FOUND)
        set (HAVE_QHULL TRUE)
        include_directories (${QHULL_INCLUDE_DIRS})
        set (LIBS ${LIBS} ${QHULL_LIBRARIES})
    endif()
endif(LIFE_USE_QHULL)

# Make sure that all headers are in the include path
include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
set (LIFEV_PACKAGES core array mesh alg fem filters functions solver)
foreach (component ${LIFEV_PACKAGES})
    include_directories (${PROJECT_SOURCE_DIR}/life/life${component})
    set (LIBS life${component} ${LIBS})
endforeach(component)

# Here we add the user-define value of LIBS
set (LIBS ${LIBS} ${LIFE_EXTRA_LINK_LINE})

# lifeconfig.h
string (COMPARE EQUAL ${CMAKE_BUILD_TYPE} "Debug" HAVE_LIFEV_DEBUG)
string (COMPARE EQUAL ${CMAKE_BUILD_TYPE} "Release" HAVE_LIFEV_OPTO3)

configure_file(
  "${PROJECT_SOURCE_DIR}/lifeconfig_cmake.h.in"
  "${PROJECT_BINARY_DIR}/lifeconfig.h"
)
install(FILES "${PROJECT_BINARY_DIR}/lifeconfig.h"
        DESTINATION include)

# The following subdirectories are part of the project
add_subdirectory(life)
add_subdirectory(examples)

include (CTest)
enable_testing()
add_subdirectory(testsuite)

# Documentation (not yet working, don't activate)
253
254
255
if (LIFE_BUILD_DOCS)
    add_subdirectory(doc)
endif()