diff --git a/meson.build b/meson.build index 6675aba..02044be 100644 --- a/meson.build +++ b/meson.build @@ -3,9 +3,11 @@ project( license: 'Apache-2.0', meson_version: '>= 0.64.0', default_options : [ - 'buildtype=debugoptimized', + 'buildtype=release', + 'b_ndebug=if-release', 'cpp_std=c++17', - 'warning_level=2' + 'warning_level=2', + 'pkgconfig.relocatable=true' ] ) @@ -26,6 +28,33 @@ inc_local = include_directories('include') incdir_numpy = run_command(py, ['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'], check : true).stdout().strip() inc_np = include_directories(incdir_numpy) +## Begin compiler arguments +compiler = meson.get_compiler('cpp') +message('Compiler = '+compiler.get_id()) +_cpp_args = [] +if get_option('buildtype') == 'debugoptimized' + _cpp_args += compiler.get_supported_arguments( + '-O2', + # '-fsanitize=address', + # '-fno-omit-frame-pointer', + '-g', + '-Wall' + ) +else + ## Release + _cpp_args += compiler.get_supported_arguments( + '-flto=thin', # think LTO + # '-flto', # monolithic LTO + '-O3', # full optimizations + '-DNDEBUG', # remove assertions + '-Wl,-s', # strip symbols to reduce binary size + # '-march=native' # either this or lto seems to not work on multiple builds + ) +endif + + + + ## Compile the package directory subdir('simplextree') diff --git a/simplextree/meson.build b/simplextree/meson.build index a65c8a8..4199b49 100644 --- a/simplextree/meson.build +++ b/simplextree/meson.build @@ -1,9 +1,5 @@ -## Message the C++ compiler location for debugging -compiler = meson.get_compiler('cpp') -message('Compiler = '+compiler.get_id()) - ## Compiler flags -_cpp_args = compiler.get_supported_arguments( +_cpp_args += compiler.get_supported_arguments( '-Wno-unused-parameter', '-Wno-reserved-identifier', '/Wc++11-extensions',