CMake: Add extra targets to run single benchmark using CMake generator
Add custom targets with '_benchmark' suffixes to make run of benchmarks using generators possible, e.g.: $ ninja tst_bench_qudpsocket_benchmark Extend '-[no]make' option to pass benchmark. Rework '-[no]make' processing to unify these options processing. Also looks like it doesn't make sense to enable benchmarks without having test enabled. So '-DQT_BUILD_BENCHMARKS' enables test as own dependency automatically. Task-number: QTBUG-89076 Pick-to: 6.0 Change-Id: Ieee9eadaf6d75a1efec120242d6eb786ace1b071 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
886db3a2f3
commit
61d5b01972
@ -335,6 +335,12 @@ macro(qt_build_repo_begin)
|
||||
add_custom_target(host_tools)
|
||||
add_custom_target(bootstrap_tools)
|
||||
endif()
|
||||
|
||||
# Add benchmark meta target. It's collection of all benchmarks added/registered by
|
||||
# 'qt_internal_add_benchmark' helper.
|
||||
if(NOT TARGET benchmark)
|
||||
add_custom_target(benchmark)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(qt_build_repo_end)
|
||||
|
@ -603,6 +603,30 @@ function(guess_compiler_from_mkspec)
|
||||
set(cmake_args "${cmake_args}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(check_qt_build_parts type)
|
||||
set(input "INPUT_${type}")
|
||||
set(buildFlag "TRUE")
|
||||
if("${type}" STREQUAL "nomake")
|
||||
set(buildFlag "FALSE")
|
||||
endif()
|
||||
|
||||
list(APPEND knownParts "tests" "examples" "benchmarks")
|
||||
|
||||
foreach(part ${${input}})
|
||||
if(part IN_LIST knownParts)
|
||||
qt_feature_normalize_name("${part}" partUpperCase)
|
||||
string(TOUPPER "${partUpperCase}" partUpperCase)
|
||||
push("-DQT_BUILD_${partUpperCase}=${buildFlag}")
|
||||
continue()
|
||||
elseif("${part}" STREQUAL "tools" AND "${type}" STREQUAL "make")
|
||||
# default true ignored
|
||||
continue()
|
||||
endif()
|
||||
qtConfAddWarning("'-${type} ${part}' is not implemented yet.")
|
||||
endforeach()
|
||||
set(cmake_args "${cmake_args}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
drop_input(commercial)
|
||||
drop_input(confirm-license)
|
||||
translate_boolean_input(precompile_header BUILD_WITH_PCH)
|
||||
@ -662,33 +686,8 @@ endif()
|
||||
drop_input(make)
|
||||
drop_input(nomake)
|
||||
|
||||
foreach(part ${INPUT_nomake})
|
||||
if("${part}" STREQUAL "tests")
|
||||
push("-DQT_BUILD_TESTS=OFF")
|
||||
continue()
|
||||
endif()
|
||||
if("${part}" STREQUAL "examples")
|
||||
push("-DQT_BUILD_EXAMPLES=OFF")
|
||||
continue()
|
||||
endif()
|
||||
qtConfAddWarning("'-nomake ${part}' is not implemented yet.")
|
||||
endforeach()
|
||||
|
||||
foreach(part ${INPUT_make})
|
||||
if("${part}" STREQUAL "tests")
|
||||
push("-DQT_BUILD_TESTS=ON")
|
||||
continue()
|
||||
endif()
|
||||
if("${part}" STREQUAL "examples")
|
||||
push("-DQT_BUILD_EXAMPLES=ON")
|
||||
continue()
|
||||
endif()
|
||||
if("${part}" STREQUAL "tools")
|
||||
# default
|
||||
continue()
|
||||
endif()
|
||||
qtConfAddWarning("'-make ${part}' is not implemented yet.")
|
||||
endforeach()
|
||||
check_qt_build_parts(nomake)
|
||||
check_qt_build_parts(make)
|
||||
|
||||
drop_input(debug)
|
||||
drop_input(release)
|
||||
|
@ -125,6 +125,12 @@ else()
|
||||
set(__build_benchmarks OFF)
|
||||
endif()
|
||||
|
||||
# Build Benchmarks
|
||||
option(QT_BUILD_BENCHMARKS "Build Qt Benchmarks" ${__build_benchmarks})
|
||||
if(QT_BUILD_BENCHMARKS)
|
||||
set(_qt_build_tests_default ON)
|
||||
endif()
|
||||
|
||||
## Set up testing
|
||||
option(QT_BUILD_TESTS "Build the testing tree." ${_qt_build_tests_default})
|
||||
unset(_qt_build_tests_default)
|
||||
@ -157,9 +163,6 @@ enable_testing()
|
||||
option(QT_BUILD_EXAMPLES "Build Qt examples" OFF)
|
||||
option(QT_BUILD_EXAMPLES_BY_DEFAULT "Should examples be built as part of the default 'all' target." ON)
|
||||
|
||||
# Build Benchmarks
|
||||
option(QT_BUILD_BENCHMARKS "Build Qt Benchmarks" ${__build_benchmarks})
|
||||
|
||||
## Find host tools (if non native):
|
||||
set(QT_HOST_PATH "" CACHE PATH "Installed Qt host directory path, used for cross compiling.")
|
||||
|
||||
|
@ -33,6 +33,17 @@ function(qt_internal_add_benchmark target)
|
||||
${exec_args}
|
||||
)
|
||||
|
||||
# Add a ${target}_benchmark generator target, to run single benchmark more easily.
|
||||
# TODO: Need to use test wrapper script with propagated environment variables to run benchmarks.
|
||||
add_custom_target("${target}_benchmark"
|
||||
VERBATIM
|
||||
COMMENT "Running benchmark ${target}"
|
||||
COMMAND "$<TARGET_FILE:${target}>"
|
||||
)
|
||||
add_dependencies("${target}_benchmark" "${target}")
|
||||
|
||||
#Add benchmark to meta target.
|
||||
add_dependencies("benchmark" "${target}_benchmark")
|
||||
endfunction()
|
||||
|
||||
# Simple wrapper around qt_internal_add_executable for manual tests which insure that
|
||||
|
@ -71,12 +71,15 @@ qt_commandline_option(incredibuild-xge TYPE boolean NAME incredibuild_xge)
|
||||
qt_commandline_option(libudev TYPE boolean)
|
||||
qt_commandline_option(linker TYPE optionalString VALUES bfd gold lld)
|
||||
qt_commandline_option(ltcg TYPE boolean)
|
||||
qt_commandline_option(make TYPE addString VALUES examples libs tests tools)
|
||||
# special case begin
|
||||
qt_commandline_option(make TYPE addString VALUES examples libs tests tools
|
||||
benchmarks)
|
||||
# special case end
|
||||
qt_commandline_option(make-tool TYPE string)
|
||||
qt_commandline_option(mips_dsp TYPE boolean)
|
||||
qt_commandline_option(mips_dspr2 TYPE boolean)
|
||||
qt_commandline_option(mp TYPE boolean NAME msvc_mp)
|
||||
qt_commandline_option(nomake TYPE addString VALUES examples tests tools)
|
||||
qt_commandline_option(nomake TYPE addString VALUES examples tests tools benchmarks) # special case
|
||||
qt_commandline_option(opensource TYPE void NAME commercial VALUE no)
|
||||
qt_commandline_option(optimize-debug TYPE boolean NAME optimize_debug)
|
||||
qt_commandline_option(optimize-size TYPE boolean NAME optimize_size)
|
||||
|
Loading…
Reference in New Issue
Block a user