CMakeLists.txt 10.5 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.10)
2 3
PROJECT (OPAL)
SET (OPAL_VERSION_MAJOR 1)
adelmann's avatar
adelmann committed
4
SET (OPAL_VERSION_MINOR 5.00.1)
5 6 7 8 9 10
set (PACKAGE \"opal\")
set (PACKAGE_BUGREPORT \"opal@lists.psi.ch\")
set (PACKAGE_NAME \"OPAL\")
set (PACKAGE_TARNAME \"opal\")
set (PACKAGE_VERSION "\"${OPAL_VERSION_MAJOR}.${OPAL_VERSION_MINOR}\"")
set (DKS_VERSION \"1.0.1\")
gsell's avatar
gsell committed
11

12
IF (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
13 14 15
    SET (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
        "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
        FORCE
gsell's avatar
gsell committed
16
	)
17
ENDIF (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
gsell's avatar
gsell committed
18

19
MESSAGE (STATUS "Build type is: " ${CMAKE_BUILD_TYPE})
20 21
MESSAGE (STATUS "Host OS System: ${CMAKE_HOST_SYSTEM}")
MESSAGE (STATUS "Hostname:  $ENV{HOSTNAME}")
22

23
# Select flags.
24 25
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g ")
SET (CMAKE_CXX_FLAGS_RELEASE "-O3")
26
SET (CMAKE_CXX_FLAGS_DEBUG  "-O0 -g")
gsell's avatar
gsell committed
27

28 29 30
# Resolve all library dependencies
SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules")

31 32 33 34 35 36 37 38
find_package (MPI REQUIRED)
message (STATUS "The C++ compiler identification is: ${CMAKE_CXX_COMPILER_ID}")
message (STATUS "The C++ compiler version is: ${CMAKE_CXX_COMPILER_VERSION}")
message (STATUS "The MPI C++ compiler is: ${MPI_CXX_COMPILER}")
message (STATUS "The underlying C++ compiler is: ${CMAKE_CXX_COMPILER}")

# compiler dependent flags
if ( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel" )
39
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -diag-disable 383 -diag-disable 981 -std=c++11")
40

41
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
gsell's avatar
gsell committed
42
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wsign-compare -Wunused-variable -Warray-bounds -DIPPL_RESTRICT_BUG")
43

44 45
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
    if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "4.7.3")
46
        message (FATAL_ERROR "To build OPAL you need GCC version 4.7.3 or greater")
47
    elseif (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER "4.7.2")
48
       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wno-reorder -Wno-unused-local-typedefs -Werror=unused-variable -std=c++11")
49 50 51 52 53
    endif ()
else ()
    message (STATUS "Unknown C++ compiler. Please use the GNU or Intel compiler, IF you are having problems.")
endif ()

54 55 56
FIND_PACKAGE (H5Hut REQUIRED)
FIND_PACKAGE (HDF5 REQUIRED)
FIND_PACKAGE (GSL REQUIRED)
57

gsell's avatar
gsell committed
58
set (BOOSTROOT $ENV{BOOST_DIR})
59 60 61
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
kraus's avatar
kraus committed
62
find_package (Boost 1.55.0 REQUIRED COMPONENTS  regex filesystem system)
63 64
if (Boost_INCLUDE_DIRS)
    message (STATUS "Found boost include dir: ${Boost_INCLUDE_DIR}")
65 66
    message (STATUS "Found boost library dir: ${Boost_LIBRARY_DIR}")
    message (STATUS "Found boost libraries: ${Boost_LIBRARIES}")
67 68
    include_directories (${Boost_INCLUDE_DIRS})
endif ()
69

70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

### Uldis Locans 2014.09.05 ###
OPTION (ENABLE_OPENCL "Enable OpenCL" OFF)
OPTION (ENABLE_CUDA "Enable CUDA" OFF)
OPTION (ENABLE_OPENMP "Enable OpenMP + offload" OFF)

OPTION (USE_OPENCL "Use OpenCL" OFF)
OPTION (USE_CUDA "Use CUDA" OFF)
OPTION (USE_MIC "Use MIC" OFF)

### Load DKS package ###
IF (ENABLE_OPENCL OR ENABLE_CUDA OR ENABLE_MIC)
   FIND_PACKAGE(DKS REQUIRED HINTS $ENV{DKS_PREFIX} $ENV{DKS_DIR} $ENV{DKS})
   MESSAGE (STATUS "Found DKS library: ${DKS_LIBRARY}")
   MESSAGE (STATUS "Found DKS include dir: ${DKS_INCLUDE_DIR}")
kraus's avatar
kraus committed
85
   SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDKS_MPI")
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
ENDIF (ENABLE_OPENCL OR ENABLE_CUDA OR ENABLE_MIC)

### OpenCL compiler flags ###
IF (ENABLE_OPENCL)
	SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lOpenCL -pthread -DDKS_OPENCL")
ENDIF (ENABLE_OPENCL)
### End OpenCL ###

### CUDA compiler flags ###
IF (ENABLE_CUDA)
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lcudart -lcufft -lcublas -lnvToolsExt -DDKS_CUDA")
ENDIF (ENABLE_CUDA)
### End Cuda ###

### MIC compiler flags ###
IF (ENABLE_OPENMP)
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -openmp -DDKS_MIC")
ENDIF (ENABLE_OPENMP)
### END MIC ###

### if any accelerator enabled set flag to use DKS ###
IF (ENABLE_OPENCL OR ENABLE_CUDA OR ENABLE_OPENMP)
	SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPPL_DKS -DOPAL_DKS")
ENDIF (ENABLE_OPENCL OR ENABLE_CUDA OR ENABLE_OPENMP)

### select API for DKS (temporary - will be moved to runtime) ###
kraus's avatar
kraus committed
112
IF (USE_OPENCL)
113 114
	SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPPL_DKS_OPENCL")
ENDIF (USE_OPENCL)
kraus's avatar
kraus committed
115
IF (USE_CUDA)
116 117
	SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPPL_DKS_CUDA")
ENDIF (USE_CUDA)
kraus's avatar
kraus committed
118
IF (USE_MIC)
119 120 121 122
	SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPPL_DKS_MIC")
ENDIF (USE_MIC)
### END DKS part ###

123
# Handle options
124 125
OPTION (ENABLE_AMR_SOLVER "Enable BoxLib based AMR solver" OFF)

126
OPTION (ENABLE_SAAMG_SOLVER "Enable iteartive SA-AMG-PCG self field solver" OFF)
gsell's avatar
gsell committed
127

128 129 130
OPTION (DBG_SCALARFIELD "Enable dump of scalar field rho_m" OFF)
OPTION (DBG_STENCIL "Dump stencil of iterative solver in matlab format" OFF)
OPTION (BUILD_LIBOPAL "Enable building the OPAL library" OFF)
gsell's avatar
gsell committed
131

132 133 134
OPTION (NOCPLUSPLUS11_FOREACH "Disable C++11 foreach support" OFF)
OPTION (NOCPLUSPLUS11_NULLPTR "Disable C++11 nullptr support" OFF)

135 136
OPTION (NO_FIELD_ASSIGN_OPTIMIZATION "Disable compiler optimization of IPPL field assignment" OFF)

gsell's avatar
gsell committed
137 138 139 140
IF (USE_H5HUT2)
	SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_H5HUT2")
ENDIF (USE_H5HUT2)

frey_m's avatar
frey_m committed
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
IF (ENABLE_AMR_SOLVER)
    ENABLE_LANGUAGE (Fortran)
    
    SET ( CCSE_DIR $ENV{BOXLIB_PREFIX} )
    SET ( CCSE_LIBRARY_DIR $ENV{BOXLIB_LIBRARY_DIR} )
    
    FIND_PACKAGE (CCSE REQUIRED)
    
    MESSAGE (STATUS "Found BoxLib include dir: ${CCSE_INCLUDE_DIR}")
    MESSAGE (STATUS "Found BoxLib library dir: ${CCSE_LIBRARY_DIR}")
    MESSAGE (STATUS "Found BoxLib perl dir: ${CCSE_PERL_DIR}")
    
    SET (BL_SPACEDIM 3 CACHE INT "Dimension of BoxLib build")
    SET (ENABLE_MPI 1 CACHE INT "Enable build with MPI")
    SET (ENABLE_OpenMP 0 CACHE INT "Enable build with OpenMP")
    SET (BL_PRECISION "DOUBLE" CACHE INT "Precision of BoxLib build")
    SET (BL_USE_PARTICLES 1 CACHE INT "Include Particles classes in BoxLib build")
    SET (BL_DEBUG 0 CACHE INT "Include debugging information in BoxLib build")
    SET (ENABLE_PROFILING 0 CACHE INT "Include profiling information in BoxLib build")
    SET (ENABLE_BACKTRACE 0 CACHE INT "Include backtrace information in BoxLib build")
    
    # FIXME disable due to BoxLib
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-maybe-uninitialized")
    
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBL_PRECISION=${BL_PRECISION}")
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MPI=${ENABLE_MPI}")
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_OpenMP=${ENABLE_OpenMP}")
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_PARTICLES=${BL_USE_PARTICLES}")
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBL_DEBUG=${BL_DEBUG}")
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_BACKTRACE=${ENABLE_BACKTRACE}")
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_PROFILING=${ENABLE_PROFILING}")
    
    MESSAGE (STATUS "Use following BoxLib settings:")
    MESSAGE (STATUS "  BL_SPACEDIM = ${BL_SPACEDIM}")
    MESSAGE (STATUS "  BL_MACHINE = ${BL_MACHINE}")
    MESSAGE (STATUS "  BL_PRECISION = ${BL_PRECISION}")
    MESSAGE (STATUS "  ENABLE_MPI = ${ENABLE_MPI}")
    MESSAGE (STATUS "  ENABLE_OpenMP = ${ENABLE_OpenMP}")
    MESSAGE (STATUS "  BL_DEBUG = ${BL_DEBUG}")
    MESSAGE (STATUS "  BL_USE_PARTICLES = ${BL_USE_PARTICLES}")
    MESSAGE (STATUS "  ENABLE_BACKTRACE = ${ENABLE_BACKTRACE}")
    MESSAGE (STATUS "  ENABLE_PROFILING = ${ENABLE_PROFILING}")
ENDIF (ENABLE_AMR_SOLVER)
gsell's avatar
gsell committed
184 185

if (ENABLE_SAAMG_SOLVER OR ENABLE_AMR_SOLVER)
186 187
    MESSAGE ("Enable SAAMG_SOLVER  " ${ENABLE_SAAMG_SOLVER})
    MESSAGE ("Enable AMR_SOLVER    " ${ENABLE_AMR_SOLVER})
gsell's avatar
gsell committed
188 189 190 191 192 193 194 195
    find_package (Trilinos REQUIRED HINTS $ENV{TRILINOS_PREFIX} $ENV{TRILINOS_DIR} $ENV{TRILINOS})

    message (STATUS "Found Trilinos: ${Trilinos_DIR}")
    message (STATUS "      Trilinos version: ${Trilinos_VERSION}")
    message (STATUS "      Trilinos package list: ${Trilinos_PACKAGE_LIST}")
    message (STATUS "      Trilinos libraries: ${Trilinos_LIBRARIES}")
    message (STATUS "      Trilinos TPL libraries: ${Trilinos_TPL_LIBRARIES}")

196
    if (NOT ${MPI_CXX_COMPILER} STREQUAL ${Trilinos_CXX_COMPILER} )
gsell's avatar
gsell committed
197 198 199 200 201 202 203 204 205
        message (STATUS "Compiler mismatch:")
        message (STATUS "        Trilinos was compiled with:")
        message (STATUS "            ${Trilinos_C_COMPILER}")
        message (STATUS "            ${Trilinos_CXX_COMPILER}")
        message (STATUS "            ${Trilinos_Fortran_COMPILER}")
        message (STATUS "        You are using:")
        message (STATUS "            ${CMAKE_C_COMPILER}")
        message (STATUS "            ${CMAKE_CXX_COMPILER}")
        message (STATUS "            ${CMAKE_Fortran_COMPILER}")
206
        message (FATAL  "")
gsell's avatar
gsell committed
207 208
    endif ()
endif ()
209

210 211 212 213 214
IF (AMR_DUMMY_SOLVE)
    MESSAGE (STATUS "\nSolve Poisson equation with rhs equal 1")
    SET (CMAKE_CXX_FLAGS "-DAMR_DUMMY_SOLVE ${CMAKE_CXX_FLAGS}")
ENDIF (AMR_DUMMY_SOLVE)

215
IF (DBG_SCALARFIELD)
gsell's avatar
gsell committed
216 217
    MESSAGE (STATUS "\nWrite scalar rho_m field is enabled ")
    SET (CMAKE_CXX_FLAGS "-DDBG_SCALARFIELD ${CMAKE_CXX_FLAGS}")
218 219 220
ENDIF (DBG_SCALARFIELD)

IF (DBG_STENCIL)
gsell's avatar
gsell committed
221 222
    MESSAGE (STATUS "\nWrite stencil is enabled ")
    SET (CMAKE_CXX_FLAGS "-DDBG_STENCIL ${CMAKE_CXX_FLAGS}")
223 224 225
ENDIF (DBG_STENCIL)

IF (BUILD_LIBOPAL)
gsell's avatar
gsell committed
226
    MESSAGE (STATUS "\nBuilding OPAL library")
227 228 229 230 231 232
ENDIF (BUILD_LIBOPAL)

IF (NOCPLUSPLUS11_FOREACH)
    MESSAGE (STATUS "\nBuilding OPAL without c++11 foreach support")
    SET (CMAKE_CXX_FLAGS
        "-DOPAL_NOCPLUSPLUS11_FOREACH ${CMAKE_CXX_FLAGS}"
gsell's avatar
gsell committed
233
	)
234
ENDIF (NOCPLUSPLUS11_FOREACH)
235

236 237 238 239
IF (NOCPLUSPLUS11_NULLPTR)
    MESSAGE (STATUS "\nBuilding OPAL without c++11 nullptr support")
    SET (CMAKE_CXX_FLAGS
        "-DOPAL_NOCPLUSPLUS11_NULLPTR ${CMAKE_CXX_FLAGS}"
gsell's avatar
gsell committed
240
	)
241
ENDIF (NOCPLUSPLUS11_NULLPTR)
242

243 244 245 246
IF (NO_FIELD_ASSIGN_OPTIMIZATION)
    MESSAGE (STATUS "\nCompiler will not try to optimize field assignment")
    SET (CMAKE_CXX_FLAGS
        "-DdontOPTIMIZE_FIELD_ASSIGNMENT ${CMAKE_CXX_FLAGS}"
gsell's avatar
gsell committed
247
	)
248
ENDIF (NO_FIELD_ASSIGN_OPTIMIZATION)
gsell's avatar
gsell committed
249

kraus's avatar
kraus committed
250 251 252 253 254 255 256 257 258
INCLUDE(FindGit)
IF(GIT_FOUND)
    SET (OPAL_WC_REVISION 0)
    EXECUTE_PROCESS(
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
        COMMAND git rev-parse HEAD
        OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    SET (OPAL_WC_REVISION \"${GIT_OUT}\")
kraus's avatar
kraus committed
259
ELSE()
kraus's avatar
kraus committed
260
    MESSAGE (STATUS "could not find git")
kraus's avatar
kraus committed
261 262 263
    SET (OPAL_WC_REVISION \"\")
ENDIF()

kraus's avatar
kraus committed
264
SET (IPPL_USED_FROM_OPAL "TRUE")
gsell's avatar
gsell committed
265
ADD_SUBDIRECTORY (ippl)
Andreas Adelmann's avatar
Andreas Adelmann committed
266
ADD_SUBDIRECTORY (classic/src)
gsell's avatar
gsell committed
267
ADD_SUBDIRECTORY (src)
268 269

IF (BUILD_OPAL_UNIT_TESTS)
270
     ADD_SUBDIRECTORY(tests)
adelmann's avatar
adelmann committed
271
ENDIF (BUILD_OPAL_UNIT_TESTS)
272 273 274 275 276 277 278 279 280

# make variables visible in other CMakeKists files
set(OPAL_CXX_FLAGS ${OPAL_CXX_FLAGS}
         CACHE INTERNAL "" FORCE
)
 
set(OPAL_LIBS ${OPAL_LIBS}
         CACHE INTERNAL "" FORCE
)