CMakeLists.txt 6.35 KB
Newer Older
1 2 3
# A minimum version for cmake command is required.
cmake_minimum_required(VERSION 3.8)

4 5 6 7 8
if(MOREFEM_NO_TRAP_SNES_EXCEPTION)
    message("Adding flag MOREFEM_NO_TRAP_SNES_EXCEPTION")
    add_definitions(-DMOREFEM_NO_TRAP_SNES_EXCEPTION)
endif()

9
if(MOREFEM_CHECK_UPDATE_GHOSTS_CALL_RELEVANCE)
10
    message("Adding flag MOREFEM_CHECK_UPDATE_GHOSTS_CALL_RELEVANCE")
11 12 13 14
    add_definitions(-DMOREFEM_CHECK_UPDATE_GHOSTS_CALL_RELEVANCE)
endif()

if(MOREFEM_EXTENDED_TIME_KEEP)
15
    message("Adding flag MOREFEM_EXTENDED_TIME_KEEP")
16 17 18
    add_definitions(-DMOREFEM_EXTENDED_TIME_KEEP)
endif()

GILLES Sebastien's avatar
GILLES Sebastien committed
19
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
20
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
21

22 23
get_property(MOREFEM_COMPILE_DEFINITIONS DIRECTORY PROPERTY COMPILE_DEFINITIONS)

24

25
# TODO SHould disappear (in compiler...)
26 27 28 29 30 31 32 33
# From http://cmake.3232098.n2.nabble.com/Default-value-for-CMAKE-BUILD-TYPE-td7550756.html#a7550797
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to 'Debug' as none was specified.")
  set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
  # Set the possible values of build type for cmake-gui
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
    "MinSizeRel" "RelWithDebInfo")
34
endif()
35

36
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/cmake)
37

38

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
# ===================================================================================================================
# Set C and C++ compiler (or more exactly their mpi wrappers)
# ===================================================================================================================
set(CMAKE_C_COMPILER ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/bin/mpicc CACHE FILEPATH "C compiler. Prefer to use an openmpi wrapper.")
set(CMAKE_CXX_COMPILER ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/bin/mpic++ CACHE FILEPATH "C++ compiler. Prefer to use an openmpi wrapper.")

# ===================================================================================================================
# Set third party include and lib directories
# ===================================================================================================================
set(OPEN_MPI_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/include CACHE PATH "Include directory of Openmpi library.")
set(OPEN_MPI_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/lib CACHE PATH "Lib directory of Openmpi library." )

set(PETSC_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/include CACHE PATH "Include directory of Petsc library.")
set(PETSC_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/lib CACHE PATH "Library directory of Petsc.")

set(PARMETIS_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Parmetis/include CACHE PATH "Include directory of Parmetis library.")
set(PARMETIS_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Parmetis/lib CACHE PATH "Lib directory of Parmetis library.")

set(LUA_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Lua/include CACHE PATH "Include directory of Lua library.")
set(LUA_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Lua/lib CACHE PATH "Lib directory of Lua library.")

set(BOOST_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/include CACHE PATH "Include directory of Boost library.")
set(BOOST_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/lib CACHE PATH "Lib directory of Boost library.")


64 65 66
# ===================================================================================================================
# Set project.
# ===================================================================================================================
67
project( "MoReFEM")
68

69 70
enable_testing()

71
include(CustomCommands)
72
include(MoReFEMSettings)
73 74


75
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Sources /
76
                    ${CMAKE_CURRENT_SOURCE_DIR}/Sources/ThirdParty/Source/Tclap/include /
77
                    ${CMAKE_CURRENT_SOURCE_DIR}/Sources/ThirdParty/Source/Seldon /
78
                    ${OPEN_MPI_INCL_DIR} /
79
                    ${PETSC_INCL_DIR} /
80 81 82 83 84 85
                    ${PARMETIS_INCL_DIR} /
                    ${LUA_INCL_DIR} /
                    ${BOOST_INCL_DIR}                    
                    )


86 87 88

morefem_find_library(LIB_OPEN_MPI "mpi" ${OPEN_MPI_LIB_DIR} "Openmpi")
morefem_find_library(LIB_OPEN_MPI_CXX "mpi_cxx" ${OPEN_MPI_LIB_DIR} "Openmpi (C++)")
89
morefem_find_library(LIB_PETSC "petsc" ${PETSC_LIB_DIR} "Petsc")
90
morefem_find_library(LIB_PARMETIS "parmetis" ${PARMETIS_LIB_DIR} "Parmetis")
91
morefem_find_library(LIB_METIS "metis" ${PARMETIS_LIB_DIR} "Metis")
92 93 94
morefem_find_library(LIB_LUA "lua" ${LUA_LIB_DIR} "Lua")
morefem_find_library(LIB_BOOST_FILESYSTEM "boost_filesystem" ${BOOST_LIB_DIR} "Boost filesystem")
morefem_find_library(LIB_BOOST_SYSTEM "boost_system" ${BOOST_LIB_DIR} "Boost system")
95

96 97 98 99 100 101
if(BLAS_CUSTOM_LINKER)
    set(LIB_BLAS ${BLAS_LIB})    
else()
    morefem_find_library(LIB_BLAS ${BLAS_LIB} ${BLAS_LIB_DIR} "Blas library.")
endif()

102 103 104
if (PHILLIPS_DIR)
    morefem_find_library(LIB_PHILLIPS "pfa_border_distance_interface" ${PHILLIPS_DIR} "Phillips library")
endif()
105

106 107 108 109
set(MOREFEM_COMMON_DEP
    ${LIB_OPEN_MPI}
    ${LIB_OPEN_MPI_CXX}
    ${LIB_PETSC} 
110
    ${MOREFEM_GOMP_DEPENDENCY}
111 112
    ${LIB_PARMETIS}    
    ${LIB_METIS} 
113 114
    ${LIB_BOOST_FILESYSTEM} 
    ${LIB_BOOST_SYSTEM}                      
115
    ${LIB_BLAS}
116
    ${LIB_LUA}
117 118
)

119

120 121
set(MOREFEM_ROOT ${PROJECT_SOURCE_DIR})

122

123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
######################################################
# Settings to make shared library work correctly
######################################################

#SET(CMAKE_INSTALL_RPATH "/Volumes/Data/sebastien/Morefem/CMake/lib")
set(CMAKE_MACOSX_RPATH True)

# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH  False)

# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH False) 

set(CMAKE_INSTALL_RPATH "${MOREFEM_INSTALL_DIR}/lib")

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH True)

143

144
set(MOREFEM_TEST_OUTPUT_DIR /tmp/MoReFEM/${CMAKE_C_COMPILER_ID}/${CMAKE_BUILD_TYPE})
145 146


147 148 149
######################################################
# Walk through Sources directory to find all sources to build.
######################################################
150
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Sources)
151
      
152 153