CMakeLists.txt 11.2 KB
Newer Older
1 2 3 4 5 6
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
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++)
7

bnelson's avatar
bnelson committed
8 9 10
# Helps organize projects in IDEs.
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)

11 12 13 14 15 16 17
# 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)
18 19 20
SET(NEKTAR_VERSION ${NEKTAR_VERSION_MAJOR}.${NEKTAR_VERSION_MINOR}.${NEKTAR_VERSION_PATCH})

INCLUDE(CMakeExportBuildSettings)
21
INCLUDE(CMakeDependentOption)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
ENABLE_TESTING()

# Use the CMake 2.4 policy for CMake 2.6
IF(COMMAND cmake_policy)
  cmake_policy(SET CMP0003 OLD)
ENDIF(COMMAND cmake_policy)

# Find the modules included with Nektar
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
IF( NOT NEKTAR_PASSED_FIRST_CONFIGURE )
  SET(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/dist CACHE PATH "" FORCE)
ENDIF()

SET(LIB_DIR "lib")
IF( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
	SET(LIB_DIR "lib64")
ENDIF()
39
SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

SET(NEKTAR_BIN_DIR bin)
SET(NEKTAR_LIB_DIR ${LIB_DIR})
SET(NEKTAR_INCLUDE_DIR include/nektar++)
SET(NEKTAR_SHARE_DIR share/nektar++)
SET(NEKTAR_LIBRARY_TYPE "SHARED")

# Set up RPATH
SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
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")

# Components of the Nektar++ package to build
60 61 62 63 64 65 66
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)
67 68

# Build options
69
OPTION(NEKTAR_FULL_DEBUG "Enable Full Debugging." OFF)
70 71 72
MARK_AS_ADVANCED(NEKTAR_FULL_DEBUG)

IF (${CMAKE_COMPILER_IS_GNUCXX}) 
73
    OPTION(NEKTAR_ENABLE_PROFILE "Uses -pg compiler flag" OFF)
74 75 76 77
    MARK_AS_ADVANCED(NEKTAR_ENABLE_PROFILE)
ENDIF (${CMAKE_COMPILER_IS_GNUCXX}) 

SET(ExpressionTemplateDefault OFF)
78 79
OPTION(NEKTAR_USE_EXPRESSION_TEMPLATES 
    "Use Expression templates." ${ExpressionTemplateDefault})
80 81
MARK_AS_ADVANCED(NEKTAR_USE_EXPRESSION_TEMPLATES)

82 83 84 85 86
# 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)
87 88 89
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_SMV
    "Use LibSMV library for faster small matrix-vector multiplies." OFF
    "NEKTAR_USE_BLAS_LAPACK" OFF)
90 91 92 93 94 95 96 97
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
98
    "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)
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_ACCELERATE_FRAMEWORK
    "Use the Mac Accelerate Framework for BLAS and Lapack support." ON
    "NEKTAR_USE_BLAS_LAPACK; APPLE" OFF)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_CHUD_FRAMEWORK
    "Use the Mac CHUD Framework (for Shark support)." OFF
    "APPLE" OFF)
MARK_AS_ADVANCED(NEKTAR_USE_CHUD_FRAMEWORK)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_DIRECT_BLAS_CALLS
    "Use direct BLAS calls rather than NekMatrix calls in the StdRegions and
    LocalRegions sublibrary" ON
    "NEKTAR_USE_BLAS_LAPACK" OFF)
MARK_AS_ADVANCED(NEKTAR_USE_DIRECT_BLAS_CALLS)

OPTION(NEKTAR_USE_MEMORY_POOLS
    "Use memory pools to accelerate memory allocation." ON)
114 115 116 117
MARK_AS_ADVANCED(NEKTAR_USE_MEMORY_POOLS)

# Turn on NEKTAR_USE_WIN32_LAPACK if we are in Windows and the libraries exist.
IF( WIN32 )
bnelson's avatar
bnelson committed
118 119 120 121
    IF( CMAKE_CL_64 )
        FIND_LIBRARY( WIN32_BLAS NAMES libblas64 PATHS ${CMAKE_SOURCE_DIR}/ThirdParty ${CMAKE_SOURCE_DIR}/../ThirdParty )
        FIND_LIBRARY( WIN32_LAPACK NAMES liblapack64 PATHS ${CMAKE_SOURCE_DIR}/ThirdParty ${CMAKE_SOURCE_DIR}/../ThirdParty )
    ELSE()
Chris Cantwell's avatar
Chris Cantwell committed
122 123
	FIND_LIBRARY( WIN32_BLAS NAMES blas_win32 PATHS ${CMAKE_SOURCE_DIR}/ThirdParty ${CMAKE_SOURCE_DIR}/../ThirdParty )
	FIND_LIBRARY( WIN32_LAPACK NAMES lapack_win32 PATHS ${CMAKE_SOURCE_DIR}/ThirdParty ${CMAKE_SOURCE_DIR}/../ThirdParty )
bnelson's avatar
bnelson committed
124 125
    ENDIF()
    
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
	IF( WIN32_BLAS AND WIN32_LAPACK )
		SET(Win32LapackDefault ON)
    ELSE(WIN32_BLAS AND WIN32_LAPACK)
		SET(Win32LapackDefault OFF)
    ENDIF(WIN32_BLAS AND WIN32_LAPACK)
ELSE(WIN32)
	SET(Win32LapackDefault OFF)
ENDIF(WIN32)

IF( MSVC )
	# Needed for M_PI to be visible in visual studio.
	ADD_DEFINITIONS(-D_USE_MATH_DEFINES)
	
	# Removes the warnings about unsafe methods such as strcpy, std::copy,
    # memcmp, etc.
	ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE)
ENDIF( )


145 146 147
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_WIN32_LAPACK
    "Use Win32 Lapack provided with the Third Party Distribution."
    ${Win32LapackDefault} "NEKTAR_USE_BLAS_LAPACK; WIN32" OFF)
148

Chris Cantwell's avatar
Chris Cantwell committed
149 150
# Include Nektar++ common macros
INCLUDE (NektarCommon)
151 152

# Find Libraries
153
SET(TPURL http://www.nektar.info/thirdparty)
154
SET(TPSRC ${CMAKE_SOURCE_DIR}/ThirdParty)
155 156 157
IF (NOT EXISTS ${TPSRC})
    FILE(MAKE_DIRECTORY ${TPSRC})
ENDIF ()
158 159 160 161 162
INCLUDE (ThirdPartyTinyxml)
INCLUDE (ThirdPartyLoki)
INCLUDE (ThirdPartyMetis)
INCLUDE (ThirdPartySpblastk)
INCLUDE (ThirdPartyBoost)
163
INCLUDE (ThirdPartyZlib)
164 165 166 167
INCLUDE (ThirdPartyFFTW)
INCLUDE (ThirdPartyArpack)
INCLUDE (ThirdPartyMPI)
INCLUDE (ThirdPartyVTK)
168
INCLUDE (ThirdPartyQT4)
169
INCLUDE (ThirdPartySMV)
170 171 172 173 174 175 176

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 )
177

178 179 180 181
IF( NEKTAR_USE_OPENBLAS )
    INCLUDE (FindOpenBlas)
    SET(NEKTAR_USING_OPENBLAS TRUE)
ENDIF( NEKTAR_USE_OPENBLAS )
182

183 184 185
IF( NEKTAR_USE_SMV )
    INCLUDE (FindSMV)
    SET(NEKTAR_USING_SMV TRUE)
186
    ADD_DEFINITIONS(-DNEKTAR_USING_SMV)	
187 188
ENDIF( NEKTAR_USE_SMV )

189 190 191 192 193 194 195 196 197 198 199 200 201 202
IF( NEKTAR_USE_ACCELERATE_FRAMEWORK )
    INCLUDE (FindAccelerateFramework)
ENDIF( NEKTAR_USE_ACCELERATE_FRAMEWORK )

IF( NEKTAR_USE_CHUD_FRAMEWORK )
    INCLUDE (FindCHUDFramework)
    ADD_DEFINITIONS(-DNEKTAR_USING_CHUD)	
ENDIF( NEKTAR_USE_CHUD_FRAMEWORK )

IF( NEKTAR_USE_ACML )
    INCLUDE (FindACML)
    SET(NEKTAR_USING_BLAS TRUE)
    SET(NEKTAR_USING_LAPACK TRUE)
    SET(NEKTAR_USING_ACML TRUE)
203
    ADD_DEFINITIONS(-DUSE_ACML)
204 205 206 207 208 209 210 211
ENDIF( NEKTAR_USE_ACML )

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

IF( NEKTAR_USE_SYSTEM_BLAS_LAPACK )
    INCLUDE(FindNativeBlasLapack)
212 213
    SET(NEKTAR_USING_BLAS TRUE)
    SET(NEKTAR_USING_LAPACK TRUE)
214 215 216
ENDIF( NEKTAR_USE_SYSTEM_BLAS_LAPACK )

IF( NEKTAR_USE_BLAS_LAPACK )
217 218
    SET(NEKTAR_USING_BLAS TRUE)
    SET(NEKTAR_USING_LAPACK TRUE)
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
    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 )

IF( NEKTAR_USE_DIRECT_BLAS_CALLS )    
    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 )

240 241
SET(Boost_USE_STATIC_LIBS OFF)
IF( WIN32 )
242 243 244 245 246
    # 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.
247 248
    ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_THREAD_DYN_LINK)
ENDIF( )
249

250 251 252 253 254 255 256
# 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)
  SET(CMAKE_INCLUDE_SYSTEM_FLAG_C   "-isystem ") 
  SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") 
ENDIF (APPLE)

257
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
258 259 260

# Build active components
IF (NEKTAR_BUILD_LIBRARY)
261
    SET(NEKTAR++_LIBRARIES SolverUtils LibUtilities StdRegions SpatialDomains LocalRegions
262 263 264 265 266
        MultiRegions)
    INCLUDE_DIRECTORIES(library)
    ADD_SUBDIRECTORY(library)
ENDIF (NEKTAR_BUILD_LIBRARY)

267 268
INCLUDE_DIRECTORIES(solvers)
ADD_SUBDIRECTORY(solvers)
269 270 271 272 273 274

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

275 276 277 278 279
IF (NEKTAR_BUILD_TESTS)
    INCLUDE_DIRECTORIES(tests)
    ADD_SUBDIRECTORY(tests)
ENDIF (NEKTAR_BUILD_TESTS)

280 281 282 283 284 285 286 287 288 289
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/Nektar++Config.cmake.in 
               ${CMAKE_BINARY_DIR}/Nektar++Config.cmake @ONLY)
             
INSTALL(FILES ${CMAKE_BINARY_DIR}/Nektar++Config.cmake 
              ${CMAKE_SOURCE_DIR}/cmake/FindLoki.cmake
              ${CMAKE_SOURCE_DIR}/cmake/FindAccelerateFramework.cmake
              ${CMAKE_SOURCE_DIR}/cmake/FindCHUDFramework.cmake
              ${CMAKE_SOURCE_DIR}/cmake/FindACML.cmake
              ${CMAKE_SOURCE_DIR}/cmake/FindArpack.cmake
              ${CMAKE_SOURCE_DIR}/cmake/FindNistSparseBlas.cmake
290
              ${CMAKE_SOURCE_DIR}/cmake/FindOpenBlas.cmake
291 292 293 294 295 296 297 298
              ${CMAKE_SOURCE_DIR}/cmake/FindNativeBlasLapack.cmake
              ${CMAKE_SOURCE_DIR}/cmake/FindMKL.cmake
              ${CMAKE_SOURCE_DIR}/cmake/FindMetis.cmake
	          ${CMAKE_SOURCE_DIR}/cmake/FindFFTW.cmake
              ${CMAKE_SOURCE_DIR}/cmake/FindWin32Lapack.cmake
              ${CMAKE_SOURCE_DIR}/cmake/NektarCommon.cmake
              ${CMAKE_SOURCE_DIR}/cmake/FindTinyXml.cmake
              ${CMAKE_SOURCE_DIR}/cmake/FindGSMPI.cmake
Chris Cantwell's avatar
Chris Cantwell committed
299
              ${CMAKE_SOURCE_DIR}/cmake/FindXXT.cmake
300
              ${CMAKE_SOURCE_DIR}/cmake/FindSMV.cmake
301 302 303 304 305 306 307 308
              DESTINATION ${CMAKE_INSTALL_PREFIX}) 

INSTALL(EXPORT Nektar++Libraries DESTINATION ${LIB_DIR})

SET(NEKTAR_PASSED_FIRST_CONFIGURE ON CACHE BOOL INTERNAL)
MARK_AS_ADVANCED(NEKTAR_PASSED_FIRST_CONFIGURE)

INCLUDE(NektarPackageGenerator)