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

incardon's avatar
incardon committed
4
enable_testing()
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 14 15 16 17 18 19 20 21 22 23 24
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake_modules/)

set(BOOST_INCLUDE ${Boost_INCLUDE_DIR} CACHE PATH "Include directory for BOOST")
set(PETSC_ROOT CACHE PATH "If compiling with linear algebra indicate the PETSC root directory")
set(PARMETIS_ROOT CACHE PATH "Parmetis root directory")
set(METIS_ROOT CACHE PATH "Metis root directory")
set(LIBHILBERT_ROOT CACHE PATH "LibHilbert root path")
set(HDF5_ROOT CACHE PATH "HDF5 root path")
set(EIGEN3_ROOT CACHE PATH "Eigen3 include path")
set(LIBHILBERT_ROOT CACHE PATH "LibHilbert root path")
set(SUITESPARSE_ROOT CACHE PATH "The suitesparse root path")
set(TINYOBJLOADER_ROOT CACHE PATH "TinyObjLoader library path")
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
25
set(ACTION_ON_ERROR CACHE STRING "Action to perform in case of error")
incardon's avatar
incardon committed
26 27 28 29 30 31 32
set(PROFILE_WITH_SCOREP CACHE BOOL "Enable profiling with scorep")
set(ENV{PETSC_DIR} ${PETSC_ROOT})
set(ENV{HDF5_ROOT} ${HDF5_ROOT})
set(ENV{EIGEN3_ROOT} ${EIGEN3_ROOT})
set(METIS_DIR ${METIS_ROOT})
set(PARMETIS_DIR ${PARMETIS_ROOT})
set(OPENBLAS_ROOT CACHE PATH "Root path for blas library")
incardon's avatar
incardon committed
33
set(SuiteSparse_ROOT ${SUITESPARSE_ROOT})
incardon's avatar
incardon committed
34

incardon's avatar
incardon committed
35
set (CMAKE_CXX_STANDARD 11)
incardon's avatar
incardon committed
36
set (CMAKE_CUDA_STANDARD 11)
incardon's avatar
incardon committed
37

incardon's avatar
incardon committed
38
if (OPENBLAS_ROOT)
incardon's avatar
incardon committed
39 40
	set(ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${OPENBLAS_ROOT}/lib")
	set(ENV{DYLD_LIBRARY_PATH} "$ENV{DYLD_LIBRARY_PATH}:${OPENBLAS_ROOT}/lib")
incardon's avatar
incardon committed
41 42 43 44 45 46 47 48
endif()

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

if(ENABLE_GPU)
	enable_language(CUDA)
	find_package(CUDA)
incardon's avatar
incardon committed
49 50 51

	if (CUDA_VERSION_MAJOR EQUAL 9 AND CUDA_VERSION_MINOR EQUAL 2)
		message("CUDA is compatible")
52
		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)
incardon's avatar
incardon committed
53
		set(WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT  "-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")
54 55
	elseif ( CUDA_VERSION_MAJOR EQUAL 10 AND CUDA_VERSION_MINOR EQUAL 1 )
                message("CUDA is compatible")
56
                set(WARNING_SUPPRESSION_AND_OPTION_NVCC  -Xcudafe "--display_error_number --diag_suppress=2915 --diag_suppress=2914  --diag_suppress=2912 --diag_suppress=2913 --diag_suppress=111 --diag_suppress=186 --diag_suppress=611 " --expt-extended-lambda)
incardon's avatar
incardon committed
57
		set(WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT  "-Xcudafe \"--display_error_number --diag_suppress=2915 --diag_suppress=2914 --diag_suppress=2912 --diag_suppress=2913 --diag_suppress=111 --diag_suppress=186 --diag_suppress=611 \" --expt-extended-lambda")
incardon's avatar
incardon committed
58 59 60 61
	else()
		message(FATAL_ERROR "CUDA is incompatible, version 9.2 is only supported")
	endif()

incardon's avatar
incardon committed
62 63
endif()

incardon's avatar
incardon committed
64

incardon's avatar
incardon committed
65
find_package(Boost 1.68.0 COMPONENTS unit_test_framework iostreams program_options)
incardon's avatar
incardon committed
66
find_package(MPI)
incardon's avatar
incardon committed
67
find_package(PETSc)
incardon's avatar
incardon committed
68
find_package(HDF5)
incardon's avatar
incardon committed
69
find_package(Eigen3)
incardon's avatar
incardon committed
70 71 72
find_package(LibHilbert)
find_package(Metis)
find_package(ParMetis)
incardon's avatar
incardon committed
73 74 75
find_package(TinyObjLoader )
find_package(BLAS)
find_package(LAPACK)
incardon's avatar
incardon committed
76
find_package(Eigen3)
incardon's avatar
incardon committed
77
find_package(SuiteSparse OPTIONAL_COMPONENTS UMFPACK)
incardon's avatar
incardon committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

if(PROFILE_WITH_SCOREP)
	set(CMAKE_CXX_COMPILER_LAUNCHER "scorep")
	set(CMAKE_CC_COMPILER_LAUNCHER "scorep")
	set(CMAKE_CUDA_COMPILER_LAUNCHER "scorep")
endif()

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

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

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

incardon's avatar
incardon committed
97 98 99 100
if(ACTION_ON_ERROR)
	set(DEFINE_ACTION_ON_ERROR "#define ${ACTION_ON_ERROR}")
endif()

incardon's avatar
incardon committed
101 102 103 104 105 106 107 108
if(SE_CLASS2)
	set(DEFINE_SE_CLASS2 "#define SE_CLASS2")
endif()

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

109 110 111 112
if(PETSC_FOUND)
	set(DEFINE_HAVE_PETSC "#define HAVE_PETSC")
endif()

incardon's avatar
incardon committed
113 114 115 116
if(SCAN_COVERTY)
	set(DEFINE_SCAN_COVERTY "#define COVERTY_SCAN")
endif()

117
if(TEST_PERFORMANCE)
118
	set(DEFINE_PERFORMANCE_TEST "#define PERFORMANCE_TEST")
119 120
endif()

incardon's avatar
incardon committed
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
if(CUDA_FOUND)
	set(DEFINE_CUDA_GPU "#define CUDA_GPU")
endif()

if (METIS_FOUND)
	set(DEFINE_HAVE_METIS "#define HAVE_METIS 1")
else()
	file(WRITE error_code "201")
	message( FATAL_ERROR "Metis is required in order to install OpenFPM" )
endif()

if (PARMETIS_FOUND)
	set(DEFINE_HAVE_PARMETIS "#define HAVE_PARMETIS 1")
else()
	file(WRITE error_code "208")
	message( FATAL_ERROR "ParMetis is required in order to install OpenFPM")
endif()

if(MPI_FOUND)
	set(DEFINE_HAVE_MPI "#define HAVE_MPI")
else()
	file(WRITE error_code "200")
	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()
	file(WRITE error_code "202")
	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()
		file(WRITE error_code "207")
		message( FATAL_ERROR "HDF5 found ${HDF5_INCLUDE_DIRS} does not have parallel support, OpenFPM require it" )
	endif()
else()
	file(WRITE error_code "207")
	message( FATAL_ERROR "HDF5 with parallel support is required in order to install OpenFPM" )
endif()

incardon's avatar
incardon committed
168
if(EIGEN3_FOUND)
incardon's avatar
incardon committed
169 170 171 172 173 174 175 176 177 178
	set(DEFINE_HAVE_EIGEN "#define HAVE_EIGEN")
endif()

if(LIBHILBERT_FOUND)
	set(DEFINE_HAVE_LIBHILBERT "#define HAVE_LIBHILBERT 1")
else()
	file(WRITE error_code "210")
	message( FATAL_ERROR "LibHilbert is required in order to install OpenFPM")
endif()

179
if(SUITESPARSE_FOUND AND SuiteSparse_UMFPACK_FOUND)
incardon's avatar
incardon committed
180 181 182
	set(DEFINE_HAVE_SUITESPARSE "#define HAVE_SUITESPARSE")
endif()

incardon's avatar
incardon committed
183
if(APPLE)
incardon's avatar
incardon committed
184 185 186
	set(DEFINE_HAVE_OSX "#define HAVE_OSX")
endif()

incardon's avatar
incardon committed
187 188 189 190 191
if(TINYOBJLOADER_FOUND)
	set(DEFINE_HAVE_TINYOBJLOADER "#define HAVE_TINYOBJLOADER 1")
endif()

file(WRITE error_code "0")
incardon's avatar
incardon committed
192
file(WRITE cuda_lib "${CUDA_cudart_static_LIBRARY} ${CUDA_cudadevrt_LIBRARY}")
193 194 195
file(WRITE cuda_include "-I${CUDA_INCLUDE_DIRS}")
file(WRITE mpi_include "-I${MPI_C_INCLUDE_DIRS}")
file(WRITE mpi_libs "${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES}")
incardon's avatar
incardon committed
196
file(WRITE cuda_suppress_wr "${WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT}")
incardon's avatar
incardon committed
197 198 199 200 201 202 203 204 205 206 207

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

add_subdirectory (src)
add_subdirectory (openfpm_devices)
add_subdirectory (images)
add_subdirectory (openfpm_data)
add_subdirectory (openfpm_io)
add_subdirectory (openfpm_vcluster)
add_subdirectory (openfpm_numerics)