CMakeLists.txt 37.1 KB
Newer Older
1 2
cmake_minimum_required (VERSION 2.8.3 FATAL_ERROR)

3 4 5
if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 7 AND CMAKE_PATCH_VERSION GREATER 11)
  cmake_policy(SET CMP0022 OLD)
endif()
6

7
cmake_policy(SET CMP0004 NEW)
BRAMAS Berenger's avatar
BRAMAS Berenger committed
8

9 10 11 12
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
#===========================================================================
# Project Declaration
#===========================================================================
13
project(SCALFMM C CXX )
14
# check if compiling into source directories
15
string(COMPARE EQUAL "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" insource)
16
if(insource)
17
  message(FATAL_ERROR "${PROJECT_NAME} requires an out of source build. Goto ./Build and tapes cmake ../")
18
endif(insource)
19

20 21
list(APPEND CMAKE_MODULE_PATH  ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/)
SET(SCALFMM_CMAKE_MODULE_PATH  ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/)
22 23 24
#
# Adds the CMAKE_DEPENDENT_OPTION command
INCLUDE(CMakeDependentOption)
COULAUD Olivier's avatar
COULAUD Olivier committed
25 26 27 28
#===========================================================================
# Version Number
#===========================================================================

29
# SCALFMM version number.  An even minor number corresponds to releases.
30 31 32
set(SCALFMM_MAJOR_VERSION 2)
set(SCALFMM_MINOR_VERSION 0)
set(SCALFMM_PATCH_VERSION rc0)
33
set(SCALFMM_VERSION  "${SCALFMM_MAJOR_VERSION}.${SCALFMM_MINOR_VERSION}.${SCALFMM_PATCH_VERSION}" )
COULAUD Olivier's avatar
COULAUD Olivier committed
34

35 36 37
SET(CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_STANDARD 14)

38
set( MORSE_DISTRIB_DIR "" CACHE PATH "Directory of MORSE distribution")
BRAMAS Berenger's avatar
BRAMAS Berenger committed
39

40
if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse_cmake")
41 42 43 44

  # Add extra cmake module path and initialize morse cmake modules
  # --------------------------------------------------------------
  if(MORSE_DISTRIB_DIR)
45 46 47 48 49
    list(APPEND CMAKE_MODULE_PATH ${MORSE_DISTRIB_DIR}/modules)
    set(MORSE_CMAKE_MODULE_PATH ${MORSE_DISTRIB_DIR}/modules )
  elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse_cmake")
    list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse_cmake/modules)
    set(MORSE_CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse_cmake/modules )
50 51
  endif()
  include(MorseInit)
52 53 54 55 56 57 58 59 60 61
  # Set the RPATH config
  # --------------------
  # 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 TRUE)
  # the RPATH to be used when installing
  set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

62 63 64
  # Build ScalFmm as static or dynamic lib
  # --------------------------------------
  option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
65 66
  #
  # Options
67
  #
68 69 70 71 72 73 74
  option( SCALFMM_USE_MPI              "Set to ON to build ScaFMM with MPI"          OFF )
  option( SCALFMM_USE_BLAS             "Set to ON to build ScaFMM with BLAS"         ON )
  option( SCALFMM_USE_FFT              "Set to ON to build ScaFMM with FFTW"         ON )
  option( SCALFMM_BUILD_EXAMPLES       "Set to ON to compile examples "              ON  )
  option( SCALFMM_BUILD_TESTS          "Set to ON to build functionalities Tests"    OFF )
  option( SCALFMM_BUILD_UTESTS         "Set to ON to build UTests"                   OFF )
  option( SCALFMM_INSTALL_DATA         "Set to ON to include the data when proceeding to the installtion " OFF )
75
  option( SCALFMM_BUILD_DOC            "Set to ON to build the Doxygen documentation " OFF )
76 77 78 79 80
  option( SCALFMM_BUILD_DEBUG          "Set to ON to build in Debug"                 OFF )
  option( SCALFMM_USE_LOG              "Set to ON to print output debug information" OFF )
  option( SCALFMM_USE_MEM_STATS        "Set to ON to profile memory"                 OFF )
  option( SCALFMM_ATTACHE_SOURCE       "Set to ON to compile with -g"                OFF )
  option( SCALFMM_USE_ADDONS           "Set to ON to compile add ons"                OFF )
81
  option( SCALFMM_USE_SIGNALS          "Set to ON to catch various signal an print backtrace"  OFF )
82 83
  option( SCALFMM_USE_ASSERT           "Set to ON to enable safe tests during execution" ON  )
  option( SCALFMM_USE_MIC_NATIVE       "Set to ON to compile in native mode for MIC" OFF  )
84
  option( SCALFMM_ONLY_DEVEL           "Set to ON to compile Development tools (only scalfmm team)" OFF )
85 86 87
  option( SCALFMM_USE_EZTRACE          "Set to ON to compile with eztrace framwork" OFF )
  option( SCALFMM_USE_STARPU           "Set to ON to build SCALFMM with StarPU"     OFF )
  option( SCALFMM_BUILD_UTILS          "Set to ON to build utils Tests"             OFF )
Berenger Bramas's avatar
Berenger Bramas committed
88 89


90
  if( SCALFMM_ONLY_DEVEL )
91
    if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
92
      option( SCALFMM_USE_OMP4 "Set to ON to disable the gcc/intel omp4"    OFF )
93
    else()
94
      option( SCALFMM_USE_OMP4 "Set to ON to disable the gcc/intel omp4"    ON )
95
    endif()
96
    option( SCALFMM_TIME_OMPTASKS "Set to ON to time omp4 tasks and generate output file"    OFF )
97
    # SIMGRID and peformance models options
98
    option( SCALFMM_SIMGRID_NODATA "Set to ON to avoid the allocation of numerical parts in the group tree" OFF )
99
    option( STARPU_SIMGRID_MLR_MODELS "Set to ON to enable MLR models need for calibration and simulation" OFF )
COULAUD Olivier's avatar
COULAUD Olivier committed
100
    # OPENMP 4/5 support
101
    message(WARNING "OpenMP_VERSION:  ${OpenMP_VERSION}")
COULAUD Olivier's avatar
COULAUD Olivier committed
102
    option( OPENMP_SUPPORT_PRIORITY  "Set to ON to enable tasks priority (OMP4.x/KSTAR/StarPU compiler only)" OFF )
103
    # STARPU options
COULAUD Olivier's avatar
COULAUD Olivier committed
104 105 106 107
    CMAKE_DEPENDENT_OPTION(OPENMP_SUPPORT_COMMUTE        "Set to ON to let tasks commute (KSTAR/StarPU compiler only)" OFF 
      "SCALFMM_USE_STARPU" OFF)
    CMAKE_DEPENDENT_OPTION(OPENMP_SUPPORT_TASK_NAME       "Set to ON to enable a taskname clause for tasks (KSTAR/StarPU compiler only)" OFF
      "SCALFMM_USE_STARPU" OFF)
108 109 110 111
    CMAKE_DEPENDENT_OPTION(SCALFMM_STARPU_USE_COMMUTE  "Set to ON to enable commute with StarPU" ON  "SCALFMM_USE_STARPU" OFF)
    CMAKE_DEPENDENT_OPTION(SCALFMM_STARPU_USE_REDUX  "Set to ON to enable redux with StarPU"     OFF "SCALFMM_USE_STARPU" OFF)
    CMAKE_DEPENDENT_OPTION(SCALFMM_STARPU_USE_PRIO  "Set to ON to enable priority with StarPU"   ON  "SCALFMM_USE_STARPU" OFF)
    CMAKE_DEPENDENT_OPTION(SCALFMM_STARPU_FORCE_NO_SCHEDULER  "Set to ON to disable heteroprio even if supported" OFF "SCALFMM_USE_STARPU" OFF)
112
    CMAKE_DEPENDENT_OPTION(SCALFMM_USE_STARPU_EXTRACT  "Set to ON to enable extract with StarPU mpi implicit" ON  "SCALFMM_USE_STARPU" OFF)
113
  endif()
114
  message(STATUS "AVANT  ${CMAKE_CXX_COMPILER_ID}" )
115 116 117
  #
  #  MPI
  #
118
  if( SCALFMM_USE_MPI )
119
    try_compile(COMPILE_INTEL ${CMAKE_CURRENT_BINARY_DIR}
120 121
      ${SCALFMM_CMAKE_MODULE_PATH}/compileTestIntel.cpp
      COMPILE_DEFINITIONS "${CMAKE_CXX_FLAGS}")
122 123 124 125 126 127 128
    if (COMPILE_INTEL)
      set(CMAKE_CXX_COMPILER_ID  "Intel")
    endif()
  endif()
  message(STATUS "CXX  ${CMAKE_CXX_COMPILER_ID}" )
  # Set scalfmm to default libraries
  set(SCALFMM_LIBRARIES "")
129
  set(SCALFMM_CXX_FLAGS "-fpic -Wall")
COULAUD Olivier's avatar
COULAUD Olivier committed
130
  #  set(SCALFMM_CXX_FLAGS "${SCALFMM_CXX_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/Contribs")
131 132 133 134 135 136 137 138 139 140 141 142
  #
  #
  # Test if openmp is here
  #
  find_package (OpenMP)
  if(OPENMP_FOUND)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
  else(OPENMP_FOUND)
    message(WARNING "OPENMP NOT FOUND")
  endif(OPENMP_FOUND)
143
  message(STATUS "SCALFMM_BUILD_DEBUG = ${SCALFMM_BUILD_DEBUG}" )
144 145
  #
  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
146
    set(SCALFMM_CXX_FLAGS  "${SCALFMM_CXX_FLAGS} -m64")
147 148
  endif()
  ##############################################################################
Berenger Bramas's avatar
Berenger Bramas committed
149
  #                           Inastemp                                         #
150
  ##############################################################################
151

Berenger Bramas's avatar
Berenger Bramas committed
152 153 154 155 156 157 158 159 160 161 162 163
  set(INASTEMP_JUST_LIB TRUE)
  # add the cmakelist directory
  add_subdirectory(inastemp)
  # use the filled variables from inastemp
  INCLUDE_DIRECTORIES(
           ${INASTEMP_BINARY_DIR}/Src    
           ${INASTEMP_SOURCE_DIR}/Src 
           ${INASTEMP_INCLUDE_DIR}
           ${CMAKE_CURRENT_BINARY_DIR}/inastemp/Src
      )
  # propagate the flags to be able to compile 
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${INASTEMP_CXX_FLAGS}")
164

165 166 167
  ##############################################################################
  #                           FUSE list                                        #
  ##############################################################################
COULAUD Olivier's avatar
COULAUD Olivier committed
168 169
  set(FUSE_LIST "")
  #set(FUSE_LIST " MPI;BLAS;FFT;STARPU;CUDA;OPENCL;OMP4;SSE;AVX;AVX2;MIC;MPI2")
170
  # then do list(APPEND FUSE_LIST "BLAS") to protect from FUSE_BLAS
COULAUD Olivier's avatar
COULAUD Olivier committed
171 172
  #  list(APPEND FUSE_LIST "MPI")
  
173 174 175 176
  ##############################################################################
  #                        Debug      flags                                    #
  ##############################################################################
  #
177
  if( SCALFMM_BUILD_DEBUG )
178 179 180 181 182 183
    #
    # Compile Debug flags
    #
    set(CMAKE_BUILD_TYPE Debug)
    ADD_DEFINITIONS(-O0)
    if( APPLE )
184
      set(SCALFMM_FLAGS_OPTI_DEBUG "-funroll-loops" CACHE STRING
185 186 187 188 189 190 191 192 193 194 195
        "Set your optimization flags for debug mode.")
    else(APPLE)
      if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
        set(SCALFMM_FLAGS_OPTI_DEBUG "-fp-model strict  -funroll-loops" CACHE STRING
          "Set your optimization flags for debug mode.")
      else()
        set(SCALFMM_FLAGS_OPTI_DEBUG "-funroll-loops" CACHE STRING
          "Set your optimization flags for debug mode.")
      endif()
    endif(APPLE)
    #  ADD_DEFINITIONS(${SCALFMM_FLAGS_OPTI_DEBUG})
196
    set(SCALFMM_CXX_FLAGS "${SCALFMM_CXX_FLAGS} ${SCALFMM_FLAGS_OPTI_DEBUG}")
197
    set(CMAKE_CXX_FLAGS_TYPE "${CMAKE_CXX_FLAGS_DEBUG}")
COULAUD Olivier's avatar
COULAUD Olivier committed
198
    
199 200 201 202
  else()
    ##############################################################################
    #                          Release flags                                     #
    ##############################################################################
COULAUD Olivier's avatar
COULAUD Olivier committed
203
    
204 205 206
    set(CMAKE_BUILD_TYPE Release)
    set(CMAKE_CXX_FLAGS_TYPE  "${CMAKE_CXX_FLAGS_RELEASE}")
    # if compiler is intel add -ip
207

BRAMAS Berenger's avatar
BRAMAS Berenger committed
208
    if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
COULAUD Olivier's avatar
COULAUD Olivier committed
209
      set(SCALFMM_CXX_FLAGS  "${SCALFMM_CXX_FLAGS} -ipo  -fstrict-aliasing ")# -no-prec-div -no-prec-sqrt")
BRAMAS Berenger's avatar
BRAMAS Berenger committed
210
    endif()
211 212
    # Compile optimization
    if(APPLE)
213
      set(SCALFMM_FLAGS_OPTI_RELEASE "-funroll-loops" CACHE STRING
214 215 216
        "Set your optimization flags for release mode.")
    else(APPLE)
      # Not apple system - Check the compiler flags
217 218 219 220
      if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
        #set(SCALFMM_FLAGS_OPTI_RELEASE "-fp-model precise -fp-model source -fimf-precision=low  -funroll-loops -ftree-vectorize"
        set(SCALFMM_FLAGS_OPTI_RELEASE "-funroll-loops -ftree-vectorize"
          CACHE STRING "Set your optimization flags for release mode.")
221 222
        # set(SCALFMM_FLAGS_OPTI_RELEASE "-funroll-loops -ftree-vectorize" CACHE STRING
        #   "Set your optimization flags for release mode.")
223 224 225 226 227 228
      else()
        set(SCALFMM_FLAGS_OPTI_RELEASE "-ffast-math -funroll-loops -ftree-vectorize" CACHE STRING
          "Set your optimization flags for release mode.")
      endif()
    endif(APPLE)
    #
229
    set(SCALFMM_CXX_FLAGS  "${SCALFMM_CXX_FLAGS} ${SCALFMM_FLAGS_OPTI_RELEASE}")
230
  endif()
231 232
  MESSAGE(STATUS   " %%%%%%%%%% SCALFMM_CXX_FLAGS  ${SCALFMM_CXX_FLAGS} %%%%%%%%%%%%%")
  MESSAGE(STATUS   " %%%%%%%%%% CMAKE_CXX_FLAGS_RELEASE  ${CMAKE_CXX_FLAGS_RELEASE} %%%%%%%%%%%%%")
COULAUD Olivier's avatar
COULAUD Olivier committed
233
  
234 235 236 237
  #
  ##############################################################################
  #                Attach source code to exec                                  #
  ##############################################################################
238 239
  message(STATUS "SCALFMM_ATTACHE_SOURCE       = ${SCALFMM_ATTACHE_SOURCE}" )
  if( SCALFMM_ATTACHE_SOURCE )
240
    message(STATUS "Option -g is used, the code is attached to the binary." )
241 242
    set(SCALFMM_CXX_FLAGS  "${SCALFMM_CXX_FLAGS} -g")
  endif(SCALFMM_ATTACHE_SOURCE)
243 244 245 246 247
  #
  ##############################################################################
  #                                 find MPI                                   #
  ##############################################################################
  #
248
  if( SCALFMM_USE_MPI )
COULAUD Olivier's avatar
COULAUD Olivier committed
249 250 251
    find_package(MPI REQUIRED)
    if(MPI_FOUND)
      if (MPI_CXX_FOUND)
COULAUD Olivier's avatar
COULAUD Olivier committed
252
#	message("MPI_CXX is in the place")
COULAUD Olivier's avatar
COULAUD Olivier committed
253 254 255 256 257 258 259
	if (MPI_CXX_INCLUDE_PATH)
	  include_directories( ${MPI_CXX_INCLUDE_PATH} )
	endif()
	if (MPI_CXX_COMPILE_FLAGS)
	  set(SCALFMM_CXX_FLAGS "${SCALFMM_CXX_FLAGS} ${MPI_CXX_COMPILE_FLAGS}")
	endif()
	if (MPI_CXX_INCLUDE_PATH)
260
          LIST(APPEND SCALFMM_INCLUDES  "${SCALFMM_INCLUDES};${MPI_CXX_INCLUDE_PATH}")
COULAUD Olivier's avatar
COULAUD Olivier committed
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
	endif()
	if (MPI_CXX_LINK_FLAGS)
	  list(APPEND "CMAKE_EXE_LINKER_FLAGS ${MPI_CXX_LINK_FLAGS}")
	endif()
	if (MPI_CXX_LIBRARIES)
	  set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${MPI_CXX_LIBRARIES}")
	endif()
      else (MPI_CXX_FOUND)
	message(FATAL_ERROR "MPI_CXX is required but was not found. "
	  "Please provide an MPI compiler in your environment."
	  "Note that you can give the path to your MPI installation "
	  "by setting MPI_DIR cmake variable.")
      endif (MPI_CXX_FOUND)	
    else(MPI_FOUND)
    endif(MPI_FOUND)
COULAUD Olivier's avatar
COULAUD Olivier committed
276
  endif( SCALFMM_USE_MPI)
277
  list(APPEND FUSE_LIST "MPI")
278 279 280 281 282
  #
  ##############################################################################
  #                             Blas option                                    #
  ##############################################################################
  #
283
  if( SCALFMM_USE_BLAS )
284 285 286 287
#      if(APPLE) # In order to use QT-creator on macos
#            list(APPEND CMAKE_REQUIRED_INCLUDES $ENV{MKLROOT}/include)
#      endif()

COULAUD Olivier's avatar
COULAUD Olivier committed
288 289 290 291 292 293
    #   include(FortranCInterface)
    #    # Define a Fortran interface file (FCMangle.hpp)
    #   FortranCInterface_HEADER( ${CMAKE_CURRENT_SOURCE_DIR}/Src/FCMangle.hpp
    #                            MACRO_NAMESPACE "PM_"
    #                           SYMBOL_NAMESPACE "PM_"
    #                           SYMBOLS init testPPM:init)
294 295
    message(STATUS "CMAKE_CXX_COMPILER_ID STREQUAL  ${CMAKE_CXX_COMPILER_ID}")

296 297
    option( SCALFMM_USE_MKL_AS_BLAS  "Set to ON to use MKL BLAS/LAPACK" OFF )
    option( SCALFMM_USE_ESSL_AS_BLAS "Set to ON to use ESSL BLAS/LAPACK" OFF )
298

299
    if( SCALFMM_USE_MKL_AS_BLAS )
300
      set(BLA_VENDOR "Intel10_64lp_seq")
301
      find_package(BLAS ) # not REQUIRED
302 303 304 305
      unset(LAPACK_LIBRARIES)
      if (BLAS_LIBRARIES)
        set(BLASLAPACK_LIBRARIES ${BLAS_LIBRARIES})
      endif()
306 307
    elseif(SCALFMM_USE_ESSL_AS_BLAS)
      set(BLA_VENDOR "IBMESSL")
308 309
      find_package(BLAS   QUIET) # not REQUIRED
      find_package(LAPACK QUIET) # not REQUIRED
310 311 312 313 314 315
      if (LAPACK_LIBRARIES)
        set(BLASLAPACK_LIBRARIES "${LAPACK_LIBRARIES}")
      endif()
      if (BLAS_LIBRARIES)
        list(APPEND BLASLAPACK_LIBRARIES ${BLAS_LIBRARIES})
      endif()
316
    elseif(SCALFMM_USE_EXTERNAL_BLAS)
317
      message(STATUS "BLAS SET BY EXTERNAL PROGRAM = ${BLAS_LIBRARIES}")
318
      list(APPEND BLASLAPACK_LIBRARIES "${BLAS_LIBRARIES}")
319
    else()
320 321
      find_package(BLAS)  # not REQUIRED
      find_package(LAPACK)  # not REQUIRED
322 323 324 325 326 327 328
      set(BLASLAPACK_LIBRARIES)
      if (LAPACK_LIBRARIES)
        set(BLASLAPACK_LIBRARIES "${LAPACK_LIBRARIES}")
      endif()
      if (BLAS_LIBRARIES)
        list(APPEND BLASLAPACK_LIBRARIES "${BLAS_LIBRARIES}")
      endif()
329
    endif()
330

331
    if(BLAS_FOUND)
332
      set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${BLASLAPACK_LIBRARIES}")
333 334 335 336 337 338 339 340
      if(BLAS_LIBRARY_DIRS)
        # the RPATH to be used when installing
        list(APPEND CMAKE_INSTALL_RPATH "${BLAS_LIBRARY_DIRS}")
      endif()
      if(LAPACK_FOUND AND LAPACK_LIBRARY_DIRS)
        # the RPATH to be used when installing
        list(APPEND CMAKE_INSTALL_RPATH "${LAPACK_LIBRARY_DIRS}")
      endif()
341
      message (STATUS "check BLAS Fortran mangling")
342
      # add options to let the user be able to force a behavior
343
      option( SCALFMM_BLAS_ADD_     "Set to ON to force calls to BLAS Fortran symbols with _ (ex: dgemm_)"        ON )
344 345 346 347 348 349 350
      option( SCALFMM_BLAS_UPCASE   "Set to ON to force calls to BLAS Fortran symbols in capital (ex: DGEMM)"     OFF )
      option( SCALFMM_BLAS_NOCHANGE "Set to ON to force calls to BLAS Fortran symbols with no change (ex: dgemm)" OFF )
      # if options not changed by user then auto-detection
      if (NOT SCALFMM_BLAS_ADD_ AND NOT SCALFMM_BLAS_UPCASE AND NOT SCALFMM_BLAS_NOCHANGE)
        # give blas libraries and check dgemm symbol
        set(CMAKE_REQUIRED_LIBRARIES "${BLAS_LIBRARIES}")
        check_function_exists(dgemv_ DGEMV_ADD_)
351
        check_function_exists(DGEMV  DGEMV_UPCASE)
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
        check_function_exists(dgemv  DGEMV_NOCHANGE)
        # here we consider that the first kind of symbol found will be the one used
        # current order is: ADD_, UPCASE, NOCHANGE
        if (DGEMV_ADD_)
          set (SCALFMM_BLAS_ADD_     ON)
          set (SCALFMM_BLAS_UPCASE   OFF)
          set (SCALFMM_BLAS_NOCHANGE OFF)
          message (STATUS "BLAS dgemv_ symbol found, SCALFMM_BLAS_ADD_ is ON")
        else (DGEMV_ADD_)
          if (DGEMV_UPCASE)
            set (SCALFMM_BLAS_ADD_     OFF)
            set (SCALFMM_BLAS_UPCASE   ON)
            set (SCALFMM_BLAS_NOCHANGE OFF)
            message (STATUS "BLAS DGEMV symbol found, SCALFMM_BLAS_UPCASE is ON")
          else (DGEMV_UPCASE)
            if (DGEMV_NOCHANGE)
              set (SCALFMM_BLAS_ADD_     OFF)
              set (SCALFMM_BLAS_UPCASE   OFF)
              set (SCALFMM_BLAS_NOCHANGE ON)
              message (STATUS "BLAS dgemv symbol found, SCALFMM_BLAS_NOCHANGE is ON")
            endif (DGEMV_NOCHANGE)
          endif (DGEMV_UPCASE)
        endif (DGEMV_ADD_)
        if ( (NOT DGEMV_ADD_) AND (NOT DGEMV_UPCASE) AND (NOT DGEMV_NOCHANGE) )
          message(FATAL_ERROR "BLAS Fortran mangling is not properly detected - please check your BLAS libraries")
        endif ()
      else  (NOT SCALFMM_BLAS_ADD_ AND NOT SCALFMM_BLAS_UPCASE AND NOT SCALFMM_BLAS_NOCHANGE)
        if (SCALFMM_BLAS_ADD_)
          message (STATUS "SCALFMM_BLAS_ADD_ is set to ON")
        endif()
        if (SCALFMM_BLAS_UPCASE)
          message (STATUS "SCALFMM_BLAS_UPCASE is set to ON")
        endif()
        if (SCALFMM_BLAS_NOCHANGE)
          message (STATUS "SCALFMM_BLAS_NOCHANGE is set to ON")
        endif()
      endif (NOT SCALFMM_BLAS_ADD_ AND NOT SCALFMM_BLAS_UPCASE AND NOT SCALFMM_BLAS_NOCHANGE)
389
    else()
390 391
      MESSAGE(WARNING "BLAS: ${BLAS-FOUND}") 

392
      message(WARNING "BLAS has not been found, SCALFMM will continue to compile but some applications will be disabled.")
393
      message(WARNING "If you have BLAS set BLAS_LIBDIR, BLAS_INCDIR or BLAS_DIR (CMake variables using -D or environment variables).")
COULAUD Olivier's avatar
COULAUD Olivier committed
394
      set(SCALFMM_USE_BLAS OFF)
395
    endif()
396

397
  endif(SCALFMM_USE_BLAS)
398
  list(APPEND FUSE_LIST "BLAS")
399 400 401
  #
  # FFT option
  #
402
  CMAKE_DEPENDENT_OPTION(SCALFMM_USE_MKL_AS_FFTW  "Set to ON to use MKL FFTW"  ON  "SCALFMM_USE_FFT;SCALFMM_USE_MKL_AS_BLAS"  OFF )
403
  CMAKE_DEPENDENT_OPTION(SCALFMM_USE_ESSL_AS_FFTW "Set to ON to use ESSL FFTW" ON  "SCALFMM_USE_FFT;SCALFMM_USE_ESSL_AS_BLAS" OFF )
404
  if( SCALFMM_USE_FFT )
405 406
    message(STATUS "SCALFMM USE FFT Configure:")

407 408 409
    # The package find_package(FFTW) can be used with the following COMPONENTS:
    # MKL, ESSL, THREADS|OMP and/or SIMPLE|LONG|QUAD
    # Default will find the real double precision fftw library version without THREADS|OMP
410
    if( SCALFMM_USE_MKL_AS_FFTW )
411

412 413 414
      message(STATUS "         SCALFMM USE FFT from MKL")
      find_package(FFTW COMPONENTS MKL)
    elseif (SCALFMM_USE_ESSL_AS_FFTW)
415 416 417
      message(STATUS "         SCALFMM USE FFT from ESSL ")
      find_package(FFTW COMPONENTS ESSL)
      add_definitions(-DSCALFMM_USE_ESSL_AS_FFTW)
418
    else()
419 420
      message(STATUS "         SCALFMM USE FFTW")
      find_package(FFTW COMPONENTS SIMPLE)
421
    endif()
422

COULAUD Olivier's avatar
COULAUD Olivier committed
423 424 425 426 427 428 429 430 431
    if(FFTW_FOUND)
      if (FFTW_LIBRARY_DIRS_DEP)
	set(FFT_LIBRARIES "-L${FFTW_LIBRARY_DIRS_DEP};" CACHE STRING "Set your MKL flags")
      endif()
      if (FFTW_LIBRARIES_DEP)
	foreach (fft_lib ${FFTW_LIBRARIES_DEP})
          set(FFT_LIBRARIES "${FFT_LIBRARIES};${fft_lib};")
	endforeach()
      endif()
432

COULAUD Olivier's avatar
COULAUD Olivier committed
433 434 435 436
      set(FFT_INCLUDES "${FFTW_INCLUDE_DIRS_DEP}" )
      if (FFT_LIBRARIES)
	set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${FFT_LIBRARIES}")
      endif()
437

COULAUD Olivier's avatar
COULAUD Olivier committed
438 439 440 441 442
      if(FFTW_LIBRARY_DIRS)
	# the RPATH to be used when installing
	list(APPEND CMAKE_INSTALL_RPATH "${FFTW_LIBRARY_DIRS}")
      endif()
      if (FFT_INCLUDES)
443
        LIST(APPEND SCALFMM_INCLUDES "${FFT_INCLUDES}")
COULAUD Olivier's avatar
COULAUD Olivier committed
444 445
      endif()
    else(FFTW_FOUND)
446
      message(WARNING "FFTW has not been found, SCALFMM will continue to compile but some applications will be disabled.")
447
      message(WARNING "If you have FFTW set FFTW_LIBDIR, FFTW_INCDIR or FFTW_DIR (CMake variables using -D or environment variables).")
448
      set(SCALFMM_USE_FFT OFF)
COULAUD Olivier's avatar
COULAUD Olivier committed
449
    endif(FFTW_FOUND)
450

451
  endif(SCALFMM_USE_FFT)
COULAUD Olivier's avatar
COULAUD Olivier committed
452
  message(STATUS "SCALFMM_USE_FFT       =  ${SCALFMM_USE_FFT}")
453 454 455 456 457 458
  if (SCALFMM_INCLUDES)
    list(REMOVE_DUPLICATES SCALFMM_INCLUDES)
  endif()
  if (SCALFMM_LIBRARIES)
    list(REMOVE_DUPLICATES SCALFMM_LIBRARIES)
  endif()
459
  list(APPEND FUSE_LIST "FFT")
460 461 462 463 464 465 466

  #
  # C++ 2011
  message( STATUS "CMAKE_SYSTEM:   ${CMAKE_SYSTEM}  CMAKE_CXX_COMPILER_ID ${CMAKE_CXX_COMPILER_ID}  CMAKE_CXX_COMPILER ${NAME}")
  if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
    execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE INTEL_VERSION)
    message( STATUS "Intel:   ${INTEL_VERSION}")
467
    set(SCALFMM_CXX_FLAGS "${SCALFMM_CXX_FLAGS} -Wall")
468 469
  else()
    # Compile option valid on GCC/G++
470
    set(SCALFMM_CXX_FLAGS "${SCALFMM_CXX_FLAGS} -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wconversion -Wcast-qual -Wcast-align -Woverloaded-virtual")
471
  endif()
472 473
  #
  ##################################################################
COULAUD Olivier's avatar
COULAUD Olivier committed
474
  #              STARPU Section
475 476
  ##################################################################
  #
477 478
  message( STATUS "SCALFMM_USE_STARPU             = ${SCALFMM_USE_STARPU}" )
  if( SCALFMM_USE_STARPU )
479
    # CUDA could be used with StarPU enabled
480 481
    option( SCALFMM_USE_CUDA "Set to ON to use CUDA with StarPU" OFF )
    if(SCALFMM_USE_CUDA)
482 483 484 485 486
      execute_process(COMMAND nvcc --version ERROR_VARIABLE cuda_error_output OUTPUT_QUIET)
      if(cuda_error_output)
        message( FATAL_ERROR "nvcc is needed with CUDA." )
      endif()
      if(NOT DEFINED CUSTOM_CUDA_FLAGS)
487 488
        set( CUSTOM_CUDA_FLAGS "-std=c++11;-arch=sm_20;--ptxas-options=-v;-use_fast_math" CACHE
          STRING "Set your CUDA flags, for example : -arch=sm_20;--ptxas-options=-v;-use_fast_math")
489 490 491 492 493
      endif()
      # This is needed to remove backslash after space in ADD_CUSTOM_COMMAND
      separate_arguments(CUSTOM_CUDA_FLAGS)
      message( STATUS "CUSTOM_CUDA_FLAGS             = ${CUSTOM_CUDA_FLAGS}" )
      find_package(CUDA REQUIRED)
494

495 496 497 498 499 500
      if (CUDA_INCLUDE_DIRS)
        include_directories(${CUDA_INCLUDE_DIRS})
      endif()
      if (CUDA_LIBRARIES)
        set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${CUDA_LIBRARIES}")
      endif()
501

502
      set(CUDA_NEEDED_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/Src)
503 504 505
    endif()

    # Find StarPU with a list of optional components
COULAUD Olivier's avatar
COULAUD Olivier committed
506
    set(SCALFMM_STARPU_VERSION "1.2" CACHE STRING " STARPU version desired")
507 508
    # create list of components in order to make a single call to find_package(starpu...)
    set(STARPU_COMPONENT_LIST "HWLOC")
COULAUD Olivier's avatar
COULAUD Olivier committed
509 510

    
511
    if(SCALFMM_USE_CUDA)
512
      list(APPEND STARPU_COMPONENT_LIST "CUDA")
513
    endif()
514
    list(APPEND FUSE_LIST "CUDA")   
515

COULAUD Olivier's avatar
COULAUD Olivier committed
516 517 518
    if(SCALFMM_USE_MPI)
      list(APPEND STARPU_COMPONENT_LIST "MPI")
    endif()
COULAUD Olivier's avatar
COULAUD Olivier committed
519 520 521 522 523 524 525 526
    # TODO: replace this by a component of find starpu
    OPTION( SCALFMM_USE_OPENCL      "Set to ON to use OPENCL with StarPU" OFF )

    if(SCALFMM_USE_OPENCL)
      list(APPEND STARPU_COMPONENT_LIST "OPENCL")  
#      include_directories($ENV{OPENCL_INC})
#      SET(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};-L$ENV{OPENCL_LIB};-lOpenCL")
    endif()
527
    list(APPEND FUSE_LIST "OPENCL")
COULAUD Olivier's avatar
COULAUD Olivier committed
528 529


530
    find_package(STARPU ${SCALFMM_STARPU_VERSION} REQUIRED
531
      COMPONENTS ${STARPU_COMPONENT_LIST})
532

533 534 535 536
    if(HWLOC_FOUND AND HWLOC_LIBRARY_DIRS)
      # the RPATH to be used when installing
      list(APPEND CMAKE_INSTALL_RPATH "${HWLOC_LIBRARY_DIRS}")
    endif()
COULAUD Olivier's avatar
COULAUD Olivier committed
537

538 539 540 541 542 543 544
    if(FXT_FOUND AND FXT_LIBRARY_DIRS)
      # the RPATH to be used when installing
      list(APPEND CMAKE_INSTALL_RPATH "${FXT_LIBRARY_DIRS}")
    endif()
    if(STARPU_FOUND AND STARPU_LIBRARY_DIRS)
      # the RPATH to be used when installing
      list(APPEND CMAKE_INSTALL_RPATH "${STARPU_LIBRARY_DIRS}")
COULAUD Olivier's avatar
COULAUD Olivier committed
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
      # Append list of libraries and include dirs
      include_directories(${STARPU_INCLUDE_DIRS_DEP})
      foreach (starpu_libdir ${STARPU_LIBRARY_DIRS_DEP})
	if (${starpu_libdir} MATCHES "^ *-L")
          set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${starpu_libdir}")
	else()
          set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};-L${starpu_libdir}")
	endif()
      endforeach()
      foreach (starpu_lib ${STARPU_LIBRARIES_DEP})
	if (EXISTS ${starpu_lib} OR ${starpu_lib} MATCHES "^ *-")
          set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${starpu_lib}")
	else()
          set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};-l${starpu_lib}")
	endif()
      endforeach()
    else()
COULAUD Olivier's avatar
COULAUD Olivier committed
562
      # StarPU not found
COULAUD Olivier's avatar
COULAUD Olivier committed
563 564

    endif()
565

COULAUD Olivier's avatar
COULAUD Olivier committed
566
        # TODO: is this very useful? CUDA is already a component of find starpu
567
    if (CUDA_LIBRARIES)
568
      set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${CUDA_LIBRARIES}")
569
    endif()
570

571
    # Message
572
    if (STARPU_INCLUDE_DIRS)
573
      message(STATUS "         STARPU_INCLUDES           = ${STARPU_INCLUDE_DIRS}")
574
      LIST(APPEND SCALFMM_INCLUDES  "${STARPU_INCLUDE_DIRS}")
575
    endif()
576

577
    # Adding SimGrid includes
578
    LIST(APPEND SCALFMM_INCLUDES "$ENV{SIMGRID_INCLUDE}")
579
    message(STATUS "         Adding SIMGRID           = $ENV{SIMGRID_INCLUDE}")
580
  endif(SCALFMM_USE_STARPU)
581
  list(APPEND FUSE_LIST "STARPU")
582

583
  ##################################################################
Berenger Bramas's avatar
Berenger Bramas committed
584
  #                         FUSE                                   #
585 586
  ##################################################################

587 588
  list(APPEND FUSE_LIST "SSE")
  list(APPEND FUSE_LIST "AVX")
Berenger Bramas's avatar
Berenger Bramas committed
589
  list(APPEND FUSE_LIST "MIC")
590

591 592
  ##################################################################
  #
COULAUD Olivier's avatar
COULAUD Olivier committed
593 594
  #   Set EZTRACE
  #
595
  ##################################################################
COULAUD Olivier's avatar
COULAUD Olivier committed
596 597 598 599
  If(SCALFMM_USE_EZTRACE)
    find_package (PkgConfig)
    if(PKG_CONFIG_FOUND)
      set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH "ON")
600
      pkg_search_module( EZTrace REQUIRED eztrace)
COULAUD Olivier's avatar
COULAUD Olivier committed
601
      if(EZTrace_FOUND)
602 603
        link_directories(${EZTrace_LIBRARY_DIRS})
        link_libraries( ${EZTrace_LIBRARIES})
604 605 606 607
        if (EZTrace_LIBRARY_DIRS)
          # the RPATH to be used when installing
          list(APPEND CMAKE_INSTALL_RPATH "${EZTrace_LIBRARY_DIRS}")
        endif()
608
        IF( SCALFMM_USE_MPI )
COULAUD Olivier's avatar
COULAUD Olivier committed
609
          link_libraries(-leztrace-autostart-mpi)
610 611 612 613 614 615 616 617 618
        ENDIF(SCALFMM_USE_MPI)
        include_directories(${EZTrace_INCLUDE_DIRS})
        MESSAGE(STATUS "EZTRACE:  ${EZTrace_INCLUDE_DIRS}   ${EZTrace_LIBRARY_DIRS}  ${EZTrace_LIBRARIES}")
        CMAKE_DEPENDENT_OPTION(SCALFMM_TRACE_ALGO "Set to ON to trace the full algorithm (all operators)" ON  "SCALFMM_USE_EZTRACE" OFF )
        CMAKE_DEPENDENT_OPTION(SCALFMM_TRACE_P2M   "Set to ON to trace P2M operator" OFF  "SCALFMM_USE_EZTRACE" OFF )
        CMAKE_DEPENDENT_OPTION(SCALFMM_TRACE_M2M   "Set to ON to trace M2M operator" OFF  "SCALFMM_USE_EZTRACE" OFF )
        CMAKE_DEPENDENT_OPTION(SCALFMM_TRACE_M2L   "Set to ON to trace M2L operator" OFF  "SCALFMM_USE_EZTRACE" OFF )
        CMAKE_DEPENDENT_OPTION(SCALFMM_TRACE_L2L   "Set to ON to trace L2L operator" OFF  "SCALFMM_USE_EZTRACE" OFF )
        CMAKE_DEPENDENT_OPTION(SCALFMM_TRACE_P2P   "Set to ON to trace P2P operator" OFF  "SCALFMM_USE_EZTRACE" OFF )
619
      else(EZTrace_FOUND)
620 621
        MESSAGE(WARNING "Eztrace not found - EZTRACE Is set to OFF")
        set(SCALFMM_USE_EZTRACE OFF)
622
      endif(EZTrace_FOUND)
COULAUD Olivier's avatar
COULAUD Olivier committed
623
    else(PKG_CONFIG_FOUND)
624
      MESSAGE(WARNING "PKG-CONFIG not found - EZTRACE Is set to OFF")
COULAUD Olivier's avatar
COULAUD Olivier committed
625 626 627 628
      set(SCALFMM_USE_EZTRACE OFF)
    endif(PKG_CONFIG_FOUND)

  endif(SCALFMM_USE_EZTRACE)
629

630
  list(APPEND FUSE_LIST "OMP4")
COULAUD Olivier's avatar
COULAUD Olivier committed
631

632 633 634 635
  ##################################################################
  #
  #   To catch signals
  #
636
  ##################################################################
637 638 639 640 641 642 643 644
  if((WIN32 OR (${CMAKE_SYSTEM_NAME} MATCHES "Windows")) AND SCALFMM_USE_SIGNALS)
    # We are on Windows and we cannot catch signals
    message( FATAL_ERROR "Catching the signals requieres an UNIX system." )
  else()
    IF( NOT APPLE)
      SET(SCALFMM_CXX_FLAGS "${SCALFMM_CXX_FLAGS} -rdynamic")
    ENDIF()
  endif()
645 646 647 648 649 650 651 652
  ##################################################################
  #                                                                #
  #                     END SETTING VARIABLES                      #
  #                                                                #
  ##################################################################
  #
  # Generate  ScalFmmConfig.h
  #
653
  set(SCALFMM_COMPILE_FLAGS "${SCALFMM_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
654
  set(CMAKE_CXX_FLAGS "${SCALFMM_COMPILE_FLAGS}")
655 656 657
  # We need the libraries without spaces (inside the config file)
  set(SCALFMM_COMPILE_LIBS   "")
  foreach(lib_var ${SCALFMM_LIBRARIES})
658
    string(STRIP ${lib_var} lib_var)
659
    LIST(APPEND SCALFMM_COMPILE_LIBS   ${lib_var})
660
  endforeach()
661 662
  string(REPLACE " " ";" SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}")
  string(REPLACE ";;" ";" SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}")
663 664
#  string(REPLACE " " ";" SCALFMM_INCLUDES "${SCALFMM_INCLUDES}")
#  string(REPLACE ";;" ";" SCALFMM_INCLUDES "${SCALFMM_INCLUDES}")
665
  configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Src/ScalFmmConfig.h.cmake
666
    ${CMAKE_CURRENT_BINARY_DIR}/Src/ScalFmmConfig.h  )
667 668 669 670 671
  #
  ##################################################################
  #                      Build - lib                               #
  ##################################################################
  #
672
  MESSAGE(STATUS "FUSE : ${FUSE_LIST} ")
673
  add_subdirectory(Contribs)
674 675 676 677 678 679 680
  add_subdirectory(Src)
  # Link with scalfmm lib
  set(scalfmm_lib scalfmm)
  #
  ##################################################################
  #            Remove compilation  of the drivers                  #
  ##################################################################
681
  message(STATUS "SCALFMM_BUILD_EXAMPLES  =  ${SCALFMM_BUILD_EXAMPLES}" )
682
  if( SCALFMM_BUILD_EXAMPLES )
683 684 685 686 687 688 689
    # Build - Examples and drivers
    add_subdirectory(Examples)
  endif()
  ##################################################################
  #           Build tools (Internal use)                           #
  ##################################################################
  # Build - UTILs
690
  if( SCALFMM_ONLY_DEVEL AND SCALFMM_BUILD_UTILS)
691
    add_subdirectory(Utils)
692
  endif()
693

694 695 696 697
  ##################################################################
  #                Build -Tests to see examples                    #
  ##################################################################
  # Build - Tests
698 699
  message( STATUS "SCALFMM_BUILD_TESTS          = ${SCALFMM_BUILD_TESTS}" )
  if( SCALFMM_BUILD_TESTS )
700 701
    add_subdirectory(Tests)
  endif()
berenger-bramas's avatar
berenger-bramas committed
702

703 704 705 706
  ##################################################################
  #              Build - Unitary and numerical Tests               #
  ##################################################################
  #
707 708
  message( STATUS "SCALFMM_BUILD_UTESTS         = ${SCALFMM_BUILD_UTESTS}" )
  if( SCALFMM_BUILD_UTESTS )
709 710 711 712
    include(CTest)
    enable_testing()
    add_subdirectory(UTests)
  endif()
713
  #
714 715 716
  ##################################################################
  #                           Add - doc                            #
  ##################################################################
717
  #
718
  message(STATUS "SCALFMM_BUILD_DOC           =  ${SCALFMM_BUILD_DOC}" )
719 720 721
  if(SCALFMM_BUILD_DOC)
    add_subdirectory(Doc)
  endif()
722
  #
723 724 725 726
  ##################################################################
  #                       Build - Addons                           #
  ##################################################################
  #
727 728 729 730 731 732 733 734 735 736
  #   SCALFMM_ADDON_CKERNELAPI doesn't works with scalfmm 2.0
#  if( SCALFMM_USE_ADDONS )
#    file(GLOB all_addons ./Addons/*)
#    # Options
#    option( SCALFMM_ADDON_CKERNELAPI "Set to ON to build ScaFMM FMM API interface" OFF )
#    foreach(addon_name ${all_addons})
#      message(STATUS "Addons += ${addon_name}" )
#      add_subdirectory(${addon_name})
#    endforeach()
#  endif()
737

738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
  # Add custom clean command
  if("${CMAKE_GENERATOR}" MATCHES "Make")
    add_custom_target(reset
      COMMAND ${CMAKE_MAKE_PROGRAM} clean && rm -r ./CMake* && cmake ..
      WORKING_DIRECTORY ${CMAKE_CURRENT_DIR}
      COMMENT "Cleaning Build dir and CMake cache, then do cmake.."
      )
  endif()
  #
  ##################################################################
  #                                                                #
  #                  Build and export cmake files                  #
  #                                                                #
  ##################################################################
  #
753 754 755
  message(STATUS "SCALFMM_BINARY_DIR:          " ${SCALFMM_BINARY_DIR})
  configure_file(${SCALFMM_SOURCE_DIR}/ScalFMMConfig.cmake.in
    ${SCALFMM_BINARY_DIR}/ScalFMMConfig.cmake
756 757 758
    @ONLY IMMEDIATE
    )
  #
759 760 761
  install(FILES  ${SCALFMM_BINARY_DIR}/ScalFMMConfig.cmake  DESTINATION lib/  )
  if( SCALFMM_INSTALL_DATA )
    install(FILES  ${SCALFMM_SOURCE_DIR}/Data/test20k.fma  DESTINATION Data/   )
762
  endif()
763
  #
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780
  ##################################################################
  #                                                                #
  #              build a CPack driven installer package            #
  #                                                                #
  ##################################################################
  #
  # Use git commit number as CPACK_PACKAGE_VERSION_PATCH
  set(CPACK_PACKAGE_VERSION_PATCH 0)
  execute_process(
    COMMAND git rev-list HEAD --count
    OUTPUT_VARIABLE CPACK_PACKAGE_VERSION_PATCH
    RESULT_VARIABLE RET
    ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
    )
  #string_TRIM(PATCH1 PATCH)
  set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY "ON")
  #
781
  set(CPACK_RESOURCE_FILE_LICENSE  "${CMAKE_CURRENT_SOURCE_DIR}/LICENCE")
782 783
  set(CPACK_PACKAGE_VERSION_MAJOR "${SCALFMM_MAJOR_VERSION}")
  set(CPACK_PACKAGE_VERSION_MINOR "${SCALFMM_MINOR_VERSION}")
784
  #
785
  set(PACK_PACKAGE_VERSION "${SCALFMM_MAJOR_VERSION}.${SCALFMM_MINOR_VERSION}-${CPACK_PACKAGE_VERSION_PATCH}")
786
  set(CPACK_SOURCE_GENERATOR "TGZ")
787
  set(CPACK_SOURCE_PACKAGE_FILE_NAME  "SCALFMM-${SCALFMM_MAJOR_VERSION}.${SCALFMM_MINOR_VERSION}-${CPACK_PACKAGE_VERSION_PATCH}")
788 789
  set(CPACK_SOURCE_IGNORE_FILES "\\\\.git;.DS_Store;.*~;/*.aux;/*.idx;/*.log;/*.out;/*.toc;/*.ilg;CMakeLists.txt.user;/.settings/")
  list(APPEND CPACK_SOURCE_IGNORE_FILES  "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/Utils/;/Build*;/Obsolete/")
790 791 792 793 794 795 796 797 798
  #
  include(CPack)
  #
  #
  ##################################################################
  #                                                                #
  #                      PRINT messages                            #
  #                                                                #
  ##################################################################
799
  message(STATUS "CPACK_SOURCE_IGNORE_FILES      = ${CPACK_SOURCE_IGNORE_FILES}")
800 801 802
  message(STATUS "CPACK_SOURCE_PACKAGE_FILE_NAME = ${CPACK_SOURCE_PACKAGE_FILE_NAME}")
  #
  #                    Use Mem stats
803
  message(STATUS "SCALFMM_USE_MEM_STATS = ${SCALFMM_USE_MEM_STATS}" )
804
  #                    Use Log
805
  message(STATUS "SCALFMM_USE_LOG       = ${SCALFMM_USE_LOG}" )
806
  #                    Use Assert
807
  message(STATUS "SCALFMM_USE_ASSERT    = ${SCALFMM_USE_ASSERT}" )
808
  #
COULAUD Olivier's avatar
COULAUD Olivier committed
809 810 811 812 813 814
  message(STATUS "SCALFMM_USE_MPI       = ${SCALFMM_USE_MPI}" )

  message(STATUS "SCALFMM_USE_BLAS      = ${SCALFMM_USE_BLAS}")
  message(STATUS "SCALFMM_USE_FFT       = ${SCALFMM_USE_FFT}")
  message(STATUS "SCALFMM_USE_MKL       =  ${SCALFMM_USE_MKL}")
  #
COULAUD Olivier's avatar
COULAUD Olivier committed
815 816 817 818 819 820
  if(SCALFMM_USE_STARPU)
    message( STATUS "SCALFMM_USE_STARPU             = ${SCALFMM_USE_STARPU}" )
    message(STATUS "     STARPU_LIBRARIES           = ${STARPU_LIBRARIES}")
    message( STATUS "SCALFMM_USE_CUDA               = ${SCALFMM_USE_CUDA}" )
    MESSAGE( STATUS "SCALFMM_USE_OPENCL             = ${SCALFMM_USE_OPENCL}" )
  endif(SCALFMM_USE_STARPU)
COULAUD Olivier's avatar
COULAUD Olivier committed
821 822 823 824 825 826
  message(STATUS "CMAKE_CXX_FLAGS_TYPE  = ${CMAKE_CXX_FLAGS_TYPE}")
  message(STATUS "CMAKE_CXX_FLAGS       = ${CMAKE_CXX_FLAGS}")
  message(STATUS "SCALFMM_CXX_FLAGS     = ${SCALFMM_CXX_FLAGS}")
  message(STATUS "SCALFMM_LIBRARIES     = ${SCALFMM_LIBRARIES}")
  message(STATUS "SCALFMM_INCLUDES      = ${SCALFMM_INCLUDES}")
  message(STATUS "FUSE_LIST             = ${FUSE_LIST}")
827
  #
828 829 830
  ##################################################################
  #                               END                              #
  ##################################################################
831
  #
832
else(MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse_cmake")
833 834 835 836 837 838 839

  message(STATUS "MORSE_DISTRIB_DIR is not set")
  message(STATUS "Please indicate where is located your MORSE distribution directory."
    " This is necessary to find cmake_modules.")
  message(STATUS "If you are a MORSE developer, you normally have access to the svn repository of the MORSE_DISTRIB_DIR: "
    "svn checkout svn+ssh://yourlogin@scm.gforge.inria.fr/svnroot/morse/trunk/morse_distrib")

840
endif(MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse_cmake")