CMakeLists.txt 24.7 KB
Newer Older
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
cmake_minimum_required (VERSION 3.13.0 FATAL_ERROR)

#
# Project Declaration
#--------------------
project(scalfmm CXX)
# check if compiling into source directories
string(COMPARE EQUAL "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" insource)
if(insource)
  message(FATAL_ERROR "${PROJECT_NAME} requires an out of source build. Goto ./Build and tapes cmake ../")
endif(insource)

#
# Version Number
# --------------

# SCALFMM version number.  An even minor number corresponds to releases.
set(${CMAKE_PROJECT_NAME}_MAJOR_VERSION 3)
set(${CMAKE_PROJECT_NAME}_MINOR_VERSION 0)
set(${CMAKE_PROJECT_NAME}_PATCH_VERSION 0-pre-alpha)
set(${CMAKE_PROJECT_NAME}_VERSION  "${${CMAKE_PROJECT_NAME}_MAJOR_VERSION}.${${CMAKE_PROJECT_NAME}_MINOR_VERSION}.${${CMAKE_PROJECT_NAME}_PATCH_VERSION}" )

#
# Update cmake path
# -----------------
#list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)

#
# Creating main lib
# -----------------
add_library(${CMAKE_PROJECT_NAME} INTERFACE)
target_compile_features(${CMAKE_PROJECT_NAME} INTERFACE cxx_std_20)
# Set library includes
# --------------------
target_include_directories(${CMAKE_PROJECT_NAME} INTERFACE
  $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
  )

if(MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/morse_cmake")

  # Add extra cmake module path and initialize morse cmake modules
  # --------------------------------------------------------------
  if(MORSE_DISTRIB_DIR)
    list(APPEND CMAKE_MODULE_PATH ${MORSE_DISTRIB_DIR}/modules)
    set(MORSE_CMAKE_MODULE_PATH ${MORSE_DISTRIB_DIR}/modules )
  elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/morse_cmake")
    list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/modules/morse_cmake/modules)
    set(MORSE_CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/modules/morse_cmake/modules )
  endif()

  include(MorseInit)

  # Set the RPATH config
  # These options allow all installed executables to run correctly
  # when installed to the install diretory
  # --------------------
  # 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")
  # add the automatically determined parts of the RPATH
  # which point to directories outside the build tree to the install RPATH
  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)


  # Build ScalFmm as static or dynamic lib
  # --------------------------------------
  # option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
  #
  # Options
  #
  # Cmake options for dependencies
  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"        OFF )
  option( SCALFMM_USE_STARPU           "Set to ON to build SCALFMM with StarPU"     OFF )

  # Cmake options that impact the build tree
  option( SCALFMM_BUILD_EXAMPLES       "Set to ON to build examples"                  ON  )
  option( SCALFMM_BUILD_UNITS          "Set to ON to build unit tests"                OFF )
  option( SCALFMM_BUILD_DOC            "Set to ON to build the Doxygen documentation" OFF )

  # Cmake options related to trace, logging and statistics
  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_ONLY_DEVEL           "Set to ON to compile Development tools (only scalfmm team)" ON )

  #
  # Set scalfmm dev flags
  # ------------------------
  if(SCALFMM_ONLY_DEVEL)
    list(APPEND SCALFMM_CXX_FLAGS -Wall -pedantic )
  endif(SCALFMM_ONLY_DEVEL)

  # TODO: Find new way to resolve dependencies...
  # Set FUSE LIST
  # -------------
  set(FUSE_LIST "") # Construct during configure
  set(FUSE_DEP_AVAILABLE "MPI;CUDA;STARPU;OMP4;BLAS;FFT;OPENCL") # List to compare against when compiling tests, etc...

106 107 108 109 110 111
  #
  # Boost
  # -----
  find_package(Boost 1.69.0 COMPONENTS serialization REQUIRED)
  message(STATUS "${Boost_LIBRARIES}")

112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
  #
  # OpenMP
  # ------
  if(NOT OpenMP_CXX_FOUND)
    find_package(OpenMP)
    if(OpenMP_CXX_FOUND)
      target_link_libraries(${CMAKE_PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX)
      list(APPEND SCALFMM_LIBRARIES OpenMP)
      if(OpenMP_CXX_VERSION_MAJOR GREATER_EQUAL 4)
        list(APPEND FUSE_LIST OMP4)
      endif()
    else(OpenMP_CXX_FOUND)
      message(WARNING "OPENMP NOT FOUND")
    endif(OpenMP_CXX_FOUND)
  endif(NOT OpenMP_CXX_FOUND)

  #
129 130 131 132 133 134
  # XTL, XSIMD & XTENSOR
  # --------------------
  #if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/xsimd")
  #  set(xsimd_DIR "${CMAKE_CURRENT_BINARY_DIR}/modules/xsimd")
  #  # Find XSIMD properly
  #  add_subdirectory(modules/xsimd)
135 136 137 138 139 140 141
    find_package(xsimd CONFIG REQUIRED)
    if(xsimd_FOUND)
      message(STATUS "XSIMD found")
      target_link_libraries(${CMAKE_PROJECT_NAME} INTERFACE xsimd)
    else(xsimd_FOUND)
      message(FATAL_ERROR "Can't find XSIMD !")
    endif(xsimd_FOUND)
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
  #endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/xsimd")
    find_package(xtl CONFIG REQUIRED)
    if(xtl_FOUND)
      message(STATUS "XTL found")
      target_link_libraries(${CMAKE_PROJECT_NAME} INTERFACE xtl)
    else(xtl_FOUND)
      message(FATAL_ERROR "Can't find XTL !")
    endif(xtl_FOUND)
    find_package(xtensor CONFIG REQUIRED)
    if(xtensor_FOUND)
      message(STATUS "XTENSOR found")
      target_link_libraries(${CMAKE_PROJECT_NAME} INTERFACE xtensor)
    else(xtensor_FOUND)
      message(FATAL_ERROR "Can't find XTENSOR !")
    endif(xtensor_FOUND)
    #set(xtensor-blas_DIR $ENV{xtensor_blas_DIR})
    #find_package(xtensor-blas CONFIG REQUIRED)
    #if(xtensor-blas_FOUND)
    #  message(STATUS "XTENSOR-BLAS found")
    #  target_link_libraries(${CMAKE_PROJECT_NAME} INTERFACE xtensor-blas)
    #else(xtensor-blas_FOUND)
    #  message(FATAL_ERROR "Can't find XTENSOR-BLAS !")
    #endif(xtensor-blas_FOUND)

166 167 168 169 170 171 172 173 174

  #
  # Module inria
  # ------------
  target_include_directories(${CMAKE_PROJECT_NAME} INTERFACE
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/modules/inria>
    $<INSTALL_INTERFACE:include>
  )

175 176 177 178 179 180 181 182
  #
  # Module rangev3
  # ------------
  target_include_directories(${CMAKE_PROJECT_NAME} INTERFACE
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/modules/rangev3>
    $<INSTALL_INTERFACE:include>
  )

183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 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 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
  #
  # Specific Debug flags
  # --------------------
  if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    list(APPEND SCALFMM_CXX_FLAGS -funroll-loops)
    if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
      list(APPEND SCALFMM_CXX_FLAGS -fp-model\ strict)
    endif()
  endif()

  #
  # Specific Release flags
  # ----------------------
  if(CMAKE_BUILD_TYPE STREQUAL "Release")
    list(APPEND SCALFMM_CXX_FLAGS -funroll-loops)
    if(NOT APPLE)
      list(APPEND -ftree-vectorize)
      if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
        list(APPEND SCALFMM_CXX_FLAGS  -ipo  -fstrict-aliasing)
      endif()
      list(APPEND SCALFMM_CXX_FLAGS -ffast-math -ftree-vectorize)
    endif(NOT APPLE)
  endif()

  #
  # MPI
  # ---
  if(SCALFMM_USE_MPI)
    if(NOT MPI_FOUND)
      find_package(MPI REQUIRED)
      if(MPI_CXX_FOUND)
        target_link_libraries(${CMAKE_PROJECT_NAME} INTERFACE MPI::MPI_CXX)
        list(APPEND SCALFMM_LIBRARIES MPI)
        list(APPEND FUSE_LIST MPI)
      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)
    endif(NOT MPI_FOUND)
  endif(SCALFMM_USE_MPI)
  #
  # Blas options
  # ------------
  if(SCALFMM_USE_BLAS)

    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 )
    option( SCALFMM_USE_EXTERNAL_BLAS "Set to ON to use external BLAS. Please, set BLAS_LIBRARIES variable." OFF )

    if( SCALFMM_USE_MKL_AS_BLAS )
      set(BLA_VENDOR "Intel10_64lp_seq")
      find_package(BLAS ) # not REQUIRED
    elseif(SCALFMM_USE_ESSL_AS_BLAS)
      set(BLA_VENDOR "IBMESSL")
      find_package(BLAS   QUIET) # not REQUIRED
      find_package(LAPACK QUIET) # not REQUIRED
    elseif(SCALFMM_USE_EXTERNAL_BLAS)
      message(STATUS "BLAS SET BY EXTERNAL PROGRAM = ${BLAS_LIBRARIES}")
      list(APPEND BLASLAPACK_LIBRARIES "${BLAS_LIBRARIES}")
    else()
      find_package(BLAS)  # not REQUIRED
      find_package(LAPACK)  # not REQUIRED
    endif()

    if(BLAS_FOUND)
      target_link_libraries(${CMAKE_PROJECT_NAME} INTERFACE blas::blas)
      list(APPEND SCALFMM_LIBRARIES BLAS)
      list(APPEND FUSE_LIST BLAS)

      if(LAPACK_FOUND)
        target_link_libraries(${CMAKE_PROJECT_NAME} INTERFACE lapack::lapack)
        list(APPEND SCALFMM_LIBRARIES LAPACK)
      endif()

      message (STATUS "Check BLAS Fortran mangling")
      # add options to let the user be able to force a behavior
      option( SCALFMM_BLAS_ADD_     "Set to ON to force calls to BLAS Fortran symbols with _ (ex: dgemm_)"        ON )
      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_)
        check_function_exists(DGEMV  DGEMV_UPCASE)
        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)
    else()
      MESSAGE(WARNING "BLAS: ${BLAS_FOUND}")

      message(WARNING "BLAS has not been found, SCALFMM will continue to compile but some applications will be disabled.")
      message(WARNING "If you have BLAS set BLAS_LIBDIR, BLAS_INCDIR or BLAS_DIR (CMake variables using -D or environment variables).")
      set(SCALFMM_USE_BLAS OFF)
    endif()

  endif(SCALFMM_USE_BLAS)

  #
  # FFT options
  # -----------
  include(CMakeDependentOption)
  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 )
  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 )

  if(SCALFMM_USE_FFT)
    message(STATUS "SCALFMM USE FFT Configure:")

    # 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
    if(SCALFMM_USE_MKL_AS_FFTW)
      message(STATUS "         SCALFMM USE FFT from MKL")
      set(BLA_VENDOR "Intel10_64lp_seq")
      if(NOT TARGET blas::blas)
        find_package(FFTW COMPONENTS MKL)
      else()
        set(FFTW_FOUND 1)
        find_package(FFTW COMPONENTS MKL QUIET)
        target_include_directories(${CMAKE_PROJECT_NAME} INTERFACE ${FFTW_INCLUDE_DIRS})
      endif()
    elseif (SCALFMM_USE_ESSL_AS_FFTW)
      message(STATUS "         SCALFMM USE FFT from ESSL ")
      find_package(FFTW COMPONENTS ESSL)
    else()
      message(STATUS "         SCALFMM USE FFTW")
      find_package(FFTW COMPONENTS SIMPLE)
    endif()

    if(FFTW_FOUND)
      list(APPEND FUSE_LIST FFT)
      if(NOT SCALFMM_USE_MKL_AS_FFTW)
        target_link_libraries(${CMAKE_PROJECT_NAME} INTERFACE fftw::fftw)
        list(APPEND SCALFMM_LIBRARIES FFTW)
      endif()
    else(FFTW_FOUND)
      message(WARNING "FFTW has not been found, SCALFMM will continue to compile but some applications will be disabled.")
      message(WARNING "If you have FFTW set FFTW_LIBDIR, FFTW_INCDIR or FFTW_DIR (CMake variables using -D or environment variables).")
      set(SCALFMM_USE_FFT OFF)
    endif(FFTW_FOUND)

  endif(SCALFMM_USE_FFT)
  message(STATUS "SCALFMM_USE_FFT = ${SCALFMM_USE_FFT}")

  #
  # STARPU Section
  # --------------
  message( STATUS "SCALFMM_USE_STARPU = ${SCALFMM_USE_STARPU}" )
  CMAKE_DEPENDENT_OPTION( SCALFMM_USE_OPENCL "Set to ON to use OPENCL with StarPU" OFF "SCALFMM_USE_STARPU" OFF)
  CMAKE_DEPENDENT_OPTION( SCALFMM_USE_CUDA "Set to ON to use OPENCL with StarPU" OFF "SCALFMM_USE_STARPU" OFF)
  if( SCALFMM_USE_STARPU )
    enable_language(C)
    # Find StarPU with a list of optional components
    set(SCALFMM_STARPU_VERSION "1.2.8" CACHE STRING " STARPU version desired")
    # create list of components in order to make a single call to find_package(starpu...)
    set(STARPU_COMPONENT_LIST "HWLOC")
    if(SCALFMM_USE_CUDA)
      message(WARNING "This release doest not include a full support for CUDA/OpenCl.")
      #list(APPEND STARPU_COMPONENT_LIST "CUDA")
    endif()
    if(SCALFMM_USE_MPI)
      list(APPEND STARPU_COMPONENT_LIST "MPI")
    endif()
    if(SCALFMM_USE_OPENCL)
      message(WARNING "This release doest not include a full support for CUDA/OpenCl.")
      #list(APPEND STARPU_COMPONENT_LIST "OPENCL")
    endif()

    find_package(STARPU ${SCALFMM_STARPU_VERSION} REQUIRED
      COMPONENTS ${STARPU_COMPONENT_LIST})

    if(STARPU_FOUND)
      target_link_libraries(${CMAKE_PROJECT_NAME} INTERFACE starpu::starpu_dep)
      list(APPEND FUSE_LIST "STARPU")
      list(APPEND SCALFMM_LIBRARIES "STARPU")
      if(SCALFMM_USE_CUDA)
        #list(APPEND FUSE_LIST "CUDA")
      endif()
      if(SCALFMM_USE_OPENCL)
        #list(APPEND FUSE_LIST "OPENCL")
      endif()
    else(STARPU_FOUND)
      message(FATAL_ERROR "StarPU not found.")
    endif(STARPU_FOUND)
  endif(SCALFMM_USE_STARPU)

  # Additional options for developers
  if( SCALFMM_ONLY_DEVEL )
    if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
      option( SCALFMM_USE_OMP4 "Set to ON to disable the gcc/intel omp4"    OFF )
    else()
      option( SCALFMM_USE_OMP4 "Set to ON to disable the gcc/intel omp4"    ON )
    endif()
    option( SCALFMM_TIME_OMPTASKS "Set to ON to time omp4 tasks and generate output file"    OFF )
    # SIMGRID and peformance models options
    option( SCALFMM_SIMGRID_NODATA "Set to ON to avoid the allocation of numerical parts in the group tree" OFF )
    option( STARPU_SIMGRID_MLR_MODELS "Set to ON to enable MLR models need for calibration and simulation" OFF )
    # OPENMP 4/5 support
    option( OPENMP_SUPPORT_PRIORITY  "Set to ON to enable tasks priority (OMP4.x/KSTAR/StarPU compiler only)" OFF )
    # STARPU options
    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)
    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)
    cmake_dependent_option(SCALFMM_USE_STARPU_EXTRACT  "Set to ON to enable extract with StarPU mpi implicit" ON  "SCALFMM_USE_STARPU" OFF)
  endif()

  #
  # Set ScalFMM compile flags
  # -------------------------
  set(SCALFMM_CXX_FLAGS "${SCALFMM_CXX_FLAGS}" CACHE STRING "Global compile flags for ScalFMM")
  message(STATUS "ScalFMM final flags : ${SCALFMM_CXX_FLAGS}")
  # And adding flags to target
  # --------------------------
  target_compile_options(${CMAKE_PROJECT_NAME} INTERFACE "${SCALFMM_CXX_FLAGS}")

  #
  # Set ScalFMM dependencies
  # ------------------------
  set(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES}" CACHE STRING "ScalFMM libraries dependencies")
  message(STATUS "ScalFMM dependencies : ${SCALFMM_LIBRARIES}")

  #  #
  #  # Set ScalFMM link flags
  #  # ----------------------
  #  string(REPLACE ";" " " SCALFMM_LINK_FLAGS "${SCALFMM_LINK_FLAGS}")
  #  set(SCALFMM_LINK_FLAGS "${SCALFMM_LINK_FLAGS}" CACHE STRING "Global link flags for ScalFMM")
  #  message(STATUS "ScalFMM link flags : ${SCALFMM_LINK_FLAGS}")
  #  # And adding lin flags to the target
  #  # ----------------------------------
  #  target_link_options(${CMAKE_PROJECT_NAME} INTERFACE "${SCALFMM_LIBRARIES}")

  #
  # Set ScalFMM compile definitions
  # -------------------------------
  set(SCALFMM_COMPILE_DEFINITIONS "${SCALFMM_COMPILE_DEFINITIONS}" CACHE STRING "Global compile definitions for ScalFMM")
  message(STATUS "ScalFMM compile definitions : ${SCALFMM_COMPILE_DEFINITIONS}")
  # And adding definitions to target
  # --------------------------------
  target_compile_definitions(${CMAKE_PROJECT_NAME} INTERFACE "${SCALFMM_COMPILE_DEFINITIONS}")


  #
  # Generate ScalFmmConfig.h
  # ------------------------
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/scalfmm/config/scalfmm-config.hpp.cmake
    ${CMAKE_CURRENT_BINARY_DIR}/include/scalfmm/config/scalfmm-config.hpp)

  #
  # Static analysis during build
  # ----------------------------
  CMAKE_DEPENDENT_OPTION(SCALFMM_USE_STATIC_ANALYSIS  "Set to ON to use static analysis tools"  ON  "SCALFMM_ONLY_DEVEL"  OFF )
  CMAKE_DEPENDENT_OPTION(SCALFMM_USE_CPPCHECK   "Set to ON to use static analysis tools"  OFF "SCALFMM_USE_STATIC_ANALYSIS"  OFF )
  CMAKE_DEPENDENT_OPTION(SCALFMM_USE_CLANGTIDY  "Set to ON to use static analysis tools"  ON  "SCALFMM_USE_STATIC_ANALYSIS"  OFF  )
  CMAKE_DEPENDENT_OPTION(SCALFMM_USE_IWYU       "Set to ON to use static analysis tools"  ON  "SCALFMM_USE_STATIC_ANALYSIS"  OFF )

  if(SCALFMM_USE_STATIC_ANALYSIS AND SCALFMM_USE_CPPCHECK)
    find_program(CPPCHECK "cppcheck")
    if (CPPCHECK)
      set(CMAKE_CXX_CPPCHECK "${CPPCHECK}"
        "--language=c++"
        "$<GENEX_EVAL:-I$<TARGET_PROPERTY:INTERFACE_INCLUDE_DIRECTORIES>>"
        "-I."
        "-v"
        "--enable=all"
        "--force"
        "--inline-suppr"
        )
      message(STATUS "CPPCHECK analysis is ON.")
    endif()
    #add_custom_target(genexdebug COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_GENEX_EVAL:${CMAKE_PROJECT_NAME},-I$<TARGET_PROPERTY:${CMAKE_PROJECT_NAME},INTERFACE_INCLUDE_DIRECTORIES>>)
  endif(SCALFMM_USE_STATIC_ANALYSIS AND SCALFMM_USE_CPPCHECK)

  if(SCALFMM_USE_STATIC_ANALYSIS AND SCALFMM_USE_CLANGTIDY)
    find_program(CLANGTIDY "clang-tidy")
498
    if(CLANGTIDY)
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
      set(CMAKE_CXX_CLANG_TIDY "${CLANGTIDY};-checks=-*,boost-*,cppcoreguidelines-*,clang-analyser-cplusplus*,modernize-*,mpi-*,performance-*,portability-*,readability-*")
      message(STATUS "Clang Tidy analysis is ON.")
    endif()
  endif(SCALFMM_USE_STATIC_ANALYSIS AND SCALFMM_USE_CLANGTIDY)

  if(SCALFMM_USE_STATIC_ANALYSIS AND SCALFMM_USE_IWYU)
    find_program(IWYU "include-what-you-use")
    if(IWYU)
      set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${IWYU}")
      message(STATUS "Include What You Use analysis is ON.")
    endif()
  endif(SCALFMM_USE_STATIC_ANALYSIS AND SCALFMM_USE_IWYU)

  #
  # Build Examples
  # --------------
  message(STATUS "SCALFMM_BUILD_EXAMPLES = ${SCALFMM_BUILD_EXAMPLES}" )
  if( SCALFMM_BUILD_EXAMPLES )
    # Build - Examples and drivers
    add_subdirectory(examples)
  endif()

  #
  # Build - Unitary and numerical Tests
  # -----------------------------------
  message( STATUS "SCALFMM_BUILD_UTESTS = ${SCALFMM_BUILD_UTESTS}" )
  if( SCALFMM_BUILD_UNITS )
    enable_testing()
    include(CTest)
    add_subdirectory(units)
  endif()

  #
  # Add - doc
  # ---------
  message(STATUS "SCALFMM_BUILD_DOC = ${SCALFMM_BUILD_DOC}" )
  if(SCALFMM_BUILD_DOC)
    add_subdirectory(doc)
  endif()

  #
  # Export Library
  # --------------
542
  install(TARGETS ${CMAKE_PROJECT_NAME} #xsimd
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
    EXPORT ${CMAKE_PROJECT_NAME}-targets
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
    RUNTIME DESTINATION bin)

  install(DIRECTORY ${${CMAKE_PROJECT_NAME}_SOURCE_DIR}/include
    DESTINATION ${CMAKE_INSTALL_PREFIX}
    PATTERN "scalfmm-config.hpp.cmake" EXCLUDE)

  install(DIRECTORY ${${CMAKE_PROJECT_NAME}_SOURCE_DIR}/modules/inria
    DESTINATION ${CMAKE_INSTALL_PREFIX}
    PATTERN "scalfmm-config.hpp.cmake" EXCLUDE)

  install(FILES ${${CMAKE_PROJECT_NAME}_BINARY_DIR}/include/scalfmm/config/scalfmm-config.hpp
    DESTINATION include/scalfmm/config/scalfmm-config.hpp)

  install(EXPORT ${CMAKE_PROJECT_NAME}-targets
    FILE ${CMAKE_PROJECT_NAME}-targets.cmake
    NAMESPACE ${CMAKE_PROJECT_NAME}::
    DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})

  include(CMakePackageConfigHelpers)
  write_basic_package_version_file("${CMAKE_PROJECT_NAME}ConfigVersion.cmake"
    VERSION ${${CMAKE_PROJECT_NAME}_VERSION}
    COMPATIBILITY SameMajorVersion)

  configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_PROJECT_NAME}Config.cmake.in
    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
    INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/${CMAKE_PROJECT_NAME}/)

  install(FILES "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake"
    "${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake"
    DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})

  #
  # build a CPack driven installer package
  # --------------------------------------
  # See CPackConfig.cmake for the details.
  include(CPack)

  #
  # Print configure status
  # ----------------------
  #                    Use Mem stats
  message(STATUS "SCALFMM_USE_MEM_STATS = ${SCALFMM_USE_MEM_STATS}" )
  #                    Use Log
  message(STATUS "SCALFMM_USE_LOG = ${SCALFMM_USE_LOG}" )
  #
  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}")
  #
  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)
  message(STATUS "SCALFMM_CXX_FLAGS = ${SCALFMM_CXX_FLAGS}")
  message(STATUS "SCALFMM_LIBRARIES = ${SCALFMM_LIBRARIES}")
  message(STATUS "FUSE_LIST = ${FUSE_LIST}")

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

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

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