|
| 1 | +################################################################################ |
| 2 | +# This file is part of Shadowfax |
| 3 | +# Copyright (C) 2015 Bert Vandenbroucke (bert.vandenbroucke@gmail.com) |
| 4 | +# |
| 5 | +# Shadowfax is free software: you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU Affero General Public License as published by |
| 7 | +# the Free Software Foundation, either version 3 of the License, or |
| 8 | +# (at your option) any later version. |
| 9 | +# |
| 10 | +# Shadowfax is distributed in the hope that it will be useful, |
| 11 | +# but WITOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +# GNU Affero General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU Affero General Public License |
| 16 | +# along with Shadowfax. If not, see <http://www.gnu.org/licenses/>. |
| 17 | +################################################################################ |
| 18 | + |
| 19 | +cmake_minimum_required(VERSION 2.6) |
| 20 | +project(shadowfax) |
| 21 | + |
| 22 | +# The version number. |
| 23 | +set(SHADOWFAX_VERSION_MAJOR 1) |
| 24 | +set(SHADOWFAX_VERSION_MINOR 0) |
| 25 | + |
| 26 | +# suppress warnings about duplicate build directories (caused by the foreach over dimensions) |
| 27 | +# these warnings are unnecessary in this case and displaying them may confuse the enduser |
| 28 | +cmake_policy(SET CMP0013 OLD) |
| 29 | + |
| 30 | +add_definitions(-std=c++0x) |
| 31 | + |
| 32 | +set(CMAKE_CXX_FLAGS_PROFILE "-pg -g") |
| 33 | +set(CMAKE_C_FLAGS_PROFILE "-pg -g") |
| 34 | + |
| 35 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wignored-qualifiers -Werror") |
| 36 | + |
| 37 | +if(NO_SANITIZER) |
| 38 | + set(SANITIZER False) |
| 39 | +else(NO_SANITIZER) |
| 40 | + set(SANITIZER True) |
| 41 | +endif(NO_SANITIZER) |
| 42 | + |
| 43 | +# currently the only way to link in the new GNU address sanitizer |
| 44 | +if(SANITIZER) |
| 45 | + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
| 46 | + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8") |
| 47 | + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer") |
| 48 | + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=address") |
| 49 | + add_definitions(-DSANITIZER) |
| 50 | + endif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8") |
| 51 | + endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
| 52 | +endif(SANITIZER) |
| 53 | + |
| 54 | +# fix for strange errors on the UGent HPC |
| 55 | +if(NO_MPI_SEEK) |
| 56 | + add_definitions(-DMPICH_IGNORE_CXX_SEEK) |
| 57 | +endif(NO_MPI_SEEK) |
| 58 | + |
| 59 | +# HDF5 somewhere in between versions 1.6 and 1.8 changed its API |
| 60 | +# old systems are not aware of this and need the 1.6 API. Luckily, the 1.8 |
| 61 | +# API provides macros that convert 1.6 API function calls to the correct |
| 62 | +# 1.8 version. By specifying this flag, we indicate that we will use 1.6 version |
| 63 | +# function calls everywhere. Old systems will completely ignore this flag and |
| 64 | +# everything will work. New systems will be compiled using the compatibility |
| 65 | +# macros and will hence also work. Everybody happy. |
| 66 | +# If at some point in the future, HDF5 stops supporting the old API, some work |
| 67 | +# will have to be done to replace old function calls by new ones and this flag |
| 68 | +# may be removed. |
| 69 | +# |
| 70 | +# more info: http://www.hdfgroup.org/HDF5/doc/RM/APICompatMacros.html |
| 71 | +add_definitions(-DH5_USE_16_API) |
| 72 | + |
| 73 | +# the include directories |
| 74 | +include_directories(${PROJECT_SOURCE_DIR}/inc) |
| 75 | +include_directories(${PROJECT_SOURCE_DIR}/src) |
| 76 | + |
| 77 | +find_package(MPI REQUIRED) |
| 78 | +include_directories(${MPI_INCLUDE_PATH}) |
| 79 | + |
| 80 | +find_package(Boost 1.53.0 REQUIRED) |
| 81 | +include_directories(${Boost_INCLUDE_DIRS}) |
| 82 | +link_directories(${Boost_LIBRARY_DIRS}) |
| 83 | +set(ALL_Boost_LIBRARIES ${Boost_LIBRARIES}) |
| 84 | + |
| 85 | +find_package(HDF5 REQUIRED) |
| 86 | +include_directories(${HDF5_INCLUDE_DIR}) |
| 87 | +link_directories(${HDF5_LIBRARY_DIRS}) |
| 88 | + |
| 89 | +# select the programs to compile |
| 90 | +if(ONLY_SIMULATION_PROGRAM) |
| 91 | + set(DO_SHADOWFAX True) |
| 92 | + set(DO_ICMAKER False) |
| 93 | + set(DO_VTKMAKER False) |
| 94 | +else(ONLY_SIMULATION_PROGRAM) |
| 95 | + set(DO_SHADOWFAX True) |
| 96 | + set(DO_ICMAKER True) |
| 97 | + set(DO_VTKMAKER True) |
| 98 | +endif(ONLY_SIMULATION_PROGRAM) |
| 99 | + |
| 100 | +# put executable in the rundirs |
| 101 | +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/rundir) |
| 102 | + |
| 103 | +# now do the source dir, creates the executable |
| 104 | +# we perform a loop to make separate executables for 2 and 3 dimensions |
| 105 | +if(ONLY_3D) |
| 106 | + set(NDIMS 3) |
| 107 | +elseif(ONLY_2D) |
| 108 | + set(NDIMS 2) |
| 109 | +else(ONLY_3D) |
| 110 | + set(NDIMS 2 3) |
| 111 | +endif(ONLY_3D) |
| 112 | + |
| 113 | +foreach(NDIM ${NDIMS}) |
| 114 | + add_subdirectory(src) |
| 115 | +endforeach(NDIM) |
| 116 | + |
| 117 | +# copy the testsuite (if it does not already exist) |
| 118 | +if(NOT EXISTS ${PROJECT_BINARY_DIR}/rundir/testsuite/) |
| 119 | + file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/rundir) |
| 120 | + file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/rundir/testsuite) |
| 121 | + execute_process(COMMAND cp -a ${PROJECT_SOURCE_DIR}/rundir/testsuite/. ${PROJECT_BINARY_DIR}/rundir/testsuite/) |
| 122 | +endif() |
| 123 | + |
| 124 | +# doxygen |
| 125 | +find_package(Doxygen) |
| 126 | +if(DOXYGEN_FOUND) |
| 127 | +configure_file(${PROJECT_SOURCE_DIR}/Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile @ONLY) |
| 128 | +add_custom_target(doc |
| 129 | +${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile |
| 130 | +WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} |
| 131 | +COMMENT "Generating API documentation with Doxygen" VERBATIM |
| 132 | +) |
| 133 | +endif(DOXYGEN_FOUND) |
0 commit comments