CMakeLists.txt 11.2 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build,
options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release
RelWithDebInfo MinSizeRel.")

PROJECT(Nektar++)

# Helps organize projects in IDEs.
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)

# Extract the version number from the VERSION file and set in CMake
# The format of this file must be X.X.X
FILE(STRINGS "VERSION" NEKVER)
STRING(REPLACE "." ";" NEKVERLIST ${NEKVER})
LIST(GET NEKVERLIST 0 NEKTAR_VERSION_MAJOR)
LIST(GET NEKVERLIST 1 NEKTAR_VERSION_MINOR)
LIST(GET NEKVERLIST 2 NEKTAR_VERSION_PATCH)
SET(NEKTAR_VERSION ${NEKTAR_VERSION_MAJOR}.${NEKTAR_VERSION_MINOR}.${NEKTAR_VERSION_PATCH})

20
# Add support for CMAKE_DEPENDENT_OPTION
21
INCLUDE(CMakeDependentOption)
22
23

# Enable CTest.
24
25
26
27
ENABLE_TESTING()

# Use the CMake 2.4 policy for CMake 2.6
IF(COMMAND cmake_policy)
28
29
30
31
32
33
34
    CMAKE_POLICY(SET CMP0003 OLD)

    # Silence warnings when using generator expressions in
    # TARGET_LINK_LIBRARIES.
    IF(POLICY CMP0022)
        CMAKE_POLICY(SET CMP0022 NEW)
    ENDIF()
35
36
37
38
ENDIF(COMMAND cmake_policy)

# Find the modules included with Nektar
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
39
40
41
42

# Set default install path if not provided on the command-line
IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
    SET(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/dist CACHE PATH "" FORCE)
43
44
ENDIF()

45
# Attempt to retrieve git branch and SHA1 hash of current changeset.
46
INCLUDE(GetGitRevisionDescription)
Chris Cantwell's avatar
Chris Cantwell committed
47
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
48

49
# Set library, binary, include, share and doc paths.
50
SET(LIB_DIR "lib/nektar++-${NEKTAR_VERSION}")
Dave Moxey's avatar
Dave Moxey committed
51
IF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT APPLE )
52
    SET(LIB_DIR "lib64/nektar++-${NEKTAR_VERSION}")
53
54
55
56
57
ENDIF()
SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")

SET(NEKTAR_BIN_DIR bin)
SET(NEKTAR_LIB_DIR ${LIB_DIR})
58
59
60
SET(NEKTAR_INCLUDE_DIR include/nektar++-${NEKTAR_VERSION})
SET(NEKTAR_SHARE_DIR share/nektar++-${NEKTAR_VERSION})
SET(NEKTAR_DOC_DIR share/doc/nektar++-${NEKTAR_VERSION})
61
62

# Build shared libraries.
63
64
65
66
67
68
SET(NEKTAR_LIBRARY_TYPE "SHARED")

# Set up RPATH
SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
69
70
71
72
IF (APPLE)
    SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
    SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
ENDIF()
73
74
75
76
77
78
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
	"${CMAKE_INSTALL_PREFIX}/${LIB_DIR}" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
	SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
ENDIF("${isSystemDir}" STREQUAL "-1")

79
80
81
82
83
84
85
# Get rid of OS X RPATH warnings -- we should set this to 1 once we reach
# required minimum cmake version of 3.0.0 and configure it in a more sane
# fashion.
IF(NOT DEFINED CMAKE_MACOSX_RPATH)
    SET(CMAKE_MACOSX_RPATH 0)
ENDIF()

86
87
88
89
90
91
92
93
# Components of the Nektar++ package to build
OPTION(NEKTAR_BUILD_LIBRARY    "Build main Nektar++ libraries." ON)
OPTION(NEKTAR_BUILD_DEMOS      "Build demonstration codes."     ON)
OPTION(NEKTAR_BUILD_SOLVERS    "Build example solvers."         ON)
OPTION(NEKTAR_BUILD_UTILITIES  "Build utilities."               ON)
OPTION(NEKTAR_BUILD_UNIT_TESTS "Build unit tests."              ON)
OPTION(NEKTAR_BUILD_TESTS      "Build regression tests."        ON)
OPTION(NEKTAR_BUILD_TIMINGS    "Build benchmark timing codes."  OFF)
94
95
OPTION(NEKTAR_BUILD_PACKAGES   "Build Nektar++ binary packages" OFF)
MARK_AS_ADVANCED(NEKTAR_BUILD_PACKAGES)
96

97
OPTION(NEKTAR_TEST_ALL "Include full set of regression tests to this build." OFF)
98

99
# Meshing utilities and library
100
OPTION(NEKTAR_USE_MESHGEN "Build mesh generation utilities." OFF)
Michael Turner's avatar
Michael Turner committed
101

102
103
104
105
# Build options
OPTION(NEKTAR_FULL_DEBUG "Enable Full Debugging." OFF)
MARK_AS_ADVANCED(NEKTAR_FULL_DEBUG)

Michael Turner's avatar
Michael Turner committed
106
IF (${CMAKE_COMPILER_IS_GNUCXX})
107
108
    OPTION(NEKTAR_ENABLE_PROFILE "Uses -pg compiler flag" OFF)
    MARK_AS_ADVANCED(NEKTAR_ENABLE_PROFILE)
Michael Turner's avatar
Michael Turner committed
109
ENDIF (${CMAKE_COMPILER_IS_GNUCXX})
110

Michael Turner's avatar
Michael Turner committed
111
OPTION(NEKTAR_USE_EXPRESSION_TEMPLATES
112
    "Use Expression templates." OFF)
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
MARK_AS_ADVANCED(NEKTAR_USE_EXPRESSION_TEMPLATES)

# BLAS Support
OPTION(NEKTAR_USE_BLAS_LAPACK "Use Blas and lapack routines." ON)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_OPENBLAS
    "Use OpenBLAS library as a substitute to native BLAS." OFF
    "NEKTAR_USE_BLAS_LAPACK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_SMV
    "Use LibSMV library for faster small matrix-vector multiplies." OFF
    "NEKTAR_USE_BLAS_LAPACK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_ACML
    "Use the AMD Core Math Library (ACML) for BLAS and Lapack support." OFF
    "NEKTAR_USE_BLAS_LAPACK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_MKL
    "Use the Intel Math Kernel Library (MKL) for BLAS and Lapack support." OFF
    "NEKTAR_USE_BLAS_LAPACK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_SYSTEM_BLAS_LAPACK
    "Use the system provided blas and lapack libraries" ON
    "NEKTAR_USE_BLAS_LAPACK; UNIX; NOT APPLE; NOT NEKTAR_USE_OPENBLAS; NOT NEKTAR_USE_MKL; NOT NEKTAR_USE_ACML; NOT NEKTAR_USE_ACCELERATE_FRAMEWORK" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_ACCELERATE_FRAMEWORK
    "Use the Mac Accelerate Framework for BLAS and Lapack support." ON
    "NEKTAR_USE_BLAS_LAPACK; APPLE" OFF)
135
136
137
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_WIN32_LAPACK
    "Use Win32 Lapack provided with the Third Party Distribution."
    ON "NEKTAR_USE_BLAS_LAPACK; WIN32" OFF)
138

Dave Moxey's avatar
Dave Moxey committed
139
# Memory pools
140
141
142
143
OPTION(NEKTAR_USE_MEMORY_POOLS
    "Use memory pools to accelerate memory allocation." ON)
MARK_AS_ADVANCED(NEKTAR_USE_MEMORY_POOLS)

144
145
146
IF (MSVC)
    # Needed for M_PI to be visible in visual studio.
    ADD_DEFINITIONS(-D_USE_MATH_DEFINES)
Michael Turner's avatar
Michael Turner committed
147

148
    # Removes the warnings about unsafe methods such as strcpy, std::copy,
149
    # memcmp, etc.
150
151
    ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE)
ENDIF()
152
153
154
155

# Include Nektar++ common macros
INCLUDE (NektarCommon)

156
157
158
# Set various ThirdParty locations
SET(TPURL   http://www.nektar.info/thirdparty)
SET(TPSRC   ${CMAKE_SOURCE_DIR}/ThirdParty)
159
SET(TPBUILD ${CMAKE_BINARY_DIR}/ThirdParty)
160
SET(TPDIST  ${CMAKE_BINARY_DIR}/ThirdParty/dist)
161
SET(TPINC   ${CMAKE_INSTALL_PREFIX}/include/ThirdParty)
162
SET(TPLIB   ${CMAKE_INSTALL_PREFIX}/${NEKTAR_LIB_DIR})
163
164

# Create ThirdParty source directory if it doesn't exist already.
165
166
167
IF (NOT EXISTS ${TPSRC})
    FILE(MAKE_DIRECTORY ${TPSRC})
ENDIF ()
168

169
# Find ThirdParty libraries and headers.
170
171
172
INCLUDE (ThirdPartyTinyxml)
INCLUDE (ThirdPartyLoki)
INCLUDE (ThirdPartyMetis)
173
INCLUDE (ThirdPartyScotch)
174
INCLUDE (ThirdPartyZlib)
175
INCLUDE (ThirdPartyBoost)
176
INCLUDE (ThirdPartyFFTW)
177
INCLUDE (ThirdPartyOCC)
178
179
INCLUDE (ThirdPartyArpack)
INCLUDE (ThirdPartyMPI)
Dave Moxey's avatar
Dave Moxey committed
180
INCLUDE (ThirdPartyPETSc)
181
182
183
INCLUDE (ThirdPartyVTK)
INCLUDE (ThirdPartyQT4)
INCLUDE (ThirdPartySMV)
184
# INCLUDE (ThirdPartyTriangle)
Michael Turner's avatar
Michael Turner committed
185
INCLUDE (ThirdPartyTetGen)
186
INCLUDE (ThirdPartyANN)
187
INCLUDE (ThirdPartyCCM)
188
INCLUDE (ThirdPartyHDF5)
189

Michael Turner's avatar
Michael Turner committed
190

191
192
INCLUDE (Doxygen)

193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
IF( NEKTAR_USE_MKL )
    INCLUDE (FindMKL)
    SET(NEKTAR_USING_BLAS TRUE)
    SET(NEKTAR_USING_LAPACK TRUE)
    SET(NEKTAR_USING_MKL TRUE)
ENDIF( NEKTAR_USE_MKL )

IF( NEKTAR_USE_OPENBLAS )
    INCLUDE (FindOpenBlas)
    SET(NEKTAR_USING_OPENBLAS TRUE)
ENDIF( NEKTAR_USE_OPENBLAS )

IF( NEKTAR_USE_SMV )
    INCLUDE (FindSMV)
    SET(NEKTAR_USING_SMV TRUE)
Michael Turner's avatar
Michael Turner committed
208
    ADD_DEFINITIONS(-DNEKTAR_USING_SMV)
209
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
ENDIF( NEKTAR_USE_SMV )

IF( NEKTAR_USE_ACCELERATE_FRAMEWORK )
    INCLUDE (FindAccelerateFramework)
ENDIF( NEKTAR_USE_ACCELERATE_FRAMEWORK )

IF( NEKTAR_USE_ACML )
    INCLUDE (FindACML)
    SET(NEKTAR_USING_BLAS TRUE)
    SET(NEKTAR_USING_LAPACK TRUE)
    SET(NEKTAR_USING_ACML TRUE)
    ADD_DEFINITIONS(-DUSE_ACML)
ENDIF( NEKTAR_USE_ACML )

IF( NEKTAR_USE_WIN32_LAPACK )
    INCLUDE (FindWin32Lapack)
ENDIF( NEKTAR_USE_WIN32_LAPACK )

IF( NEKTAR_USE_SYSTEM_BLAS_LAPACK )
    INCLUDE(FindNativeBlasLapack)
    SET(NEKTAR_USING_BLAS TRUE)
    SET(NEKTAR_USING_LAPACK TRUE)
ENDIF( NEKTAR_USE_SYSTEM_BLAS_LAPACK )

IF( NEKTAR_USE_BLAS_LAPACK )
    SET(NEKTAR_USING_BLAS TRUE)
    SET(NEKTAR_USING_LAPACK TRUE)
    ADD_DEFINITIONS( -DNEKTAR_USING_LAPACK -DNEKTAR_USING_BLAS )
ENDIF( NEKTAR_USE_BLAS_LAPACK )

IF( NEKTAR_USE_TINYXML_STL )
    ADD_DEFINITIONS( -DTIXML_USE_STL)
ENDIF( NEKTAR_USE_TINYXML_STL )

Michael Turner's avatar
Michael Turner committed
243
IF( NEKTAR_USE_DIRECT_BLAS_CALLS )
244
245
246
247
248
249
250
251
252
253
254
255
256
    ADD_DEFINITIONS(-DNEKTAR_USING_DIRECT_BLAS_CALLS)
ENDIF( NEKTAR_USE_DIRECT_BLAS_CALLS )

IF( NEKTAR_USE_EXPRESSION_TEMPLATES )
    ADD_DEFINITIONS(-DNEKTAR_USE_EXPRESSION_TEMPLATES -DNEKTAR_USING_CMAKE)
ENDIF( NEKTAR_USE_EXPRESSION_TEMPLATES )

IF( NEKTAR_USE_MEMORY_POOLS )
    ADD_DEFINITIONS(-DNEKTAR_MEMORY_POOL_ENABLED)
ELSE( NEKTAR_USE_MEMORY_POOLS )
    REMOVE_DEFINITIONS(-DNEKTAR_MEMORY_POOL_ENABLED)
ENDIF( NEKTAR_USE_MEMORY_POOLS )

257
258
259
260
IF (NEKTAR_USE_MESHGEN)
    ADD_DEFINITIONS(-DNEKTAR_USE_MESHGEN)
ENDIF()

261
262
263
264
265
266
267
268
269
270
271
272
273
SET(Boost_USE_STATIC_LIBS OFF)
IF( WIN32 )
    # The auto-linking feature has problems with USE_STATIC_LIBS off, so we use
    # BOOST_ALL_NO_LIB to turn it off.
    # Several boost libraries headers aren't configured correctly if
    # USE_STATIC_LIBS is off, so we explicitly say they are dynamic with the
    # remaining definitions.
    ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_THREAD_DYN_LINK)
ENDIF( )

# Set up include directories. Include work-around for -isystem for CMake (see
# bug 0010837) to avoid unnecessary compiler warnings for third-party libs.
IF (APPLE)
Michael Turner's avatar
Michael Turner committed
274
275
  SET(CMAKE_INCLUDE_SYSTEM_FLAG_C   "-isystem ")
  SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
276
277
278
279
280
281
282
ENDIF (APPLE)

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})

# Build active components
IF (NEKTAR_BUILD_LIBRARY)
    SET(NEKTAR++_LIBRARIES SolverUtils LibUtilities StdRegions SpatialDomains LocalRegions
283
        MultiRegions Collections NekMeshUtils)
284
285
    INCLUDE_DIRECTORIES(library)
    ADD_SUBDIRECTORY(library)
286
    INSTALL(EXPORT Nektar++Libraries DESTINATION ${LIB_DIR}/cmake COMPONENT dev)
287
288
ENDIF (NEKTAR_BUILD_LIBRARY)

289
290
291
292
IF (NEKTAR_BUILD_SOLVERS)
    INCLUDE_DIRECTORIES(solvers)
    ADD_SUBDIRECTORY(solvers)
ENDIF(NEKTAR_BUILD_SOLVERS)
293
294
295
296
297
298
299
300
301

IF (NEKTAR_BUILD_UTILITIES)
    INCLUDE_DIRECTORIES(utilities)
    ADD_SUBDIRECTORY(utilities)
ENDIF (NEKTAR_BUILD_UTILITIES)

IF (NEKTAR_BUILD_TESTS)
    INCLUDE_DIRECTORIES(tests)
    ADD_SUBDIRECTORY(tests)
302
303
304
    IF (NEKTAR_USE_MPI)
        OPTION(NEKTAR_TEST_FORCEMPIEXEC  "Force all tests to be run through the MPI job launcher."  OFF)
    ENDIF (NEKTAR_USE_MPI)
305
306
ENDIF (NEKTAR_BUILD_TESTS)

307
308
309
310
311
312
313
SET(NEKTAR_DEFINITIONS "")
GET_DIRECTORY_PROPERTY(
    NEKTAR_DEFINITIONS_LIST DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS)
FOREACH(def ${NEKTAR_DEFINITIONS_LIST})
    SET(NEKTAR_DEFINITIONS "${NEKTAR_DEFINITIONS} -D${def}")
ENDFOREACH()

314
315
# Write out Nektar++ build configuration
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/Nektar++Config.cmake.in
316
               ${CMAKE_BINARY_DIR}/Nektar++Config.cmake @ONLY)
317
318
319

# Install Nektar++ CMake configuration file
INSTALL(FILES ${CMAKE_BINARY_DIR}/Nektar++Config.cmake
320
321
    DESTINATION ${NEKTAR_LIB_DIR}/cmake/
    COMPONENT dev)
322
323

# Install ThirdParty headers to subdirectory of ${NEKTAR_INCLUDE_DIR}
324
325
326
327
INSTALL(DIRECTORY ${TPDIST}/include/
    DESTINATION ${NEKTAR_INCLUDE_DIR}/ThirdParty
    COMPONENT ThirdParty
)
328

329
# Install ThirdParty libraries into ${NEKTAR_LIB_DIR}
330
331
332
333
INSTALL(DIRECTORY ${TPDIST}/lib/
    DESTINATION ${NEKTAR_LIB_DIR}
    COMPONENT ThirdParty
)
334

335
336
337
IF(NEKTAR_BUILD_PACKAGES)
    add_subdirectory(pkg)
ENDIF(NEKTAR_BUILD_PACKAGES)
338
339

ADD_SUBDIRECTORY(docs)