CMakeLists.txt 2.93 KB
Newer Older
incardon's avatar
incardon committed
1
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
incardon's avatar
incardon committed
2
project(openfpm_pdata LANGUAGES C CXX)
incardon's avatar
incardon committed
3

incardon's avatar
incardon committed
4
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake_modules/)
incardon's avatar
incardon committed
5

incardon's avatar
incardon committed
6 7 8 9
if (POLICY CMP0074)
  cmake_policy(SET CMP0074 NEW)
endif()

incardon's avatar
incardon committed
10 11 12 13
set(BOOST_INCLUDE ${Boost_INCLUDE_DIR} CACHE PATH "Include directory for BOOST")
set(SE_CLASS1 CACHE BOOL "Activate compilation with SE_CLASS1")
set(SE_CLASS2 CACHE BOOL "Activate compilation with SE_CLASS2")
set(SE_CLASS3 CACHE BOOL "Activate compilation with SE_CLASS3")
incardon's avatar
incardon committed
14 15 16
set(PETSC_ROOT CACHE PATH "If compiling with linear algebra indicate the PETSC root directory")

set(ENV{PETSC_DIR} ${PETSC_ROOT})
incardon's avatar
incardon committed
17

incardon's avatar
incardon committed
18 19 20
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CUDA_STANDARD 11)

incardon's avatar
incardon committed
21 22 23
if (ENABLE_GPU)
	enable_language(CUDA)
	find_package(CUDA)
incardon's avatar
incardon committed
24 25 26 27 28 29 30 31 32 33 34 35

        if (CUDA_VERSION_MAJOR EQUAL 9 AND CUDA_VERSION_MINOR EQUAL 2)
                message("CUDA is compatible")
                set(WARNING_SUPPRESSION_AND_OPTION_NVCC  -Xcudafe "--display_error_number --diag_suppress=611 --diag_suppress=2885 --diag_suppress=2886  --diag_suppress=2887  --diag_suppress=2888 --diag_suppress=186 --diag_suppress=111" --expt-extended-lambda)
        elseif ( CUDA_VERSION_MAJOR EQUAL 10 AND CUDA_VERSION_MINOR EQUAL 1 )
                message("CUDA is compatible")
                set(WARNING_SUPPRESSION_AND_OPTION_NVCC  -Xcudafe "--display_error_number --diag_suppress=2915 --diag_suppress=2912 --diag_suppress=2913 --diag_suppress=111 --diag_suppress=186 --diag_suppress=611 " --expt-extended-lambda)

        else()
                message(FATAL_ERROR "CUDA is incompatible, version 9.2 is only supported")
        endif()

incardon's avatar
incardon committed
36
endif()
incardon's avatar
incardon committed
37

incardon's avatar
incardon committed
38
find_package(Boost 1.66.0 REQUIRED COMPONENTS unit_test_framework iostreams program_options)
incardon's avatar
incardon committed
39
find_package(MPI REQUIRED)
incardon's avatar
incardon committed
40
find_package(PETSc)
incardon's avatar
incardon committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

if(CUDA_FOUND)
	set(OPENFPM_INIT_FILE "initialize/initialize_wrapper_cuda.cu")
else()
	set(OPENFPM_INIT_FILE "initialize/initialize_wrapper_cuda.cpp")
endif()

###### CONFIG.h FILE ######

if(SE_CLASS1)
	set(DEFINE_SE_CLASS1 "#define SE_CLASS1")
endif()

if(SE_CLASS2)
	set(DEFINE_SE_CLASS2 "#define SE_CLASS2")
endif()

if(SE_CLASS3)
	set(DEFINE_SE_CLASS3 "#define SE_CLASS3")
endif()

incardon's avatar
incardon committed
62 63 64 65
if(PETSC_FOUND)
	set(DEFINE_HAVE_PETSC "#define HAVE_PETSC")
endif()

incardon's avatar
incardon committed
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
if(CUDA_FOUND)
	set(DEFINE_CUDA_GPU "#define CUDA_GPU")
endif()

if(MPI_FOUND)
	set(DEFINE_HAVE_MPI "#define HAVE_MPI")
else()
	message( FATAL_ERROR "MPI is required in order to install OpenFPM" )
endif()

if (Boost_FOUND)
	set(DEFINE_HAVE_BOOST "#define HAVE_BOOST")
	set(DEFINE_HAVE_BOOST_IOSTREAMS "#define HAVE_BOOST_IOSTREAMS")
	set(DEFINE_HAVE_BOOST_PROGRAM_OPTIONS "#define HAVE_BOOST_PROGRAM_OPTIONS")
	set(DEFINE_HAVE_BOOST_UNIT_TEST_FRAMEWORK "#define HAVE_BOOST_UNIT_TEST_FRAMEWORK")
else()
	message( FATAL_ERROR "BOOST is required in order to install OpenFPM" )
endif()


configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config/config_cmake.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config/config.h)

include_directories(SYSTEM ${MPI_INCLUDE_PATH})

add_subdirectory (src)