exafmm / CMakeLists.txt

# Reject in-place build
IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
  MESSAGE(FATAL_ERROR "Rejecting in-place build. Please use a build directory")
ENDIF()
# Project header
PROJECT(ExaFMM)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

# All options are set here
OPTION(USE_SPHERICAL "Use Spherical Harmonics Expansions" ON)
OPTION(USE_MPI "Use MPI" ON)
OPTION(USE_OPENMP "Use OpenMP" ON)
OPTION(USE_GPU "Use GPUs" OFF)
OPTION(USE_VTK "Use VTK" OFF)

# FMM expansion coordinate system
IF(USE_SPHERICAL)
  SET(EXPAND Spherical)
ELSE()
  SET(EXPAND Cartesian)
ENDIF()

# MPI
IF(USE_MPI)
  FIND_PACKAGE(MPI REQUIRED)
  MESSAGE(STATUS "Enabling MPI")
  SET(CMAKE_CXX_COMPILER ${MPI_COMPILER})
ENDIF()

# OpenMP
IF(USE_OPENMP)
  FIND_PACKAGE(OpenMP REQUIRED)
  MESSAGE(STATUS "Enabling OpenMP")
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
ENDIF()

# CUDA
IF(USE_GPU)
  SET(DEVICE GPU)
  FIND_PACKAGE(CUDA REQUIRED)
  MESSAGE(STATUS "Enabling CUDA ${CUDA_VERSION}")
  IF(CUDA_SDK_ROOT_DIR MATCHES "CUDA_SDK_ROOT_DIR-NOTFOUND")
    MESSAGE(FATAL_ERROR "Could not locate CUDA SDK. Try setting environment variable NVSDKCOMPUTE_ROOT")
  ENDIF()
  SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -fopenmp --ptxas-options=-v -O3 -use_fast_math -arch=sm_21)
  INCLUDE_DIRECTORIES(${CUDA_SDK_ROOT_DIR}/common/inc)
ELSE()
  SET(DEVICE CPU)
ENDIF()

# VTK
IF(USE_VTK)
  FIND_PACKAGE(VTK REQUIRED)
  MESSAGE(STATUS "Enabling VTK ${VTK_VERSION}")
  ADD_DEFINITIONS(-DVTK)
  INCLUDE(${VTK_USE_FILE})
  LINK_LIBRARIES(vtkCommon vtkFiltering vtkGraphics vtkIO vtkRendering vtkViews vtkWidgets)
ENDIF()

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wshadow -Wuninitialized -O3")
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include)
ADD_DEFINITIONS(-D${DEVICE})
ADD_DEFINITIONS(-D${EXPAND})
ADD_SUBDIRECTORY(kernel)

# Unit tests
INCLUDE(CTest)
ADD_SUBDIRECTORY(unit_test)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.