CMakeLists.txt 3.88 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
5
6
if (POLICY CMP0074)
        cmake_policy(SET CMP0074 OLD)
endif ()
incardon's avatar
incardon committed
7
8
9

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake_modules/)

incardon's avatar
incardon committed
10
11
12
13
if (POLICY CMP0074)
  cmake_policy(SET CMP0074 NEW)
endif()

incardon's avatar
incardon committed
14
15
16
17
18
set(BOOST_INCLUDE ${Boost_INCLUDE_DIR} CACHE PATH "Include directory for BOOST")
set(HDF5_ROOT CACHE PATH "HDF5 root path")
set(SE_CLASS1 CACHE BOOL "Activate compilation with SE_CLASS1")
set(SE_CLASS3 CACHE BOOL "Activate compilation with SE_CLASS3")
set(ENV{HDF5_ROOT} ${HDF5_ROOT})
incardon's avatar
incardon committed
19
set(OPENFPM_PDATA_DIR CACHE PATH "OpenFPM_pdata dirs")
incardon's avatar
incardon committed
20
21
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
22
23
set(HIP_ENABLE CACHE BOOL "Enable HIP compiler")
set(AMD_ARCH_COMPILE "gfx900" CACHE STRING "AMD gpu architecture used to compile kernels")
incardon's avatar
incardon committed
24

incardon's avatar
incardon committed
25
if (ENABLE_GPU)
incardon's avatar
incardon committed
26
27
28
29
30
    	set(CUDA_ON_CPU OFF)
    	if (NOT HIP_ENABLE)
    		enable_language(CUDA)
    		find_package(CUDA)
	endif()
incardon's avatar
incardon committed
31
endif()
incardon's avatar
incardon committed
32

incardon's avatar
incardon committed
33
34
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CUDA_STANDARD 14)
incardon's avatar
incardon committed
35

incardon's avatar
incardon committed
36
37
38
39
40
41
42
if(NOT TINYOBJLOADER_FOUND)
	set(TINYOBJLOADER_ROOT CACHE PATH "TinyObjLoader library path")
endif()

set(ENV{PATH} "$ENV{PATH}:${HDF5_ROOT}/bin")
set(HDF5_PREFER_PARALLEL TRUE)

incardon's avatar
incardon committed
43
find_package(Boost 1.72.0 REQUIRED COMPONENTS unit_test_framework iostreams program_options OPTIONAL_COMPONENTS fiber context)
incardon's avatar
incardon committed
44
45
find_package(MPI REQUIRED)
find_package(HDF5 REQUIRED)
incardon's avatar
incardon committed
46
find_package(TinyObjLoader)
incardon's avatar
incardon committed
47
find_package(PETSc)
incardon's avatar
incardon committed
48
49
50
51
52
53
54
55
56
57
find_package(HIP)

if(HIP_FOUND)
        set(DEFINE_HIP_GPU "#define HIP_GPU")
        set(DEFINE_CUDIFY_USE_HIP "#define CUDIFY_USE_HIP")
endif()

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

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_CLASS3)
	set(DEFINE_SE_CLASS3 "#define SE_CLASS3")
endif()

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

incardon's avatar
incardon committed
85
86
87
88
if(PETSC_FOUND)
        set(DEFINE_HAVE_PETSC "#define HAVE_PETSC")
endif()

incardon's avatar
incardon committed
89
if (Boost_FOUND)
incardon's avatar
incardon committed
90
91
92
93
94
95
96
97
98
99
100
101
102
        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")
        if (Boost_CONTEXT_FOUND)
                set(DEFINE_HAVE_BOOST_CONTEXT "#define HAVE_BOOST_CONTEXT")
        else()
                #if context is not there CUDA_ON_CPU cannot be activated
                set(CUDA_ON_CPU OFF)
        endif()
        if (Boost_FIBER_FOUND)
                set(DEFINE_HAVE_BOOST_FIBER "#define HAVE_BOOST_FIBER")
        endif()
incardon's avatar
incardon committed
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
else()
	message( FATAL_ERROR "BOOST is required in order to install OpenFPM" )
endif()

if(HDF5_FOUND)
	if (HDF5_IS_PARALLEL)
		set(DEFINE_HAVE_HDF5 "#define HAVE_HDF5")
	else()
		message( STATUS "HDF5 found ${HDF5_INCLUDE_DIRS} does not have parallel support, OpenFPM require it" )
	endif()
else()
	message( FATAL_ERROR "HDF5 with parallel support is required in order to install OpenFPM" )
endif()

if(TINYOBJLOADER_FOUND)
        set(DEFINE_HAVE_TINYOBJLOADER "#define HAVE_TINYOBJLOADER 1")
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})

incardon's avatar
incardon committed
125
add_subdirectory (../openfpm_vcluster openfpm_vcluster)
incardon's avatar
incardon committed
126

incardon's avatar
incardon committed
127
128
129
130
131
set(WARNING_SUPPRESSION_AND_OPTION_NVCC ${WARNING_SUPPRESSION_AND_OPTION_NVCC} PARENT_SCOPE)
set(WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT ${WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT} PARENT_SCOPE)

add_subdirectory (src)