build(build): updated build system to be compatible with resource manager

The build system now passes compiler directives based on the mode being build. By default data is stored in the source root (and this is encoded into the compiled binary). However, if building in user mode then data is assumed to be at the meson install prefix data directory
This commit is contained in:
2025-03-20 14:29:43 -04:00
parent 18f3f6689d
commit cb5ac274dc
7 changed files with 61 additions and 12 deletions

View File

@@ -2,11 +2,28 @@ project('4DSSE', 'cpp', version: '0.0.1a', default_options: ['cpp_std=c++23'], m
# Add default visibility for all C++ targets # Add default visibility for all C++ targets
add_project_arguments('-fvisibility=default', language: 'cpp') add_project_arguments('-fvisibility=default', language: 'cpp')
# Determine the mode
mode = 1
if get_option('user_mode')
mode = 0
endif
# Define DATA_DIR based on mode
if mode == 1
data_dir = meson.project_source_root() + '/assets/dynamic'
else
data_dir = get_option('prefix') + '/' + get_option('datadir') + '/4DSSE'
endif
# Pass the DATA_DIR definition to the compiler
add_project_arguments('-DDATA_DIR=' + data_dir, language : 'cpp')
# Build external dependencies first so that all the embedded resources are available to the other targets # Build external dependencies first so that all the embedded resources are available to the other targets
subdir('build-config') subdir('build-config')
subdir('subprojects/PicoSHA2') subdir('subprojects/PicoSHA2')
subdir('assets/static')
# Build the main project # Build the main project
subdir('src') subdir('src')
if get_option('build_tests') if get_option('build_tests')

View File

@@ -1 +1,2 @@
option('build_tests', type: 'boolean', value: true, description: 'Build tests') option('build_tests', type: 'boolean', value: true, description: 'Build tests')
option('user_mode', type: 'boolean', value: false, description: 'Enable user mode (set mode = 0)')

View File

@@ -1,23 +1,34 @@
# Define the library # Define the library
eos_sources = files( eos_sources = files(
'private/helm.cpp', 'private/helm.cpp',
'private/eosIO.cpp'
) )
eos_headers = files( eos_headers = files(
'public/helm.h' 'public/helm.h',
'public/eosIO.h'
) )
dependencies = [
const_dep,
quill_dep,
probe_dep,
config_dep,
mfem_dep,
macros_dep,
]
# Define the libconst library so it can be linked against by other parts of the build system # Define the libconst library so it can be linked against by other parts of the build system
libeos = static_library('eos', libeos = static_library('eos',
eos_sources, eos_sources,
include_directories: include_directories('public'), include_directories: include_directories('public'),
cpp_args: ['-fvisibility=default'], cpp_args: ['-fvisibility=default'],
dependencies: [const_dep, quill_dep, probe_dep, config_dep, mfem_dep], dependencies: dependencies,
install : true) install : true)
eos_dep = declare_dependency( eos_dep = declare_dependency(
include_directories: include_directories('public'), include_directories: include_directories('public'),
link_with: libeos, link_with: libeos,
dependencies: dependencies
) )
# Make headers accessible # Make headers accessible
install_headers(eos_headers, subdir : '4DSSE/eos') install_headers(eos_headers, subdir : '4DSSE/eos')

View File

@@ -6,14 +6,22 @@ meshIO_sources = files(
meshIO_headers = files( meshIO_headers = files(
'public/meshIO.h' 'public/meshIO.h'
) )
dependencies = [
mfem_dep
]
# Define the libmeshIO library so it can be linked against by other parts of the build system # Define the libmeshIO library so it can be linked against by other parts of the build system
libmeshIO = static_library('meshIO', libmeshIO = static_library('meshIO',
meshIO_sources, meshIO_sources,
include_directories: include_directories('public'), include_directories: include_directories('public'),
cpp_args: ['-fvisibility=default'], cpp_args: ['-fvisibility=default'],
dependencies: [mfem_dep], dependencies: dependencies,
install : true) install : true)
meshio_dep = declare_dependency(
include_directories: include_directories('public'),
link_with: libmeshIO,
dependencies: dependencies
)
# Make headers accessible # Make headers accessible
install_headers(meshIO_headers, subdir : '4DSSE/meshIO') install_headers(meshIO_headers, subdir : '4DSSE/meshIO')

View File

@@ -1,11 +1,18 @@
# Build resources first so that all the embedded resources are available to the other targets # Build the main source code in the correct order
subdir('resources')
# Build the main source code # Utility Libraries
subdir('dobj') subdir('misc')
subdir('const')
subdir('opatIO')
subdir('meshIO')
subdir('config') subdir('config')
subdir('probe') subdir('probe')
subdir('const')
subdir('dobj')
# Asset Libraries
subdir('eos') subdir('eos')
subdir('opatIO')
subdir('meshIO')
# Resouce Manager Libraries
subdir('resource')
# Physics Libraries

View File

@@ -16,5 +16,9 @@ libopatIO = library('opatIO',
install : true, install : true,
) )
opatio_dep = declare_dependency(
include_directories: include_directories('public'),
link_with: libopatIO,
)
# Make headers accessible # Make headers accessible
install_headers(opatIO_headers, subdir : '4DSSE/opatIO') install_headers(opatIO_headers, subdir : '4DSSE/opatIO')

View File

@@ -11,6 +11,7 @@ subdir('meshIO')
subdir('config') subdir('config')
subdir('probe') subdir('probe')
subdir('eos') subdir('eos')
subdir('resource')
# Subdirectories for sandbox tests # Subdirectories for sandbox tests
subdir('dobj_sandbox') subdir('dobj_sandbox')