Skip to content

Commit

Permalink
Improve support for building with Meson
Browse files Browse the repository at this point in the history
Incorporate improvements suggested by Meson maintainer in
mesonbuild/wrapdb#643 .
  • Loading branch information
mikecrowe committed Sep 26, 2022
1 parent 8d47147 commit 3875016
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 28 deletions.
6 changes: 3 additions & 3 deletions meson.build
Expand Up @@ -9,9 +9,9 @@ project(
'catch2',
'cpp',
version : '3.1.0',
license: 'Boost 1.0')
pkg = import('pkgconfig')
cpp = meson.get_compiler('cpp')
license: 'BSL-1.0',
meson_version: '>=0.49.0'
)

subdir('src/catch2')
subdir('tests')
58 changes: 34 additions & 24 deletions src/catch2/meson.build
Expand Up @@ -4,16 +4,19 @@
# https://www.boost.org/LICENSE_1_0.txt)

# SPDX-License-Identifier: BSL-1.0
pkg = import('pkgconfig')

conf_data = configuration_data()
conf_data.set('CATCH_CONFIG_DEFAULT_REPORTER', 'console')
conf_data.set('CATCH_CONFIG_CONSOLE_WIDTH', '80')

configure_file(input: 'catch_user_config.hpp.in',
output: 'catch_user_config.hpp',
format: 'cmake@',
install_dir: get_option('includedir') / 'catch2',
configuration: conf_data)
configure_file(
input: 'catch_user_config.hpp.in',
output: 'catch_user_config.hpp',
format: 'cmake@',
install_dir: get_option('includedir') / 'catch2',
configuration: conf_data
)

benchmark_headers = [
'benchmark/catch_benchmark.hpp',
Expand Down Expand Up @@ -302,46 +305,53 @@ sources = benchmark_sources + internal_sources + reporter_sources
# make it compatible with newer meson.
include_subdir = 'catch2'
foreach file : headers
file_path = file.split('/')
file_path = file.split('/')

folder = ''
foreach path : file_path
if path != file_path[-1]
folder = folder / path
endif
endforeach
folder = ''
foreach path : file_path
if path != file_path[-1]
folder = folder / path
endif
endforeach

install_headers(file, subdir: join_paths(include_subdir, folder))
install_headers(file, subdir: join_paths(include_subdir, folder))
endforeach

catch2 = static_library(
'Catch2',
sources,
include_directories : '..',
dependencies : [],
install : true)
install : true
)

catch2_dep = declare_dependency(
link_with: catch2,
include_directories: '..'
)

pkg.generate(
catch2,
filebase: 'catch2',
name : 'Catch2',
libraries : catch2,
version : meson.project_version(),
description : 'A modern, C++-native, test framework for C++14 and above',
url: 'https://github.com/catchorg/Catch2',
url: 'https://github.com/catchorg/Catch2'
)

catch2_with_main = static_library(
'Catch2Main',
[ 'internal/catch_main.cpp' ],
link_with: catch2,
include_directories : '..',
dependencies : [],
install : true)
install : true
)

catch2_with_main_dep = declare_dependency(
link_with: [ catch2, catch2_with_main ],
include_directories: '..'
)

pkg.generate(
catch2_with_main,
filebase : 'catch2-with-main',
name : 'Catch2-With-Main',
libraries : catch2_with_main,
version : meson.project_version(),
description : 'A modern, C++-native, test framework for C++14 and above (links in default main)',
requires : 'catch2 = ' + meson.project_version()
)
3 changes: 2 additions & 1 deletion tests/meson.build
Expand Up @@ -65,6 +65,7 @@ self_test = executable(
'self_test',
self_test_sources,
include_directories : '../src',
link_with : [ catch2_with_main, catch2 ])
link_with : [ catch2_with_main, catch2 ]
)

test('SelfTest', self_test)

0 comments on commit 3875016

Please sign in to comment.