From 8444c311923ff0d65a724746eadacb31c7da1fb8 Mon Sep 17 00:00:00 2001 From: Christopher Schwan Date: Tue, 14 Aug 2018 12:03:19 +0200 Subject: [PATCH] Simplify build files --- examples/meson.build | 76 +++++++++-------------------------- meson.build | 18 +++++---- tests/meson.build | 95 +++++++++++--------------------------------- 3 files changed, 53 insertions(+), 136 deletions(-) diff --git a/examples/meson.build b/examples/meson.build index a1caa69..ff1ca30 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -1,68 +1,30 @@ -executable( +examples = [ 'distributions_example', - 'distributions_example.cpp', - include_directories : incdir -) - -executable( 'helper_example', - 'helper_example.cpp', - include_directories : incdir -) - -executable( 'multi_channel_disabled_channels', - 'multi_channel_disabled_channels.cpp', - include_directories : incdir -) - -executable( 'multi_channel_example', - 'multi_channel_example.cpp', - include_directories : incdir -) - -executable( 'vegas_example', - 'vegas_example.cpp', - include_directories : incdir -) - -executable( 'vegas_read_pdf', - 'vegas_read_pdf.cpp', - include_directories : incdir -) - -executable( 'vegas_write_pdf', - 'vegas_write_pdf.cpp', - include_directories : incdir -) - -executable( 'vegas_stop_after_precision', - 'vegas_stop_after_precision.cpp', - include_directories : incdir -) - -if get_option('mpi') +] -mpi = dependency('mpi', language : 'cpp') - -executable( - 'mpi_vegas_example', - 'mpi_vegas_example.cpp', - include_directories : incdir, - dependencies : mpi -) - -executable( - 'mpi_multi_channel_example', - 'multi_channel_example.cpp', - cpp_args : '-DUSE_MPI', - include_directories : incdir, - dependencies : mpi -) +foreach e : examples + exe = executable(e, e + '.cpp', dependencies : hep_mc_dep) +endforeach +if get_option('mpi') + executable( + 'mpi_vegas_example', + 'mpi_vegas_example.cpp', + include_directories : incdir, + dependencies : [ hep_mc_dep, mpi_dep ] + ) + + executable( + 'mpi_multi_channel_example', + 'multi_channel_example.cpp', + cpp_args : '-DUSE_MPI', + dependencies : [ hep_mc_dep, mpi_dep ] + ) endif diff --git a/meson.build b/meson.build index 17d01ae..5f600c3 100644 --- a/meson.build +++ b/meson.build @@ -4,7 +4,7 @@ project( version : '0.7', license : 'GPL3', default_options : 'cpp_std=c++11', - meson_version : '>=0.42' + meson_version : '>=0.40' ) # must be before `doc` because doxygen depends on the headers @@ -14,12 +14,6 @@ if get_option('doxygen') subdir('doc') endif -if get_option('examples') - subdir('examples') -endif - -subdir('tests') - pkg = import('pkgconfig') pkg.generate( description : 'A C++ Template Library for Monte Carlo Integration', @@ -28,3 +22,13 @@ pkg.generate( ) hep_mc_dep = declare_dependency(include_directories : incdir) + +if get_option('mpi') + mpi_dep = dependency('mpi', language : 'cpp') +endif + +if get_option('examples') + subdir('examples') +endif + +subdir('tests') diff --git a/tests/meson.build b/tests/meson.build index d63bc48..af450e7 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -19,92 +19,53 @@ libgtest_main = static_library( cpp_args : '-DGTEST_HAS_PTHREAD=0' ) -test_discrete_distribution = executable( +programs = [ 'test_discrete_distribution', - 'test_discrete_distribution.cpp', - cpp_args : '-DGTEST_HAS_THREAD=0', - include_directories : incdir, - link_with : [ libgtest, libgtest_main ] -) - -test_distributions = executable( 'test_distributions', - 'test_distributions.cpp', - cpp_args : '-DGTEST_HAS_THREAD=0', - include_directories : incdir, - link_with : [ libgtest, libgtest_main ] -) - -test_genz_integrand = executable( - 'test_genz_integrand', - 'test_genz_integrand.cpp', - cpp_args : '-DGTEST_HAS_THREAD=0', - include_directories : incdir, - link_with : [ libgenz, libgtest, libgtest_main ] -) - -test_mc_helper = executable( 'test_mc_helper', - 'test_mc_helper.cpp', - cpp_args : '-DGTEST_HAS_THREAD=0', - include_directories : incdir, - link_with : [ libgtest, libgtest_main ] -) - -test_mc_point = executable( 'test_mc_point', - 'test_mc_point.cpp', - cpp_args : '-DGTEST_HAS_THREAD=0', - include_directories : incdir, - link_with : [ libgtest, libgtest_main ] -) - -test_mc_result = executable( 'test_mc_result', - 'test_mc_result.cpp', - cpp_args : '-DGTEST_HAS_THREAD=0', - include_directories : incdir, - link_with : [ libgtest, libgtest_main ] -) - -test_numerical_results = executable( 'test_numerical_results', - 'test_numerical_results.cpp', - cpp_args : '-DGTEST_HAS_THREAD=0', - include_directories : incdir, - link_with : [ libgtest, libgtest_main ] -) - -test_vegas_icdf_bug = executable( 'test_vegas_icdf_bug', - 'test_vegas_icdf_bug.cpp', - cpp_args : '-DGTEST_HAS_THREAD=0', - include_directories : incdir, - link_with : [ libgtest, libgtest_main ] -) + 'test_vegas_pdf' +] -test_vegas_pdf = executable( - 'test_vegas_pdf', - 'test_vegas_pdf.cpp', +foreach p : programs + exe = executable( + p, + p + '.cpp', + cpp_args : '-DGTEST_HAS_THREAD=0', + include_directories : incdir, + link_with : [ libgtest, libgtest_main ] + ) + + test(p, exe) +endforeach + +test_genz_integrand = executable( + 'test_genz_integrand', + 'test_genz_integrand.cpp', cpp_args : '-DGTEST_HAS_THREAD=0', include_directories : incdir, - link_with : [ libgtest, libgtest_main ] + link_with : [ libgenz, libgtest, libgtest_main ] ) +test('test_genz_integrand', test_genz_integrand, timeout : 120) + if get_option('mpi') libgtest_mpi_main = static_library( 'gtest-mpi-main', 'gtest/gtest.h', 'gtest_mpi_main.cpp', cpp_args : '-DGTEST_HAS_PTHREAD=0', - dependencies : mpi + dependencies : mpi_dep ) test_mpi_numerical_results = executable( 'test_mpi_numerical_results', 'test_numerical_results.cpp', cpp_args : [ '-DGTEST_HAS_THREAD=0', '-DHEP_USE_MPI' ], - dependencies : mpi, + dependencies : mpi_dep, include_directories : incdir, link_with : [ libgtest, libgtest_mpi_main ] ) @@ -113,13 +74,3 @@ if get_option('mpi') test('test_mpi_numerical_results', mpiexec, args : [ '-np', '2', test_mpi_numerical_results]) endif - -test('test_discrete_distribution', test_discrete_distribution) -test('test_distributions', test_distributions) -test('test_genz_integrand', test_genz_integrand, timeout : 120) -test('test_mc_helper', test_mc_helper) -test('test_mc_point', test_mc_point) -test('test_mc_result', test_mc_result) -test('test_numerical_results', test_numerical_results) -test('test_vegas_icdf_bug', test_vegas_icdf_bug) -test('test_vegas_pdf', test_vegas_pdf)