From 504e7bc8e64567b677d0b18ade5839725bfa724e Mon Sep 17 00:00:00 2001 From: Phillip Johnston Date: Sat, 9 May 2020 05:04:07 -0700 Subject: [PATCH] Meson build improvement: Don't build tests by default if used as a subproject (#218) * Don't build tests by default if used as a subproject * Refine Clang logic --- meson.build | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 950832d4..6f868f0b 100644 --- a/meson.build +++ b/meson.build @@ -134,15 +134,14 @@ etl_test_sources = files( 'test/test_queue_spsc_locked_small.cpp', 'test/test_scaled_rounding.cpp', 'test/test_state_chart.cpp', - 'test/test_type_select.cpp', 'test/test_vector_external_buffer.cpp', 'test/test_vector_pointer_external_buffer.cpp', ) # These files currently fail to compile with OS X clang at the very least -if meson.get_compiler('cpp').get_id() == 'clang' - message('Some test files fail to compile with clang and are disabled.') +if meson.get_compiler('cpp').get_id() == 'clang' and build_machine.system() == 'darwin' + message('Some test files fail to compile with OS X clang and are disabled.') else etl_test_sources += files( 'test/test_deque.cpp', @@ -197,7 +196,12 @@ etl_unit_tests = executable('etl_unit_tests', '-DETL_DEBUG', ], native: true, - install: false + install: false, + # Don't build tests by default if we are a subproject + build_by_default: meson.is_subproject() == false ) -test('ETL Unit Tests', etl_unit_tests) +# Only register tests with the test runner when built as a primary project +if meson.is_subproject() == false + test('ETL Unit Tests', etl_unit_tests) +endif