summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake32
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake2
-rw-r--r--cmake/QtSetup.cmake11
3 files changed, 44 insertions, 1 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)
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index 4bf09e5b15..cb2070f773 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -159,7 +159,7 @@ macro(qt_build_tests)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/auto/CMakeLists.txt")
add_subdirectory(auto)
endif()
- if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/CMakeLists.txt")
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/CMakeLists.txt" AND QT_BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
endmacro()
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
index 6f42e337da..837b81db4d 100644
--- a/cmake/QtSetup.cmake
+++ b/cmake/QtSetup.cmake
@@ -73,8 +73,16 @@ if(FEATURE_developer_build)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()
set(QT_BUILD_TESTING ON)
+ set(__build_benchmarks ON)
+
+ # Disable benchmarks for single configuration generators which do not build
+ # with release configuration.
+ if (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
+ set(__build_benchmarks OFF)
+ endif()
else()
set(QT_BUILD_TESTING OFF)
+ set(__build_benchmarks OFF)
endif()
## Set up testing
@@ -85,6 +93,9 @@ enable_testing()
# Set up building of examples.
option(BUILD_EXAMPLES "Build Qt examples" ON)
+# Build Benchmarks
+option(QT_BUILD_BENCHMARKS "Build Qt Benchmarks" ${__build_benchmarks})
+
## Android platform settings
if(ANDROID)
include(QtPlatformAndroid)