CMakeLists.txt 4.73 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

# ===================================================================================================================
# Include a file with default setting. Some of them might be overriden by command line, such as the C or C++ compiler.
# ===================================================================================================================

9 10
if (NOT OPEN_MPI_LIB_DIR)
message(FATAL_ERROR "OPEN_MPI_LIB_DIR was not found; the recommended way to build MoReFEM is to provide a setting file that provide many cache values with -C, e.g. cmake -C ../cmake/Settings/clang_shared_lib.cmake.")
11
endif()
12

13 14 15 16 17 18 19 20 21 22
if(MOREFEM_CHECK_UPDATE_GHOSTS_CALL_RELEVANCE)
    message("ADDING FLAG MOREFEM_CHECK_UPDATE_GHOSTS_CALL_RELEVANCE")
    add_definitions(-DMOREFEM_CHECK_UPDATE_GHOSTS_CALL_RELEVANCE)
endif()

if(MOREFEM_EXTENDED_TIME_KEEP)
    message("ADDING FLAG MOREFEM_EXTENDED_TIME_KEEP")
    add_definitions(-DMOREFEM_EXTENDED_TIME_KEEP)
endif()

GILLES Sebastien's avatar
GILLES Sebastien committed
23
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
24
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
25

26

27
# TODO SHould disappear (in compiler...)
28 29 30 31 32 33 34 35
# 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")
36
endif()
37

38
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/cmake)
39

40 41 42 43

# ===================================================================================================================
# Set project.
# ===================================================================================================================
44
project( "MoReFEM")
45

46 47
enable_testing()

48
include(CustomCommands)
49
include(MoReFEMSettings)
50 51


52
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Sources /
53
                    ${CMAKE_CURRENT_SOURCE_DIR}/Sources/ThirdParty/Source/Tclap/include /
54
                    ${CMAKE_CURRENT_SOURCE_DIR}/Sources/ThirdParty/Source/Seldon /
55
                    ${OPEN_MPI_INCL_DIR} /
56
                    ${PETSC_SPECIFIC_INCL_DIR} /
57 58 59 60 61 62
                    ${PARMETIS_INCL_DIR} /
                    ${LUA_INCL_DIR} /
                    ${BOOST_INCL_DIR}                    
                    )


63 64 65

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++)")
66
morefem_find_library(LIB_PETSC "petsc" ${PETSC_SPECIFIC_LIB_DIR} "Petsc")
67
morefem_find_library(LIB_PARMETIS "parmetis" ${PARMETIS_LIB_DIR} "Parmetis")
68
morefem_find_library(LIB_METIS "metis" ${PARMETIS_LIB_DIR} "Metis")
69 70 71
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")
72

73 74 75 76 77 78
if(BLAS_CUSTOM_LINKER)
    set(LIB_BLAS ${BLAS_LIB})    
else()
    morefem_find_library(LIB_BLAS ${BLAS_LIB} ${BLAS_LIB_DIR} "Blas library.")
endif()

79 80 81
if (PHILLIPS_DIR)
    morefem_find_library(LIB_PHILLIPS "pfa_border_distance_interface" ${PHILLIPS_DIR} "Phillips library")
endif()
82

83 84 85 86
set(MOREFEM_COMMON_DEP
    ${LIB_OPEN_MPI}
    ${LIB_OPEN_MPI_CXX}
    ${LIB_PETSC} 
87
    ${MOREFEM_GOMP_DEPENDENCY}
88 89
    ${LIB_PARMETIS}    
    ${LIB_METIS} 
90 91
    ${LIB_BOOST_FILESYSTEM} 
    ${LIB_BOOST_SYSTEM}                      
92
    ${LIB_BLAS}
93
    ${LIB_LUA}
94 95
)

96

97 98
set(MOREFEM_ROOT ${PROJECT_SOURCE_DIR})

99

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
######################################################
# 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)

120

121
set(MOREFEM_TEST_OUTPUT_DIR /tmp/MoReFEM/${CMAKE_C_COMPILER_ID}/${CMAKE_BUILD_TYPE})
122
   
123 124 125
######################################################
# Walk through Sources directory to find all sources to build.
######################################################
126
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Sources)
127
      
128 129