@@ -13,7 +13,16 @@ base = meson.current_source_dir() + '/core'
1313dependencies = []
1414
1515dependencies += dependency (' fftw3' , version : ' >= 3.0.0' , required : true )
16- dependencies += dependency (' mpich' , version : ' >= 4.0.0' , required : true )
16+
17+ # Detecting if MPICH is installed and enabling support if present
18+ mpi_dependency = dependency (' mpich' , version : ' >= 4.0.0' , required : false )
19+
20+ if mpi_dependency.found()
21+ cpp_args = [' -fPIC' , ' -std=c++11' , ' -DUSE_MPI=1' ]
22+ dependencies += mpi_dependency
23+ else
24+ cpp_args = [' -fPIC' , ' -std=c++11' ]
25+ endif
1726
1827sources = files ([
1928 ' linac/wrap_linacmodule.cc' ,
@@ -245,20 +254,18 @@ inc = include_directories([
245254core_lib = library (' core' ,
246255 sources : sources,
247256 include_directories : inc,
248- cpp_args : [ ' -fPIC ' , ' -std=c++11 ' , ' -DUSE_MPI=1 ' ] ,
257+ cpp_args : cpp_args ,
249258 override_options : [' b_lundef=false' ],
250259 dependencies : dependencies,
251260 install : true ,
252-
253261)
254262
255263core_dep = declare_dependency (link_with : core_lib)
256264
257-
258265python.extension_module(' orbit_mpi' ,
259266 sources : [base + ' /mpi_init.cc' ],
260267 include_directories : inc,
261- cpp_args : [ ' -fPIC ' , ' -std=c++11 ' ] ,
268+ cpp_args : cpp_args ,
262269 dependencies : [core_dep],
263270 install : true ,
264271 subdir : ' orbit/core' ,
0 commit comments