Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Added subproject support(lib) to the meson.build and also added meson.options #47

Merged
merged 5 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 62 additions & 29 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ project('seldon', 'cpp',
version : '0.1',
default_options : ['warning_level=3', 'cpp_std=c++20', 'optimization=3'])

add_global_arguments(['-Wno-unused-local-typedefs', '-Wno-array-bounds'], language : 'cpp')
deps = []
cpp_args = ['-Wno-unused-local-typedefs', '-Wno-array-bounds']
User-DK marked this conversation as resolved.
Show resolved Hide resolved

incdir = include_directories('include')
deps += [dependency('fmt'), dependency('tomlplusplus')]
User-DK marked this conversation as resolved.
Show resolved Hide resolved

sources_seldon = [
'src/config_parser.cpp',
Expand All @@ -16,33 +18,64 @@ sources_seldon = [
'src/util/tomlplusplus.cpp',
]

exe = executable('seldon', sources_seldon + 'src/main.cpp',
install : true,
dependencies : [dependency('fmt'), dependency('tomlplusplus')],
include_directories : incdir
)


tests = [
['Test_Tarjan', 'test/test_tarjan.cpp'],
['Test_DeGroot', 'test/test_deGroot.cpp'],
['Test_Activity_Driven', 'test/test_activity.cpp'],
['Test_Activity_Driven_Inertial', 'test/test_activity_inertial.cpp'],
['Test_Deffuant', 'test/test_deffuant.cpp'],
['Test_Network', 'test/test_network.cpp'],
['Test_Network_Generation', 'test/test_network_generation.cpp'],
['Test_Sampling', 'test/test_sampling.cpp'],
['Test_IO', 'test/test_io.cpp'],
['Test_Util', 'test/test_util.cpp'],
['Test_Prob', 'test/test_probability_distributions.cpp'],
]
# both static and shared library for bindings
# -----------------------------------
symbol_visibility = 'default'
if get_option('default_library') == 'static'
# from https://github.com/ERGO-Code/HiGHS/pull/1737/files
symbol_visibility = 'inlineshidden'
endif

# both libraries
seldon_lib = both_libraries('seldon',
sources_seldon,
install:true,
dependencies: deps,
include_directories:incdir,
gnu_symbol_visibility: symbol_visibility,
pic: true,
cpp_args : cpp_args,
)

seldon_static_dep = declare_dependency(include_directories:incdir,
link_with : seldon_lib.get_static_lib(), dependencies: deps)
seldon_shared_dep = declare_dependency(include_directories : incdir,
link_with : seldon_lib.get_shared_lib(), dependencies: deps)
# ------------------------------------

if get_option('build_exe')
exe = executable('seldon', sources_seldon + 'src/main.cpp',
install : true,
dependencies : deps,
include_directories : incdir,
cpp_args : cpp_args
)
endif

if get_option('build_tests')
tests = [
['Test_Tarjan', 'test/test_tarjan.cpp'],
['Test_DeGroot', 'test/test_deGroot.cpp'],
['Test_Activity_Driven', 'test/test_activity.cpp'],
['Test_Activity_Driven_Inertial', 'test/test_activity_inertial.cpp'],
['Test_Deffuant', 'test/test_deffuant.cpp'],
['Test_Network', 'test/test_network.cpp'],
['Test_Network_Generation', 'test/test_network_generation.cpp'],
['Test_Sampling', 'test/test_sampling.cpp'],
['Test_IO', 'test/test_io.cpp'],
['Test_Util', 'test/test_util.cpp'],
['Test_Prob', 'test/test_probability_distributions.cpp'],
]

Catch2 = dependency('Catch2', method : 'cmake', modules : ['Catch2::Catch2WithMain', 'Catch2::Catch2'])
Catch2 = dependency('Catch2', method : 'cmake', modules : ['Catch2::Catch2WithMain', 'Catch2::Catch2'])
deps+= Catch2

foreach t : tests
exe = executable(t.get(0), sources_seldon + t.get(1),
dependencies : [dependency('fmt'), dependency('tomlplusplus'), Catch2],
include_directories : incdir
)
test(t.get(0), exe, workdir : meson.project_source_root())
endforeach
foreach t : tests
exe = executable(t.get(0), sources_seldon + t.get(1),
dependencies : deps,
include_directories : incdir,
cpp_args : cpp_args
)
test(t.get(0), exe, workdir : meson.project_source_root())
endforeach
endif
2 changes: 2 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
option('build_tests', type : 'boolean', value : true, description : 'Enable building of the tests')
option('build_exe', type : 'boolean', value : true, description : 'Enable building of the executable')