Repository navigation
Expand file tree
/
Copy pathmeson.build
More file actions
139 lines (122 loc) · 3.82 KB
/
Copy pathmeson.build
File metadata and controls
139 lines (122 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
project('quip','fortran','c',
version : '0.1',
default_options : ['warning_level=3'],
meson_version : '>=1.1'
)
fortran = meson.get_compiler('fortran')
sizeof_fortran_res = fortran.run('''
program sizeof_fortran_t
type ptr_type
type(ptr_type), pointer :: p => NULL()
end type ptr_type
type(ptr_type) :: ptr
integer, allocatable, dimension(:) :: ptr_int
write (*,*) size(transfer(ptr, ptr_int))
end program sizeof_fortran_t
''')
sizeof_fortran_t=sizeof_fortran_res.stdout().strip()
git_version_res = run_command('bin/gitversion',check:true)
add_global_arguments([
'-DGIT_VERSION="'+git_version_res.stdout().strip()+'"',
], language:'fortran')
if get_option('gap')
gap_version_res = run_command('src/GAP/gapversion',check:true)
gap_args = [
'-DGAP_VERSION='+gap_version_res.stdout().strip(),
'-DHAVE_GAP',
'-DHAVE_TB',
]
if get_option('qr')
gap_args += '-DHAVE_QR'
endif
add_global_arguments(gap_args, language:'fortran')
endif
# Determine QUIP_ARCH dynamically based on host machine
quip_system = host_machine.system()
quip_cpu = host_machine.cpu_family()
if quip_system == 'darwin'
quip_os = 'darwin'
elif quip_system == 'linux'
quip_os = 'linux'
else
quip_os = quip_system
endif
quip_arch = quip_os + '_' + quip_cpu + '_gfortran'
if get_option('mpi')
quip_arch += '_openmpi'
endif
add_global_arguments([
'-ffree-line-length-none',
'-fno-second-underscore',
'-fPIC',
'-fno-realloc-lhs',
'-DFORTRAN_UNDERSCORE',
'-DGETARG_F2003',
'-DGETENV_F2003',
'-DGFORTRAN',
'-DQUIP_ARCH="' + quip_arch + '"',
'-DSIZEOF_FORTRAN_T='+sizeof_fortran_t,
], language:'fortran')
if get_option('mpi')
message('MPI ON')
scalapack_dep = dependency('scalapack', required: false)
if not scalapack_dep.found()
message('scalapack not found via pkg-config/cmake, trying system library search')
scalapack_dep = fortran.find_library('scalapack', required: true)
endif
mpi_dep = [
scalapack_dep,
dependency('mpi', language: 'fortran'),
dependency('mpi', language: 'c'),
]
add_global_arguments([
'-D_MPI',
'-DSCALAPACK',
],language:'fortran')
else
message('MPI OFF')
mpi_dep = dependency('',required: false)
endif
# Shared OpenMP link args for all libraries
openmp_link_args = ['-lgomp']
# Get openblas dependency with fallback for systems without pkg-config support
openblas_dep = dependency('openblas', required: false)
if not openblas_dep.found()
# Fallback: try to find openblas as a system library
message('openblas not found via pkg-config, trying system library search')
openblas_lib = fortran.find_library('openblas', required: true)
# Assume standard include path for openblas
openblas_dep = declare_dependency(
dependencies: openblas_lib,
compile_args: ['-I/usr/include', '-I/usr/include/openblas'],
)
endif
c = meson.get_compiler('c')
if c.get_id() == 'clang'
# Apple clang doesn't support -fopenmp, so we need to filter it out
# For Fortran, gfortran supports it, so we keep it
blas_dep = declare_dependency(
compile_args: ['-I' + openblas_dep.get_variable(pkgconfig: 'includedir')],
link_args: ['-L' + openblas_dep.get_variable(pkgconfig: 'libdir'), '-lopenblas'],
)
else
blas_dep = openblas_dep
endif
subdir('src')
# CMake package config generation for find_package(QUIP) support
cmake = import('cmake')
cmake_conf = configuration_data()
cmake_conf.set('QUIP_VERSION', meson.project_version())
cmake_conf.set('QUIP_HAS_GAP', get_option('gap') ? 'TRUE' : 'FALSE')
cmake.write_basic_package_version_file(
name: 'QUIP',
version: meson.project_version(),
compatibility: 'SameMajorVersion',
install_dir: get_option('libdir') / 'cmake' / 'QUIP'
)
cmake.configure_package_config_file(
name: 'QUIP',
input: 'cmake/QUIPConfig.cmake.in',
configuration: cmake_conf,
install_dir: get_option('libdir') / 'cmake' / 'QUIP'
)