Skip to content

Commit

Permalink
First working version of the Meson build system
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Jun 1, 2024
1 parent b0cdaab commit 3b5d7f8
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 14 deletions.
77 changes: 64 additions & 13 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ project(
],
)

cc = meson.get_compiler('c')
fc = meson.get_compiler('fortran')
fc_compiler = find_program(fc.cmd_array())

libcutest_src = []
libcutest_c_src = []

Expand All @@ -36,7 +40,7 @@ subdir('src/directsearch')
subdir('src/e04nqf')
subdir('src/filtersd')
subdir('src/filtersqp')
subdir('src/gen77')
# subdir('src/gen77')
subdir('src/gen90')
subdir('src/genc')
subdir('src/gsl')
Expand Down Expand Up @@ -78,21 +82,68 @@ subdir('src/uncmin')
subdir('src/vf13')
subdir('src/worhp')

# Preprocessing
if fc.get_id() == 'intel-cl' or fc.get_id() == 'intel-llvm-cl'
output_generator = '/Fi:@OUTPUT@'
else
output_generator = ['-o', '@OUTPUT@']
endif

pp_options = []
pp_flag = []
if fc.get_id() == 'gcc'
pp_flag += '-cpp'
pp_options += ['-cpp', '-E']
elif fc.get_id() == 'intel' or fc.get_id() == 'intel-llvm'
pp_flag += '-fpp'
pp_options += ['-fpp', '-P']
elif fc.get_id() == 'intel-cl' or fc.get_id() == 'intel-llvm-cl'
pp_flag += '/fpp'
pp_options += ['/fpp', '/P']
elif fc.get_id() == 'nagfor'
pp_flag += '-fpp'
pp_options += ['-fpp', '-F']
elif fc.get_id() == 'nvidia_hpc'
pp_flag += '-Mcpp'
pp_options += ['-Mcpp', '-F']
endif

gen_single = generator(fc_compiler,
output : 'double_@BASENAME@.f90',
arguments : pp_options + '-DSINGLE' +
['-I', '@CURRENT_SOURCE_DIR@/include', '@INPUT@'] +
output_generator)

gen_double = generator(fc_compiler,
output : 'double_@BASENAME@.f90',
arguments : pp_options + '-DDOUBLE' +
['-I', '@CURRENT_SOURCE_DIR@/include', '@INPUT@'] +
output_generator)

pp_sources_single = [gen_single.process(libcutest_src)]
pp_sources_double = [gen_double.process(libcutest_src)]

# Library
libcutest = library('cutest',
sources : libcutest_src + libcutest_c_src,
include_directories : libcutest_include,
install : true)
libcutest_single = library('cutest_single',
sources : pp_sources_single + libcutest_c_src,
include_directories : libcutest_include,
install : true)

libcutest_double = library('cutest_double',
sources : pp_sources_double + libcutest_c_src,
include_directories : libcutest_include,
install : true)

# Binaries
foreach binary: cutest_binaries
binname = binary[0]
binfile = binary[1]
executable(binname,
sources : binfile,
link_with : libcutest,
install : true)
endforeach
# foreach binary: cutest_binaries
# binname = binary[0]
# binfile = binary[1]
# executable(binname,
# sources : binfile,
# include_directories : libcutest_include,
# link_with : libcutest_double,
# install : true)
# endforeach

# Fortran modules
script_modules = files('install_modules.py')
Expand Down
2 changes: 1 addition & 1 deletion src/tao/meson.build
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cutest_binaries += [['tao_main', files('tao_main.F90')]]
# 'tao_main.F'?
# 'tao_main.F'?

0 comments on commit 3b5d7f8

Please sign in to comment.