CMakeLists.txt 2.81 KB
Newer Older
Cédric Lachat's avatar
Cédric Lachat committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
## Copyright 2009-2016 Inria
## Author: Cedric Lachat
##########################################################################
#                                                                        #
#       Example of configuration file to use PaMPA with CMake            #
#                                                                        #
##########################################################################





########################
#  Main configuration  #
########################


CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(Matrice CXX C Fortran)

# Add modules
include(CMakeDependentOption)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeScripts)
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/MOD)

# Define some variables which will be fill in with ccmake or cmake-gui
option(PTHREAD "Pthread" ON)


#######################
# Find some libraries #
#######################


##on cherche d'abord la MKL, si on la trouve la variable LAPACK_LIBRARIES est renseignee. Sinon on cherche LAPACK et CBLAS
#FIND_PACKAGE(MKL)
#IF( ${MKL_FOUND} )
#  SET( LAPACK_LIBRARIES ${MKL_LIBRARIES})
#ELSE( ${MKL_FOUND} )
#  FIND_PACKAGE(CBLAS REQUIRED)
#  FIND_PACKAGE(LAPACK REQUIRED)
#  SET( LAPACK_LIBRARIES ${LAPACK_LIBARIES} ${CBLAS_LIBARIES})
#ENDIF( ${MKL_FOUND} )
##MESSAGE(STATUS "LAPACK_LIBRARIES = ${LAPACK_LIBRARIES}")

set (PAMPA_HOME ${PAMPA_HOME-INT} CACHE PATH "PAMPA home directory")
find_package (PAMPA REQUIRED)

# PT-Scotch
option (PTSCOTCH "Build PaMPA with PT-Scotch dependencies" ON)
if (PTSCOTCH)
  #add_definitions (-DPTSCOTCH)
  find_package(PTSCOTCH REQUIRED)
endif  ()


# MPI
set(MPI_COMPILER mpicc)
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})


# Pthread
if (PTHREAD)
  find_package(Threads REQUIRED)
  if (NOT CMAKE_USE_PTHREADS_INIT) # if pthread was not found
    message (FATAL_ERROR "Pthread are not available")
  endif()
endif ()



#####################
#       pampa       #
#####################

# Add dependency on PT-Scotch
include_directories( ${PAMPA_INCLUDE_DIR} )
list (APPEND PAMPA_DEPENDENCIES ${SCOTCH_LIBRARY})
list (APPEND PAMPA_DEPENDENCIES ${PTSCOTCH_LIBRARY})
list (APPEND PAMPA_DEPENDENCIES ${PTSCOTCH_EXTRA_LIBRARY})



set(EXECS
  poisson
  )

foreach( EXEC ${EXECS})
  add_executable (${EXEC} ${EXEC}.F90)
  target_link_libraries(${EXEC}
    ${PAMPA_LIBRARY} ${PAMPA_EXTRA_LIBRARY} ${PAMPA_DEPENDENCIES}) 
  if (MPI_C_LIBRARIES)
    target_link_libraries(${EXEC} ${MPI_Fortran_LIBRARIES} m)
  else ()
    target_link_libraries(${EXEC} ${MPI_LIBRARIES} m)
  endif ()
  if (PTHREAD)
    target_link_libraries(${EXEC} ${CMAKE_THREAD_LIBS_INIT})
  endif()                                                                                                      
  target_link_libraries(${EXEC} ${LAPACK_LIBRARIES} ${PAMPA_DEPENDENCIES} ${PAMPA_LIBRARY}
    )
endforeach()