CMakeLists.txt 37.4 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)
Florent Pruvost's avatar
Florent Pruvost committed
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/)
COULAUD Olivier's avatar
COULAUD Olivier committed
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
BRAMAS Berenger's avatar
BRAMAS Berenger committed
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
104
    CMAKE_DEPENDENT_OPTION(OPENMP_SUPPORT_COMMUTE        "Set to ON to let tasks commute (KSTAR/StarPU compiler only)" OFF
COULAUD Olivier's avatar
COULAUD Olivier committed
105 106 107
      "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}
COULAUD Olivier's avatar
COULAUD Olivier committed
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
  #
  #
  # Test if openmp is here
  #
  find_package (OpenMP)
  if(OPENMP_FOUND)
137 138
    set(CMAKE_C_FLAGS          "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS        "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
139 140 141 142
    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
  ##############################################################################
Philippe Virouleau's avatar
Philippe Virouleau committed
151

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

166 167 168
  ##############################################################################
  #                           FUSE list                                        #
  ##############################################################################
COULAUD Olivier's avatar
COULAUD Olivier committed
169 170
  set(FUSE_LIST "")
  #set(FUSE_LIST " MPI;BLAS;FFT;STARPU;CUDA;OPENCL;OMP4;SSE;AVX;AVX2;MIC;MPI2")
171
  # then do list(APPEND FUSE_LIST "BLAS") to protect from FUSE_BLAS
COULAUD Olivier's avatar
COULAUD Olivier committed
172
  #  list(APPEND FUSE_LIST "MPI")
173

174 175 176 177
  ##############################################################################
  #                        Debug      flags                                    #
  ##############################################################################
  #
178
  if( SCALFMM_BUILD_DEBUG )
179 180 181 182 183 184
    #
    # Compile Debug flags
    #
    set(CMAKE_BUILD_TYPE Debug)
    ADD_DEFINITIONS(-O0)
    if( APPLE )
185
      set(SCALFMM_FLAGS_OPTI_DEBUG "-funroll-loops" CACHE STRING
186 187 188 189 190 191 192 193 194 195 196
        "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})
197
    set(SCALFMM_CXX_FLAGS "${SCALFMM_CXX_FLAGS} ${SCALFMM_FLAGS_OPTI_DEBUG}")
198
    set(CMAKE_CXX_FLAGS_TYPE "${CMAKE_CXX_FLAGS_DEBUG}")
199

200 201 202 203
  else()
    ##############################################################################
    #                          Release flags                                     #
    ##############################################################################
204

205 206 207
    set(CMAKE_BUILD_TYPE Release)
    set(CMAKE_CXX_FLAGS_TYPE  "${CMAKE_CXX_FLAGS_RELEASE}")
    # if compiler is intel add -ip
208

BRAMAS Berenger's avatar
BRAMAS Berenger committed
209
    if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
COULAUD Olivier's avatar
COULAUD Olivier committed
210
      set(SCALFMM_CXX_FLAGS  "${SCALFMM_CXX_FLAGS} -ipo  -fstrict-aliasing ")# -no-prec-div -no-prec-sqrt")
BRAMAS Berenger's avatar
BRAMAS Berenger committed
211
    endif()
212 213
    # Compile optimization
    if(APPLE)
214
      set(SCALFMM_FLAGS_OPTI_RELEASE "-funroll-loops" CACHE STRING
215 216 217
        "Set your optimization flags for release mode.")
    else(APPLE)
      # Not apple system - Check the compiler flags
COULAUD Olivier's avatar
COULAUD Olivier committed
218 219 220 221
      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.")
222 223
        # set(SCALFMM_FLAGS_OPTI_RELEASE "-funroll-loops -ftree-vectorize" CACHE STRING
        #   "Set your optimization flags for release mode.")
224 225 226 227 228 229
      else()
        set(SCALFMM_FLAGS_OPTI_RELEASE "-ffast-math -funroll-loops -ftree-vectorize" CACHE STRING
          "Set your optimization flags for release mode.")
      endif()
    endif(APPLE)
    #
230
    set(SCALFMM_CXX_FLAGS  "${SCALFMM_CXX_FLAGS} ${SCALFMM_FLAGS_OPTI_RELEASE}")
231
  endif()
COULAUD Olivier's avatar
COULAUD Olivier committed
232 233
  MESSAGE(STATUS   " %%%%%%%%%% SCALFMM_CXX_FLAGS  ${SCALFMM_CXX_FLAGS} %%%%%%%%%%%%%")
  MESSAGE(STATUS   " %%%%%%%%%% CMAKE_CXX_FLAGS_RELEASE  ${CMAKE_CXX_FLAGS_RELEASE} %%%%%%%%%%%%%")
234

235 236 237 238
  #
  ##############################################################################
  #                Attach source code to exec                                  #
  ##############################################################################
239 240
  message(STATUS "SCALFMM_ATTACHE_SOURCE       = ${SCALFMM_ATTACHE_SOURCE}" )
  if( SCALFMM_ATTACHE_SOURCE )
241
    message(STATUS "Option -g is used, the code is attached to the binary." )
242 243
    set(SCALFMM_CXX_FLAGS  "${SCALFMM_CXX_FLAGS} -g")
  endif(SCALFMM_ATTACHE_SOURCE)
244 245 246 247 248
  #
  ##############################################################################
  #                                 find MPI                                   #
  ##############################################################################
  #
249
  if( SCALFMM_USE_MPI )
COULAUD Olivier's avatar
COULAUD Olivier committed
250 251 252
    find_package(MPI REQUIRED)
    if(MPI_FOUND)
      if (MPI_CXX_FOUND)
COULAUD Olivier's avatar
COULAUD Olivier committed
253
#	message("MPI_CXX is in the place")
254 255 256 257 258 259 260 261
        if (MPI_CXX_INCLUDE_PATH)
          include_directories( ${MPI_CXX_INCLUDE_PATH} )
        endif()
        if (MPI_CXX_COMPILE_FLAGS)
          string(REPLACE ";" " " MPI_CXX_COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}")
          set(SCALFMM_CXX_FLAGS "${SCALFMM_CXX_FLAGS} ${MPI_CXX_COMPILE_FLAGS}")
        endif()
        if (MPI_CXX_INCLUDE_PATH)
COULAUD Olivier's avatar
COULAUD Olivier committed
262
          LIST(APPEND SCALFMM_INCLUDES  "${SCALFMM_INCLUDES};${MPI_CXX_INCLUDE_PATH}")
263 264 265 266 267 268 269
        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()
COULAUD Olivier's avatar
COULAUD Olivier committed
270
      else (MPI_CXX_FOUND)
271 272 273 274 275
        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)
COULAUD Olivier's avatar
COULAUD Olivier committed
276 277
    else(MPI_FOUND)
    endif(MPI_FOUND)
COULAUD Olivier's avatar
COULAUD Olivier committed
278
  endif( SCALFMM_USE_MPI)
279
  list(APPEND FUSE_LIST "MPI")
280 281 282 283 284
  #
  ##############################################################################
  #                             Blas option                                    #
  ##############################################################################
  #
285
  if( SCALFMM_USE_BLAS )
286 287 288 289
#      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
290 291 292 293 294 295
    #   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)
296 297
    message(STATUS "CMAKE_CXX_COMPILER_ID STREQUAL  ${CMAKE_CXX_COMPILER_ID}")

298 299
    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 )
300

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

333
    if(BLAS_FOUND)
COULAUD Olivier's avatar
COULAUD Olivier committed
334
      set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${BLASLAPACK_LIBRARIES}")
335 336 337 338 339 340 341 342
      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()
343
      message (STATUS "check BLAS Fortran mangling")
344
      # add options to let the user be able to force a behavior
345
      option( SCALFMM_BLAS_ADD_     "Set to ON to force calls to BLAS Fortran symbols with _ (ex: dgemm_)"        ON )
346 347 348 349 350 351 352
      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_)
353
        check_function_exists(DGEMV  DGEMV_UPCASE)
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 389 390
        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)
391
    else()
392
      MESSAGE(WARNING "BLAS: ${BLAS-FOUND}")
393

COULAUD Olivier's avatar
COULAUD Olivier committed
394
      message(WARNING "BLAS has not been found, SCALFMM will continue to compile but some applications will be disabled.")
395
      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
396
      set(SCALFMM_USE_BLAS OFF)
397
    endif()
398

399
  endif(SCALFMM_USE_BLAS)
400
  list(APPEND FUSE_LIST "BLAS")
401 402 403
  #
  # FFT option
  #
404
  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 )
405
  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 )
406
  if( SCALFMM_USE_FFT )
407 408
    message(STATUS "SCALFMM USE FFT Configure:")

409 410 411
    # 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
412
    if( SCALFMM_USE_MKL_AS_FFTW )
413

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

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

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

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

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

  #
  # 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}")
469
    set(SCALFMM_CXX_FLAGS "${SCALFMM_CXX_FLAGS} -Wall")
470 471
  else()
    # Compile option valid on GCC/G++
472
    set(SCALFMM_CXX_FLAGS "${SCALFMM_CXX_FLAGS} -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wconversion -Wcast-qual -Wcast-align -Woverloaded-virtual")
473
  endif()
474 475
  #
  ##################################################################
COULAUD Olivier's avatar
??  
COULAUD Olivier committed
476
  #              STARPU Section
477 478
  ##################################################################
  #
479 480
  message( STATUS "SCALFMM_USE_STARPU             = ${SCALFMM_USE_STARPU}" )
  if( SCALFMM_USE_STARPU )
481
    # CUDA could be used with StarPU enabled
482 483
    option( SCALFMM_USE_CUDA "Set to ON to use CUDA with StarPU" OFF )
    if(SCALFMM_USE_CUDA)
COULAUD Olivier's avatar
COULAUD Olivier committed
484 485 486 487 488
      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)
489 490
        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")
COULAUD Olivier's avatar
COULAUD Olivier committed
491 492 493 494 495
      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)
496

COULAUD Olivier's avatar
COULAUD Olivier committed
497 498 499 500 501 502
      if (CUDA_INCLUDE_DIRS)
        include_directories(${CUDA_INCLUDE_DIRS})
      endif()
      if (CUDA_LIBRARIES)
        set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${CUDA_LIBRARIES}")
      endif()
503

504
      set(CUDA_NEEDED_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/Src)
505 506 507
    endif()

    # Find StarPU with a list of optional components
COULAUD Olivier's avatar
COULAUD Olivier committed
508
    set(SCALFMM_STARPU_VERSION "1.2" CACHE STRING " STARPU version desired")
509 510
    # 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
511

512

513
    if(SCALFMM_USE_CUDA)
COULAUD Olivier's avatar
COULAUD Olivier committed
514
      list(APPEND STARPU_COMPONENT_LIST "CUDA")
515
    endif()
516
    list(APPEND FUSE_LIST "CUDA")
517

COULAUD Olivier's avatar
COULAUD Olivier committed
518 519 520
    if(SCALFMM_USE_MPI)
      list(APPEND STARPU_COMPONENT_LIST "MPI")
    endif()
COULAUD Olivier's avatar
COULAUD Olivier committed
521 522 523 524
    # 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)
525
      list(APPEND STARPU_COMPONENT_LIST "OPENCL")
COULAUD Olivier's avatar
COULAUD Olivier committed
526 527 528
#      include_directories($ENV{OPENCL_INC})
#      SET(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};-L$ENV{OPENCL_LIB};-lOpenCL")
    endif()
529
    list(APPEND FUSE_LIST "OPENCL")
COULAUD Olivier's avatar
COULAUD Olivier committed
530 531


532
    find_package(STARPU ${SCALFMM_STARPU_VERSION} REQUIRED
COULAUD Olivier's avatar
COULAUD Olivier committed
533
      COMPONENTS ${STARPU_COMPONENT_LIST})
534

535 536 537 538
    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
539

540 541 542 543 544 545 546
    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
547 548 549
      # Append list of libraries and include dirs
      include_directories(${STARPU_INCLUDE_DIRS_DEP})
      foreach (starpu_libdir ${STARPU_LIBRARY_DIRS_DEP})
550
        if (${starpu_libdir} MATCHES "^ *-L")
COULAUD Olivier's avatar
COULAUD Olivier committed
551
          set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${starpu_libdir}")
552
        else()
COULAUD Olivier's avatar
COULAUD Olivier committed
553
          set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};-L${starpu_libdir}")
554
        endif()
COULAUD Olivier's avatar
COULAUD Olivier committed
555 556
      endforeach()
      foreach (starpu_lib ${STARPU_LIBRARIES_DEP})
557
        if (EXISTS ${starpu_lib} OR ${starpu_lib} MATCHES "^ *-")
COULAUD Olivier's avatar
COULAUD Olivier committed
558
          set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};${starpu_lib}")
559
        else()
COULAUD Olivier's avatar
COULAUD Olivier committed
560
          set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};-l${starpu_lib}")
561
        endif()
COULAUD Olivier's avatar
COULAUD Olivier committed
562 563
      endforeach()
    else()
COULAUD Olivier's avatar
COULAUD Olivier committed
564
      # StarPU not found
COULAUD Olivier's avatar
COULAUD Olivier committed
565 566

    endif()
567

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

573
    # Message
574
    if (STARPU_INCLUDE_DIRS)
COULAUD Olivier's avatar
COULAUD Olivier committed
575
      message(STATUS "         STARPU_INCLUDES           = ${STARPU_INCLUDE_DIRS}")
COULAUD Olivier's avatar
COULAUD Olivier committed
576
      LIST(APPEND SCALFMM_INCLUDES  "${STARPU_INCLUDE_DIRS}")
577
    endif()
578

579
    # Adding SimGrid includes
COULAUD Olivier's avatar
COULAUD Olivier committed
580
    LIST(APPEND SCALFMM_INCLUDES "$ENV{SIMGRID_INCLUDE}")
581
    message(STATUS "         Adding SIMGRID           = $ENV{SIMGRID_INCLUDE}")
582
  endif(SCALFMM_USE_STARPU)
583
  list(APPEND FUSE_LIST "STARPU")
Florent Pruvost's avatar
Florent Pruvost committed
584

585
  ##################################################################
Berenger Bramas's avatar
Berenger Bramas committed
586
  #                         FUSE                                   #
587 588
  ##################################################################

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

593 594
  ##################################################################
  #
COULAUD Olivier's avatar
COULAUD Olivier committed
595 596
  #   Set EZTRACE
  #
597
  ##################################################################
COULAUD Olivier's avatar
COULAUD Olivier committed
598 599 600 601
  If(SCALFMM_USE_EZTRACE)
    find_package (PkgConfig)
    if(PKG_CONFIG_FOUND)
      set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH "ON")
COULAUD Olivier's avatar
COULAUD Olivier committed
602
      pkg_search_module( EZTrace REQUIRED eztrace)
COULAUD Olivier's avatar
COULAUD Olivier committed
603
      if(EZTrace_FOUND)
COULAUD Olivier's avatar
COULAUD Olivier committed
604 605
        link_directories(${EZTrace_LIBRARY_DIRS})
        link_libraries( ${EZTrace_LIBRARIES})
606 607 608 609
        if (EZTrace_LIBRARY_DIRS)
          # the RPATH to be used when installing
          list(APPEND CMAKE_INSTALL_RPATH "${EZTrace_LIBRARY_DIRS}")
        endif()
COULAUD Olivier's avatar
COULAUD Olivier committed
610
        IF( SCALFMM_USE_MPI )
COULAUD Olivier's avatar
COULAUD Olivier committed
611
          link_libraries(-leztrace-autostart-mpi)
612 613 614 615 616 617 618 619 620
        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 )
COULAUD Olivier's avatar
COULAUD Olivier committed
621
      else(EZTrace_FOUND)
622 623
        MESSAGE(WARNING "Eztrace not found - EZTRACE Is set to OFF")
        set(SCALFMM_USE_EZTRACE OFF)
COULAUD Olivier's avatar
COULAUD Olivier committed
624
      endif(EZTrace_FOUND)
COULAUD Olivier's avatar
COULAUD Olivier committed
625
    else(PKG_CONFIG_FOUND)
COULAUD Olivier's avatar
COULAUD Olivier committed
626
      MESSAGE(WARNING "PKG-CONFIG not found - EZTRACE Is set to OFF")
COULAUD Olivier's avatar
COULAUD Olivier committed
627 628 629 630
      set(SCALFMM_USE_EZTRACE OFF)
    endif(PKG_CONFIG_FOUND)

  endif(SCALFMM_USE_EZTRACE)
631

632
  list(APPEND FUSE_LIST "OMP4")
COULAUD Olivier's avatar
COULAUD Olivier committed
633

634 635 636 637
  ##################################################################
  #
  #   To catch signals
  #
638
  ##################################################################
639 640 641 642 643 644 645 646
  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()
647 648 649 650 651 652 653 654
  ##################################################################
  #                                                                #
  #                     END SETTING VARIABLES                      #
  #                                                                #
  ##################################################################
  #
  # Generate  ScalFmmConfig.h
  #
655
  set(SCALFMM_COMPILE_FLAGS "${SCALFMM_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
656
  set(CMAKE_CXX_FLAGS "${SCALFMM_COMPILE_FLAGS}")
657 658 659
  # We need the libraries without spaces (inside the config file)
  set(SCALFMM_COMPILE_LIBS   "")
  foreach(lib_var ${SCALFMM_LIBRARIES})
COULAUD Olivier's avatar
COULAUD Olivier committed
660
    string(STRIP ${lib_var} lib_var)
661
    LIST(APPEND SCALFMM_COMPILE_LIBS   ${lib_var})
662
  endforeach()
663 664
  string(REPLACE " " ";" SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}")
  string(REPLACE ";;" ";" SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}")
COULAUD Olivier's avatar
COULAUD Olivier committed
665 666
#  string(REPLACE " " ";" SCALFMM_INCLUDES "${SCALFMM_INCLUDES}")
#  string(REPLACE ";;" ";" SCALFMM_INCLUDES "${SCALFMM_INCLUDES}")
667
  configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Src/ScalFmmConfig.h.cmake
668
    ${CMAKE_CURRENT_BINARY_DIR}/Src/ScalFmmConfig.h  )
669 670 671 672 673
  #
  ##################################################################
  #                      Build - lib                               #
  ##################################################################
  #
674
  MESSAGE(STATUS "FUSE : ${FUSE_LIST} ")
COULAUD Olivier's avatar
COULAUD Olivier committed
675
  add_subdirectory(Contribs)
676 677 678 679 680 681 682
  add_subdirectory(Src)
  # Link with scalfmm lib
  set(scalfmm_lib scalfmm)
  #
  ##################################################################
  #            Remove compilation  of the drivers                  #
  ##################################################################
683
  message(STATUS "SCALFMM_BUILD_EXAMPLES  =  ${SCALFMM_BUILD_EXAMPLES}" )
684
  if( SCALFMM_BUILD_EXAMPLES )
685 686 687 688 689 690 691
    # Build - Examples and drivers
    add_subdirectory(Examples)
  endif()
  ##################################################################
  #           Build tools (Internal use)                           #
  ##################################################################
  # Build - UTILs
692
  if( SCALFMM_ONLY_DEVEL AND SCALFMM_BUILD_UTILS)
693
    add_subdirectory(Utils)
694
  endif()
695

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

705 706 707 708
  ##################################################################
  #              Build - Unitary and numerical Tests               #
  ##################################################################
  #
709 710
  message( STATUS "SCALFMM_BUILD_UTESTS         = ${SCALFMM_BUILD_UTESTS}" )
  if( SCALFMM_BUILD_UTESTS )
711 712 713 714
    include(CTest)
    enable_testing()
    add_subdirectory(UTests)
  endif()
715
  #
716 717 718
  ##################################################################
  #                           Add - doc                            #
  ##################################################################
719
  #
720
  message(STATUS "SCALFMM_BUILD_DOC           =  ${SCALFMM_BUILD_DOC}" )
721 722 723
  if(SCALFMM_BUILD_DOC)
    add_subdirectory(Doc)
  endif()
724
  #
725 726 727 728
  ##################################################################
  #                       Build - Addons                           #
  ##################################################################
  #
COULAUD Olivier's avatar
COULAUD Olivier committed
729 730 731 732 733 734 735 736 737 738
  #   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()
739

740 741 742 743 744 745 746 747 748 749 750 751 752 753 754
  # 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                  #
  #                                                                #
  ##################################################################
  #
755 756 757
  message(STATUS "SCALFMM_BINARY_DIR:          " ${SCALFMM_BINARY_DIR})
  configure_file(${SCALFMM_SOURCE_DIR}/ScalFMMConfig.cmake.in
    ${SCALFMM_BINARY_DIR}/ScalFMMConfig.cmake
758 759 760
    @ONLY IMMEDIATE
    )
  #
761 762 763
  install(FILES  ${SCALFMM_BINARY_DIR}/ScalFMMConfig.cmake  DESTINATION lib/  )
  if( SCALFMM_INSTALL_DATA )
    install(FILES  ${SCALFMM_SOURCE_DIR}/Data/test20k.fma  DESTINATION Data/   )
764
  endif()
765
  #
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782
  ##################################################################
  #                                                                #
  #              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")
  #
783
  set(CPACK_RESOURCE_FILE_LICENSE  "${CMAKE_CURRENT_SOURCE_DIR}/LICENCE")
784 785
  set(CPACK_PACKAGE_VERSION_MAJOR "${SCALFMM_MAJOR_VERSION}")
  set(CPACK_PACKAGE_VERSION_MINOR "${SCALFMM_MINOR_VERSION}")
786
  #
787
  set(PACK_PACKAGE_VERSION "${SCALFMM_MAJOR_VERSION}.${SCALFMM_MINOR_VERSION}-${CPACK_PACKAGE_VERSION_PATCH}")
788
  set(CPACK_SOURCE_GENERATOR "TGZ")
789
  set(CPACK_SOURCE_PACKAGE_FILE_NAME  "SCALFMM-${SCALFMM_MAJOR_VERSION}.${SCALFMM_MINOR_VERSION}-${CPACK_PACKAGE_VERSION_PATCH}")
COULAUD Olivier's avatar
COULAUD Olivier committed
790 791
  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/")
792 793 794 795 796 797 798 799 800
  #
  include(CPack)
  #
  #
  ##################################################################
  #                                                                #
  #                      PRINT messages                            #
  #                                                                #
  ##################################################################
801
  message(STATUS "CPACK_SOURCE_IGNORE_FILES      = ${CPACK_SOURCE_IGNORE_FILES}")
802 803 804
  message(STATUS "CPACK_SOURCE_PACKAGE_FILE_NAME = ${CPACK_SOURCE_PACKAGE_FILE_NAME}")
  #
  #                    Use Mem stats
805
  message(STATUS "SCALFMM_USE_MEM_STATS = ${SCALFMM_USE_MEM_STATS}" )
806
  #                    Use Log
807
  message(STATUS "SCALFMM_USE_LOG       = ${SCALFMM_USE_LOG}" )
808
  #                    Use Assert
809
  message(STATUS "SCALFMM_USE_ASSERT    = ${SCALFMM_USE_ASSERT}" )
810
  #
COULAUD Olivier's avatar
COULAUD Olivier committed
811 812 813 814 815 816
  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
817 818 819 820 821 822
  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
823 824 825 826 827 828
  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}")
829
  #
830 831 832
  ##################################################################
  #                               END                              #
  ##################################################################
833
  #
834
else(MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/morse_cmake")
835 836 837 838 839 840 841

  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")

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