Added support for building the module as a shared library.

This commit is contained in:
Relintai 2023-12-24 00:18:12 +01:00
parent ee78d8ae72
commit 19685c2762

12
SCsub
View File

@ -121,5 +121,15 @@ if module_env.pmlpp_build_tests and module_env.pmlpp_build_old_classes:
"test/mlpp_tests_old.cpp",
]
module_env.add_source_files(env.modules_sources, sources)
if ARGUMENTS.get('pmlpp_shared', 'no') == 'yes':
# Shared lib compilation
module_env.Append(CCFLAGS=['-fPIC'])
module_env['LIBS'] = []
shared_lib = module_env.SharedLibrary(target='#bin/pmlpp', source=sources)
shared_lib_shim = shared_lib[0].name.rsplit('.', 1)[0]
env.Append(LIBS=[shared_lib_shim])
env.Append(LIBPATH=['#bin'])
else:
# Static compilation
module_env.add_source_files(env.modules_sources, sources)