summaryrefslogtreecommitdiffstats
path: root/cmake/QtBuild.cmake
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-10-28 15:35:47 +0100
committerLeander Beernaert <leander.beernaert@qt.io>2019-11-04 15:48:30 +0000
commitcd9813d2763adb715d1cf1a37b86439fea255172 (patch)
treed0c036f4f7828daa2d8fecdf180b329dac28d439 /cmake/QtBuild.cmake
parent56115dba42a4376fd6b24541dee023a675612ce9 (diff)
Add support for benchmark conversion
Convert benchmark executables to add_qt_benchmark(). Currently add_qt_benchmark just calls add_qt_executable() and ensures that it they build under CMAKE_CURRENT_BUILD_DIR and do not install. Add QT_BUILD_BENCHMARKS option to enable/disable building of benchmarks. Change-Id: Id0bc676698d21d50048d97d9abef51d92ccb6638 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtBuild.cmake')
-rw-r--r--cmake/QtBuild.cmake32
1 files changed, 32 insertions, 0 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index c47271f9de..1c46b09eb3 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -2351,6 +2351,38 @@ function(add_qt_executable name)
endif()
endfunction()
+# Simple wrapper around add_qt_executable for benchmarks which insure that
+# the binary is built under ${CMAKE_CURRENT_BINARY_DIR} and never installed.
+# See add_qt_executable() for more details.
+function(add_qt_benchmark target)
+
+ qt_parse_all_arguments(arg "add_qt_benchmark"
+ "${__add_qt_executable_optional_args}"
+ "${__add_qt_executable_single_args}"
+ "${__add_qt_executable_multi_args}"
+ ${ARGN}
+ )
+
+ qt_remove_args(exec_args
+ ARGS_TO_REMOVE
+ ${target}
+ OUTPUT_DIRECTORY
+ INSTALL_DIRECTORY
+ ALL_ARGS
+ "${__add_qt_executable_optional_args}"
+ "${__add_qt_executable_single_args}"
+ "${__add_qt_executable_multi_args}"
+ ARGS
+ ${ARGV}
+ )
+
+ add_qt_executable(${target}
+ NO_INSTALL # we don't install benchmarks
+ OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" # avoid polluting bin directory
+ ${exec_args}
+ )
+
+endfunction()
# This function creates a CMake test target with the specified name for use with CTest.
function(add_qt_test name)