Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using system absl #56

Merged
merged 1 commit into from
May 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 75 additions & 59 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,34 +1,51 @@
project('ashuffle', ['c', 'cpp'], default_options: ['cpp_std=c++17', 'warning_level=2'])

cmake = import('cmake')
cpp = meson.get_compiler('cpp')

absl = cmake.subproject('absl', cmake_options: [
'-DCMAKE_CXX_STANDARD=17',
])

# Note: Unfortunately, meson does not pull in the "dependent" libraries
# correctly so we have to list them here. If you take a dependency on some
# addtional absl features, you will probably need to add more `dependency`
# lines here. This could also be broken on upgrades.
absl_all = [
# absl dependencies need to be explicited...
# It might be possible to use cmake dependencies (e.g. "absl:string"
# defined in abslTargets.cmake in the future but that does not seem
# worth the time trying to figure that out.
absl_libs = [
# Via Base:
absl.dependency('raw_logging_internal'),
'raw_logging_internal',

# Via Strings:
absl.dependency('int128'),
absl.dependency('str_format_internal'),
absl.dependency('strings_internal'),
absl.dependency('strings'),
'int128',
'str_format_internal',
'strings_internal',
'strings'
]

absl_deps = []
if not get_option('unsupported_use_system_absl')
absl = cmake.subproject('absl', cmake_options: [
'-DCMAKE_CXX_STANDARD=17',
])

absl_deps = []
foreach lib : absl_libs
absl_deps += absl.dependency(lib)
endforeach
else
# note that the system's absl needs to be compiled for C++17 standard
# or final link will fail.
foreach lib : absl_libs
dep = cpp.find_library('absl_' + lib)
if dep.found()
absl_deps += dep
endif
endforeach
endif
libmpdclient = dependency('libmpdclient')

sources = files(
'src/ashuffle.cc',
'src/load.cc',
'src/args.cc',
'src/getpass.cc',
'src/rule.cc',
'src/args.cc',
'src/getpass.cc',
'src/rule.cc',
'src/shuffle.cc',
)

Expand All @@ -38,55 +55,54 @@ src_inc = include_directories('src')
root_inc = include_directories('.')

ashuffle = executable(
'ashuffle',
executable_sources,
dependencies: absl_all + [libmpdclient],
install: true
'ashuffle',
executable_sources,
dependencies: absl_deps + [libmpdclient],
install: true
)

clang_tidy = run_target('ashuffle-clang-tidy',
command : files('scripts/run-clang-tidy') + executable_sources
)

# We only generate tests if we are *not running in tidy mode
if get_option('tests').enabled()

googletest = cmake.subproject('googletest', cmake_options: [
'-DBUILD_GMOCK=ON',
'-DCMAKE_CXX_STANDARD=17',
])

gtest_deps = [
dependency('threads'),
googletest.dependency('gtest'),
googletest.dependency('gmock'),
googletest.dependency('gmock_main'),
]

mpdfake_inc = include_directories('t')
mpdfake_dep = declare_dependency(include_directories : mpdfake_inc)

test_options = [
'werror=true',
]

tests = {
'rule': ['t/rule_test.cc'],
'shuffle': ['t/shuffle_test.cc'],
'load': ['t/load_test.cc'],
'args': ['t/args_test.cc'],
'ashuffle': ['t/ashuffle_test.cc'],
}

foreach test_name, test_sources : tests
test_exe = executable(
test_name + '_test',
sources + test_sources,
include_directories : src_inc,
dependencies : absl_all + gtest_deps + [mpdfake_dep],
override_options : test_options,
)
test(test_name, test_exe)
endforeach
googletest = cmake.subproject('googletest', cmake_options: [
'-DBUILD_GMOCK=ON',
'-DCMAKE_CXX_STANDARD=17',
])

gtest_deps = [
dependency('threads'),
googletest.dependency('gtest'),
googletest.dependency('gmock'),
googletest.dependency('gmock_main'),
]

mpdfake_inc = include_directories('t')
mpdfake_dep = declare_dependency(include_directories : mpdfake_inc)

test_options = [
'werror=true',
]

tests = {
'rule': ['t/rule_test.cc'],
'shuffle': ['t/shuffle_test.cc'],
'load': ['t/load_test.cc'],
'args': ['t/args_test.cc'],
'ashuffle': ['t/ashuffle_test.cc'],
}

foreach test_name, test_sources : tests
test_exe = executable(
test_name + '_test',
sources + test_sources,
include_directories : src_inc,
dependencies : absl_deps, gtest_deps + [mpdfake_dep],
override_options : test_options,
)
test(test_name, test_exe)
endforeach

endif # tests feature
2 changes: 1 addition & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
option('tidy_mode', type : 'feature', value : 'disabled')
option('tests', type : 'feature', value : 'disabled')
option('unsupported_use_system_absl', type : 'boolean', value : 'false')