CMakeLists.txt 6.79 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 9 10
IF (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
   SET (CMAKE_BUILD_TYPE RelWithDebInfo)
ENDIF (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
gsell's avatar
gsell committed
11

12 13 14 15
# 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
16

17
OPTION (ENABLE_ML_SOLVER "Enable iteartive SA-AMG-PCG self field solver" OFF)
gsell's avatar
gsell committed
18

19 20 21
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
22

23 24 25 26 27
OPTION (NOCPLUSPLUS11_FOREACH "Disable C++11 foreach support" OFF)
OPTION (NOCPLUSPLUS11_NULLPTR "Disable C++11 nullptr support" OFF)

SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules")
FIND_PACKAGE (IPPL REQUIRED
gsell's avatar
gsell committed
28
               PATHS /usr/local/include /usr/include $ENV{IPPL_PREFIX})
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
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)

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}"
54
    )
55
ENDIF (NOCPLUSPLUS11_FOREACH)
56

57 58 59 60
IF (NOCPLUSPLUS11_NULLPTR)
    MESSAGE (STATUS "\nBuilding OPAL without c++11 nullptr support")
    SET (CMAKE_CXX_FLAGS
        "-DOPAL_NOCPLUSPLUS11_NULLPTR ${CMAKE_CXX_FLAGS}"
61
    )
62
ENDIF (NOCPLUSPLUS11_NULLPTR)
63

gsell's avatar
gsell committed
64

65
IF (ENABLE_ML_SOLVER)
gsell's avatar
gsell committed
66
    # Get Trilinos as one entity
67
    FIND_PACKAGE (Trilinos PATHS $ENV{TRILINOS_INCLUDE_PATH})
gsell's avatar
gsell committed
68

69
    IF (NOT Trilinos_FOUND)
gsell's avatar
gsell committed
70
        MESSAGE (FATAL_ERROR "Could not find Trilinos!")
71
    ENDIF (NOT Trilinos_FOUND)
gsell's avatar
gsell committed
72
    # Echo trilinos build info just for fun
73 74 75 76 77 78 79 80 81 82 83 84 85
    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
86 87 88 89 90 91 92 93 94

    # 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}")
95

96
ENDIF (ENABLE_ML_SOLVER)
gsell's avatar
gsell committed
97

kraus's avatar
kraus committed
98
# compiler dependent flags
99 100
STRING (REGEX REPLACE ".*/([A-Za-z]*)$" "\\1" COMPILER_NAME ${CMAKE_CXX_COMPILER})
MESSAGE (STATUS "Your compiler is: ${COMPILER_NAME}")
kraus's avatar
kraus committed
101 102 103

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

104
    SET (MPI_UNDERLYING_COMPILER
kraus's avatar
kraus committed
105 106
        "")

107
    EXECUTE_PROCESS (COMMAND ${CMAKE_CXX_COMPILER} -show
kraus's avatar
kraus committed
108 109
                    OUTPUT_VARIABLE MPI_COMPILER_OUTPUT
                    ERROR_VARIABLE MPI_COMPILER_ERROR)
110
    IF ("${MPI_COMPILER_ERROR}" STREQUAL "")
111 112 113 114
        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)
115
    ENDIF ("${MPI_COMPILER_ERROR}" STREQUAL "")
kraus's avatar
kraus committed
116

117
    IF ("${MPI_UNDERLYING_COMPILER_NAME}" STREQUAL "icpc")
kraus's avatar
kraus committed
118
        # using intel compiler
119
        MESSAGE (STATUS "The underlying compiler of ${COMPILER_NAME} is: icpc")
kraus's avatar
kraus committed
120 121 122
        SET (OTHER_CMAKE_CXX_FLAGS
             "-diag-disable 383 -diag-disable 981 ${OTHER_CMAKE_CXX_FLAGS}")

123
    ELSEIF ("${MPI_UNDERLYING_COMPILER_NAME}" STREQUAL "clang++")
kraus's avatar
kraus committed
124
        # using clang compiler
125
        MESSAGE (STATUS "The underlying compiler of ${COMPILER_NAME} is: clang++")
kraus's avatar
kraus committed
126 127 128
        SET (OTHER_CMAKE_CXX_FLAGS
             "-Wsign-compare -Wunused-variable -Warray-bounds -DIPPL_RESTRICT_BUG ${OTHER_CMAKE_CXX_FLAGS}")

129
    ELSEIF ("${MPI_UNDERLYING_COMPILER_NAME}" STREQUAL "g++")
kraus's avatar
kraus committed
130
        # using gnu compiler
131
        MESSAGE (STATUS "The underlying compiler of ${COMPILER_NAME} is: g++")
132
        EXECUTE_PROCESS (COMMAND ${MPI_UNDERLYING_COMPILER} --version
133 134
                        OUTPUT_VARIABLE GCC_VERSION_OUTPUT
                        ERROR_VARIABLE GCC_VERSION_ERROR)
135 136
        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")
137 138
          SET (OTHER_CMAKE_CXX_FLAGS
               "-DOPAL_NOCPLUSPLUS11_NULLPTR -DOPAL_NOCPLUSPLUS11_FOREACH ${OTHER_CMAKE_CXX_FLAGS}")
139 140
          MESSAGE (STATUS "YOUR GCC VERSION IS: 4.5")
        ENDIF (${GCC_VERSION} VERSION_LESS "4.6.0" AND ${GCC_VERSION} VERSION_GREATER "4.5.0")
141
    ELSE ("${MPI_UNDERLYING_COMPILER_NAME}" STREQUAL "icpc")
kraus's avatar
kraus committed
142
        # using unknown compiler
143 144
        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.")
145
    ENDIF ("${MPI_UNDERLYING_COMPILER_NAME}" STREQUAL "icpc")
kraus's avatar
kraus committed
146 147 148

ELSE ("${COMPILER_NAME}" STREQUAL "mpicxx")
    # using unknown mpi implementation
149 150
    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
151 152
ENDIF ("${COMPILER_NAME}" STREQUAL "mpicxx")

153 154 155 156 157 158 159
SET (CMAKE_CXX_FLAGS
  "-Wall -Werror -std=c++0x ${CMAKE_CXX_FLAGS} ${OTHER_CMAKE_CXX_FLAGS}")

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

ADD_SUBDIRECTORY (classic/5.0/src)
ADD_SUBDIRECTORY (src)
kraus's avatar
kraus committed
160