build system: check for Google Benchmark, compile benchmark if source exists

This commit is contained in:
Moritz Bunkus 2017-11-16 15:15:29 +01:00
parent 2421163189
commit abb66a5486
5 changed files with 37 additions and 0 deletions

1
.gitignore vendored
View File

@ -51,6 +51,7 @@
/rake.d/dependency.d
/share/icons/*/*.h
/src/*/qt_resources.cpp
/src/benchmark/
/src/common/common.h.gch
/src/common/common_pch.h.[gp]ch
/src/common/common_pch.h.pch-????????

View File

@ -115,6 +115,8 @@ def setup_globals
$unwrapped_po = %{ca es eu it nl uk pl sr_RS@latin tr}
$po_multiple_sources = %{sv}
$benchmark_sources = FileList["src/benchmark/*.cpp"].to_a if c?(:GOOGLE_BENCHMARK)
cflags_common = "-Wall -Wno-comment -Wfatal-errors #{c(:WLOGICAL_OP)} #{c(:WNO_MISMATCHED_TAGS)} #{c(:WNO_SELF_ASSIGN)} #{c(:QUNUSED_ARGUMENTS)}"
cflags_common += " #{c(:WNO_INCONSISTENT_MISSING_OVERRIDE)} #{c(:WNO_POTENTIALLY_EVALUATED_EXPRESSION)}"
cflags_common += " #{c(:OPTIMIZATION_CFLAGS)} -D_FILE_OFFSET_BITS=64"
@ -211,6 +213,8 @@ def define_default_task
# needed for running the tests.
targets << "apps:tools:ebml_validator" if c(:host) == c(:build)
targets << "src/benchmark/benchmark" if c?(:GOOGLE_BENCHMARK) && !$benchmark_sources.empty?
task :default => targets do
puts "Done. Enjoy :)"
end
@ -843,6 +847,7 @@ task :clean do
src/*/qt_resources.cpp
src/info/ui/*.h
src/mkvtoolnix-gui/forms/**/*.h
src/benchmark/benchmark
tests/unit/all
tests/unit/merge/merge
tests/unit/propedit/propedit
@ -1057,6 +1062,19 @@ if $build_mkvtoolnix_gui
create
end
#
# benchmark
#
if c?(:GOOGLE_BENCHMARK) && !$benchmark_sources.empty?
Application.new("src/benchmark/benchmark").
description("Build the benchmark executable").
aliases(:benchmark, :bench).
sources($benchmark_sources).
libraries($common_libs, :benchmark).
create
end
#
# Applications in src/tools
#

16
ac/benchmark.m4 Normal file
View File

@ -0,0 +1,16 @@
AC_DEFUN([AX_GOOGLE_BENCHMARK],[
GOOGLE_BENCHMARK=yes
CPPFLAGS_SAVED="$CPPFLAGS"
AC_LANG_PUSH(C++)
AC_CHECK_LIB([benchmark],[main],[true],[GOOGLE_BENCHMARK=no])
AC_CHECK_HEADERS([benchmark/benchmark.h],[true],[GOOGLE_BENCHMARK=no])
AC_LANG_POP
CPPFLAGS="$CPPFLAGS_SAVED"
AC_SUBST(GOOGLE_BENCHMARK)
])
AX_GOOGLE_BENCHMARK

View File

@ -87,6 +87,7 @@ EGREP = @EGREP@
EXTRA_CFLAGS = @EXTRA_CFLAGS@
EXTRA_LDFLAGS = @EXTRA_LDFLAGS@
FSTACK_PROTECTOR = @FSTACK_PROTECTOR@
GOOGLE_BENCHMARK = @GOOGLE_BENCHMARK@
GTEST_TYPE = @GTEST_TYPE@
LDFLAGS_RPATHS = @LDFLAGS_RPATHS@
FLAC_LIBS = @FLAC_LIBS@

View File

@ -44,6 +44,7 @@ m4_include(ac/ax_boost_system.m4)
m4_include(ac/ax_boost_date_time.m4)
m4_include(ac/boost.m4)
m4_include(ac/gtest.m4)
m4_include(ac/benchmark.m4)
m4_include(ac/pandoc.m4)
m4_include(ac/ax_docbook.m4)
m4_include(ac/tiocgwinsz.m4)