CMakeLists.txt 6.98 KB
Newer Older
1 2 3 4
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
PROJECT (OPAL)
SET (OPAL_VERSION_MAJOR 1)
SET (OPAL_VERSION_MINOR 1.9)
gsell's avatar
gsell committed
5

6
SET (CMAKE_CXX_COMPILER ${MPI_COMPILER})
gsell's avatar
gsell committed
7

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

15 16
MESSAGE (STATUS "Build type is: " ${CMAKE_BUILD_TYPE})

17 18 19 20
# Select flags.
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
SET (CMAKE_CXX_FLAGS_RELEASE "-O2")
SET (CMAKE_CXX_FLAGS_DEBUG  "-O0 -g")
gsell's avatar
gsell committed
21

22 23 24 25 26 27 28 29 30 31 32 33 34 35

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

FIND_PACKAGE (IPPL REQUIRED HINTS $ENV{IPPL_PREFIX})
MESSAGE (STATUS "Found IPPL library dir: ${IPPL_LIBRARY_DIR}")
MESSAGE (STATUS "Found IPPL include dir: ${IPPL_INCLUDE_DIR}")

FIND_PACKAGE (H5Hut REQUIRED)
FIND_PACKAGE (HDF5 REQUIRED)
FIND_PACKAGE (GSL REQUIRED)


# Handle options
36
OPTION (ENABLE_ML_SOLVER "Enable iteartive SA-AMG-PCG self field solver" OFF)
gsell's avatar
gsell committed
37

38 39 40
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
41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
OPTION (NOCPLUSPLUS11_FOREACH "Disable C++11 foreach support" OFF)
OPTION (NOCPLUSPLUS11_NULLPTR "Disable C++11 nullptr support" OFF)


IF (DBG_SCALARFIELD)
   MESSAGE (STATUS "\nWrite scalar rho_m field is enabled ")
   SET (CMAKE_CXX_FLAGS "-DDBG_SCALARFIELD ${CMAKE_CXX_FLAGS}")
ENDIF (DBG_SCALARFIELD)

IF (DBG_STENCIL)
   MESSAGE (STATUS "\nWrite stencil is enabled ")
   SET (CMAKE_CXX_FLAGS "-DDBG_STENCIL ${CMAKE_CXX_FLAGS}")
ENDIF (DBG_STENCIL)

IF (BUILD_LIBOPAL)
   MESSAGE (STATUS "\nBuilding OPAL library")
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}"
64
    )
65
ENDIF (NOCPLUSPLUS11_FOREACH)
66

67 68 69 70
IF (NOCPLUSPLUS11_NULLPTR)
    MESSAGE (STATUS "\nBuilding OPAL without c++11 nullptr support")
    SET (CMAKE_CXX_FLAGS
        "-DOPAL_NOCPLUSPLUS11_NULLPTR ${CMAKE_CXX_FLAGS}"
71
    )
72
ENDIF (NOCPLUSPLUS11_NULLPTR)
73

gsell's avatar
gsell committed
74

75
IF (ENABLE_ML_SOLVER)
gsell's avatar
gsell committed
76
    # Get Trilinos as one entity
77
    FIND_PACKAGE (Trilinos PATHS $ENV{TRILINOS_INCLUDE_PATH})
gsell's avatar
gsell committed
78

79
    IF (NOT Trilinos_FOUND)
gsell's avatar
gsell committed
80
        MESSAGE (FATAL_ERROR "Could not find Trilinos!")
81
    ENDIF (NOT Trilinos_FOUND)
gsell's avatar
gsell committed
82
    # Echo trilinos build info just for fun
83 84 85 86 87 88 89 90 91 92 93 94 95
    MESSAGE (STATUS "\nFound Trilinos!  Here are the details: ")
    MESSAGE (STATUS "   Trilinos_DIR = ${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_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS}")
    MESSAGE (STATUS "   Trilinos_LIBRARY_DIRS = ${Trilinos_LIBRARY_DIRS}")
    MESSAGE (STATUS "   Trilinos_TPL_LIST = ${Trilinos_TPL_LIST}")
    MESSAGE (STATUS "   Trilinos_TPL_INCLUDE_DIRS = ${Trilinos_TPL_INCLUDE_DIRS}")
    MESSAGE (STATUS "   Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES}")
    MESSAGE (STATUS "   Trilinos_TPL_LIBRARY_DIRS = ${Trilinos_TPL_LIBRARY_DIRS}")
    MESSAGE (STATUS "   Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS}")
    MESSAGE (STATUS "End of Trilinos details\n")
gsell's avatar
gsell committed
96 97 98 99 100 101 102 103 104

    # Make sure to use same compilers and flags as Trilinos
    #SET(CMAKE_C_COMPILER ${Trilinos_C_COMPILER} )
    #SET(CMAKE_CXX_COMPILER ${Trilinos_CXX_COMPILER} )
    #SET(CMAKE_Fortran_COMPILER ${Trilinos_Fortran_COMPILER} )

    #SET(CMAKE_CXX_FLAGS  "${Trilinos_CXX_COMPILER_FLAGS} ${CMAKE_CXX_FLAGS}")
    #SET(CMAKE_C_FLAGS  "${Trilinos_C_COMPILER_FLAGS} ${CMAKE_C_FLAGS}")
    #SET(CMAKE_Fortran_FLAGS  "${Trilinos_Fortran_COMPILER_FLAGS} ${CMAKE_Fortran_FLAGS}")
105
ENDIF (ENABLE_ML_SOLVER)
gsell's avatar
gsell committed
106

107

kraus's avatar
kraus committed
108
# compiler dependent flags
109 110
STRING (REGEX REPLACE ".*/([A-Za-z]*)$" "\\1" COMPILER_NAME ${CMAKE_CXX_COMPILER})
MESSAGE (STATUS "Your compiler is: ${COMPILER_NAME}")
kraus's avatar
kraus committed
111 112 113

IF ("${COMPILER_NAME}" STREQUAL "mpicxx")

114
    SET (MPI_UNDERLYING_COMPILER
kraus's avatar
kraus committed
115 116
        "")

117
    EXECUTE_PROCESS (COMMAND ${CMAKE_CXX_COMPILER} -show
kraus's avatar
kraus committed
118 119
                    OUTPUT_VARIABLE MPI_COMPILER_OUTPUT
                    ERROR_VARIABLE MPI_COMPILER_ERROR)
120
    IF ("${MPI_COMPILER_ERROR}" STREQUAL "")
121 122 123 124
        STRING (REGEX REPLACE "([A-Za-z.0-9/]*) .*$" "\\1" MPI_UNDERLYING_COMPILER ${MPI_COMPILER_OUTPUT})
        STRING (REGEX REPLACE "/" ";" MPI_UNDERLYING_COMPILER_SPLIT ${MPI_UNDERLYING_COMPILER})
        LIST (REVERSE MPI_UNDERLYING_COMPILER_SPLIT)
        LIST (GET MPI_UNDERLYING_COMPILER_SPLIT 0 MPI_UNDERLYING_COMPILER_NAME)
125
    ENDIF ("${MPI_COMPILER_ERROR}" STREQUAL "")
kraus's avatar
kraus committed
126

127
    IF ("${MPI_UNDERLYING_COMPILER_NAME}" STREQUAL "icpc")
kraus's avatar
kraus committed
128
        # using intel compiler
129
        MESSAGE (STATUS "The underlying compiler of ${COMPILER_NAME} is: icpc")
kraus's avatar
kraus committed
130 131 132
        SET (OTHER_CMAKE_CXX_FLAGS
             "-diag-disable 383 -diag-disable 981 ${OTHER_CMAKE_CXX_FLAGS}")

133
    ELSEIF ("${MPI_UNDERLYING_COMPILER_NAME}" STREQUAL "clang++")
kraus's avatar
kraus committed
134
        # using clang compiler
135
        MESSAGE (STATUS "The underlying compiler of ${COMPILER_NAME} is: clang++")
kraus's avatar
kraus committed
136 137 138
        SET (OTHER_CMAKE_CXX_FLAGS
             "-Wsign-compare -Wunused-variable -Warray-bounds -DIPPL_RESTRICT_BUG ${OTHER_CMAKE_CXX_FLAGS}")

139
    ELSEIF ("${MPI_UNDERLYING_COMPILER_NAME}" STREQUAL "g++")
kraus's avatar
kraus committed
140
        # using gnu compiler
141
        MESSAGE (STATUS "The underlying compiler of ${COMPILER_NAME} is: g++")
142
        EXECUTE_PROCESS (COMMAND ${MPI_UNDERLYING_COMPILER} --version
143 144
                        OUTPUT_VARIABLE GCC_VERSION_OUTPUT
                        ERROR_VARIABLE GCC_VERSION_ERROR)
145 146
        STRING (REGEX REPLACE ".*([0-9]\\.[0-9]\\.[0-9]).*" "\\1" GCC_VERSION ${GCC_VERSION_OUTPUT})
        IF (${GCC_VERSION} VERSION_LESS "4.6.0" AND ${GCC_VERSION} VERSION_GREATER "4.5.0")
147 148
          SET (OTHER_CMAKE_CXX_FLAGS
               "-DOPAL_NOCPLUSPLUS11_NULLPTR -DOPAL_NOCPLUSPLUS11_FOREACH ${OTHER_CMAKE_CXX_FLAGS}")
149 150
          MESSAGE (STATUS "YOUR GCC VERSION IS: 4.5")
        ENDIF (${GCC_VERSION} VERSION_LESS "4.6.0" AND ${GCC_VERSION} VERSION_GREATER "4.5.0")
151
    ELSE ("${MPI_UNDERLYING_COMPILER_NAME}" STREQUAL "icpc")
kraus's avatar
kraus committed
152
        # using unknown compiler
153 154
        MESSAGE (STATUS "${COMPILER_NAME} is using a compiler (${MPI_UNDERLYING_COMPILER}) we were not thinking of!
                 Please use the gnu compiler or the intel compiler IF you are having problems.")
155
    ENDIF ("${MPI_UNDERLYING_COMPILER_NAME}" STREQUAL "icpc")
kraus's avatar
kraus committed
156 157 158

ELSE ("${COMPILER_NAME}" STREQUAL "mpicxx")
    # using unknown mpi implementation
159 160
    MESSAGE (STATUS "You are using an unsupported MPI compiler: ${COMPILER_NAME}!
             Please use the OpenMPI or MPICH IF you are having problems.")
kraus's avatar
kraus committed
161 162
ENDIF ("${COMPILER_NAME}" STREQUAL "mpicxx")

163 164 165 166 167
SET (CMAKE_CXX_FLAGS
  "-Wall -Werror -std=c++0x ${CMAKE_CXX_FLAGS} ${OTHER_CMAKE_CXX_FLAGS}")

MESSAGE (STATUS "Compiling with ${CMAKE_CXX_FLAGS}")

168

169 170
ADD_SUBDIRECTORY (classic/5.0/src)
ADD_SUBDIRECTORY (src)
kraus's avatar
kraus committed
171