CMakeLists.txt 10.3 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.10)
2 3
PROJECT (OPAL)
SET (OPAL_VERSION_MAJOR 1)
gsell's avatar
gsell committed
4
SET (OPAL_VERSION_MINOR 9.0)
5 6 7 8
set (PACKAGE \"opal\")
set (PACKAGE_BUGREPORT \"opal@lists.psi.ch\")
set (PACKAGE_NAME \"OPAL\")
set (PACKAGE_TARNAME \"opal\")
9 10 11 12
set (OPAL_VERSION "${OPAL_VERSION_MAJOR}.${OPAL_VERSION_MINOR}")
STRING (REGEX REPLACE "\\.([0-9])\\." ".0\\1." PACKAGE_VERSION ${OPAL_VERSION})
set (PACKAGE_VERSION_STR "\"${PACKAGE_VERSION}\"")
STRING (REGEX REPLACE "\\." "" PACKAGE_VERSION ${PACKAGE_VERSION})
gsell's avatar
gsell committed
13

14
IF (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
15 16 17
    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
18
	)
19
ENDIF (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
gsell's avatar
gsell committed
20

21 22 23

CMAKE_HOST_SYSTEM_INFORMATION(RESULT HOSTNAME QUERY HOSTNAME)

24
MESSAGE (STATUS "Build type is: " ${CMAKE_BUILD_TYPE})
25
MESSAGE (STATUS "Host OS System: ${CMAKE_HOST_SYSTEM}")
26
MESSAGE (STATUS "Hostname:  ${HOSTNAME}")
27

28
# Select flags.
29 30
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g ")
SET (CMAKE_CXX_FLAGS_RELEASE "-O3")
31
SET (CMAKE_CXX_FLAGS_DEBUG  "-O0 -g")
gsell's avatar
gsell committed
32

33 34 35
# Resolve all library dependencies
SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules")

36 37 38 39 40 41 42 43
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" )
44
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -diag-disable 383 -diag-disable 981 -std=c++11")
45

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

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

59 60 61
FIND_PACKAGE (H5Hut REQUIRED)
FIND_PACKAGE (HDF5 REQUIRED)
FIND_PACKAGE (GSL REQUIRED)
62

gsell's avatar
gsell committed
63
set (BOOSTROOT $ENV{BOOST_DIR})
64 65 66
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
67
find_package (Boost 1.54.0 REQUIRED COMPONENTS filesystem system iostreams regex)
68 69
if (Boost_INCLUDE_DIRS)
    message (STATUS "Found boost include dir: ${Boost_INCLUDE_DIR}")
70 71
    message (STATUS "Found boost library dir: ${Boost_LIBRARY_DIR}")
    message (STATUS "Found boost libraries: ${Boost_LIBRARIES}")
72 73
    include_directories (${Boost_INCLUDE_DIRS})
endif ()
74

75 76

### Uldis Locans 2014.09.05 ###
Uldis Locans's avatar
Uldis Locans committed
77
OPTION (ENABLE_DKS "Enable DKS" OFF)
78 79

### Load DKS package ###
80
IF (ENABLE_DKS)
81 82
   FIND_PACKAGE(DKS 1.1.0 REQUIRED HINTS $ENV{DKS_PREFIX} $ENV{DKS_DIR} $ENV{DKS})
   MESSAGE (STATUS "Found DKS version: ${DKS_VERSION}")
83 84
   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

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

   ### CUDA compiler flags ###
   SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lcudart -lcufft -lcublas -lnvToolsExt -DDKS_CUDA")
92

93
   ### if any accelerator enabled set flag to use DKS ###
94
   SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPPL_DKS -DIPPL_DKS_CUDA -DOPAL_DKS")
95
ENDIF (ENABLE_DKS)
96 97
### END DKS part ###

98
# Handle options
99 100
OPTION (ENABLE_AMR_SOLVER "Enable BoxLib based AMR solver" OFF)

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

103 104 105
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
106

107 108 109
OPTION (NOCPLUSPLUS11_FOREACH "Disable C++11 foreach support" OFF)
OPTION (NOCPLUSPLUS11_NULLPTR "Disable C++11 nullptr support" OFF)

110 111
OPTION (NO_FIELD_ASSIGN_OPTIMIZATION "Disable compiler optimization of IPPL field assignment" OFF)

112 113 114 115 116
IF (BUILD_OPAL_UNIT_TESTS)
    FIND_PACKAGE (GTest REQUIRED)
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_UNIT_TESTS")
ENDIF (BUILD_OPAL_UNIT_TESTS)

gsell's avatar
gsell committed
117 118 119 120
IF (USE_H5HUT2)
	SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_H5HUT2")
ENDIF (USE_H5HUT2)

frey_m's avatar
frey_m committed
121 122
IF (ENABLE_AMR_SOLVER)
    ENABLE_LANGUAGE (Fortran)
123

frey_m's avatar
frey_m committed
124 125
    SET ( CCSE_DIR $ENV{BOXLIB_PREFIX} )
    SET ( CCSE_LIBRARY_DIR $ENV{BOXLIB_LIBRARY_DIR} )
126

frey_m's avatar
frey_m committed
127
    FIND_PACKAGE (CCSE REQUIRED)
128

frey_m's avatar
frey_m committed
129 130 131
    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}")
132

frey_m's avatar
frey_m committed
133 134 135 136 137 138 139 140
    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")
141

frey_m's avatar
frey_m committed
142 143
    # FIXME disable due to BoxLib
    SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-maybe-uninitialized")
144

frey_m's avatar
frey_m committed
145 146 147 148 149 150 151
    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}")
152

frey_m's avatar
frey_m committed
153 154 155 156 157 158 159 160 161 162 163
    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
164

165 166 167 168 169 170 171 172
# remove digits from hostname: edison03 -> edison
STRING(REGEX MATCH "[^0-9]*" HOSTNAME_BASE "${HOSTNAME}")

# In case of Edison and Cori the find_package(Trilinos) gives the wrong
# Trilinos_TPL_LIBRARIES, instead of cray-tpsl/16.07.1 it uses
# cray-tpsl/16.06.1 libraries -> Linker error.
# We can avoid this issue by not going into the if-statement
if (NOT ${HOSTNAME_BASE} MATCHES "edison" AND NOT ${HOSTNAME_BASE} MATCHES "cori" AND (ENABLE_SAAMG_SOLVER OR ENABLE_AMR_SOLVER) )
173 174
    MESSAGE (STATUS "Enable SAAMG_SOLVER  " ${ENABLE_SAAMG_SOLVER})
    MESSAGE (STATUS "Enable AMR_SOLVER    " ${ENABLE_AMR_SOLVER})
gsell's avatar
gsell committed
175 176 177 178 179 180 181 182
    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}")

183
    if (NOT ${MPI_CXX_COMPILER} STREQUAL ${Trilinos_CXX_COMPILER} )
gsell's avatar
gsell committed
184 185 186 187 188 189 190 191 192
        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}")
193
        message (FATAL  "")
gsell's avatar
gsell committed
194 195
    endif ()
endif ()
196

197
IF (DBG_SCALARFIELD)
gsell's avatar
gsell committed
198 199
    MESSAGE (STATUS "\nWrite scalar rho_m field is enabled ")
    SET (CMAKE_CXX_FLAGS "-DDBG_SCALARFIELD ${CMAKE_CXX_FLAGS}")
200 201 202
ENDIF (DBG_SCALARFIELD)

IF (DBG_STENCIL)
gsell's avatar
gsell committed
203 204
    MESSAGE (STATUS "\nWrite stencil is enabled ")
    SET (CMAKE_CXX_FLAGS "-DDBG_STENCIL ${CMAKE_CXX_FLAGS}")
205 206 207
ENDIF (DBG_STENCIL)

IF (BUILD_LIBOPAL)
gsell's avatar
gsell committed
208
    MESSAGE (STATUS "\nBuilding OPAL library")
209 210 211 212 213 214
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
215
	)
216
ENDIF (NOCPLUSPLUS11_FOREACH)
217

218 219 220 221
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
222
	)
223
ENDIF (NOCPLUSPLUS11_NULLPTR)
224

225 226 227 228
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
229
	)
230
ENDIF (NO_FIELD_ASSIGN_OPTIMIZATION)
gsell's avatar
gsell committed
231

kraus's avatar
kraus committed
232 233 234 235 236 237 238 239 240
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
241
ELSE()
kraus's avatar
kraus committed
242
    MESSAGE (STATUS "could not find git")
kraus's avatar
kraus committed
243 244 245
    SET (OPAL_WC_REVISION \"\")
ENDIF()

kraus's avatar
kraus committed
246
SET (IPPL_USED_FROM_OPAL "TRUE")
gsell's avatar
gsell committed
247 248
ADD_SUBDIRECTORY (ippl)
ADD_SUBDIRECTORY (src)
249 250
ADD_SUBDIRECTORY (tools)
ADD_SUBDIRECTORY (doc/user_guide)
251 252

IF (BUILD_OPAL_UNIT_TESTS)
253
     ADD_SUBDIRECTORY(tests)
adelmann's avatar
adelmann committed
254
ENDIF (BUILD_OPAL_UNIT_TESTS)
255 256 257 258 259

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

261 262
set(OPAL_LIBS ${OPAL_LIBS}
         CACHE INTERNAL "" FORCE
263
)