CMake: Name QT_NO_MAKE_*/BUILD_* variables consistently

For consistency, apply the following renamings:
QT_NO_MAKE_EXAMPLES -> QT_BUILD_EXAMPLES_BY_DEFAULT
QT_NO_MAKE_TESTS    -> QT_BUILD_TESTS_BY_DEFAULT
QT_NO_MAKE_TOOLS    -> QT_BUILD_TOOLS_BY_DEFAULT
BUILD_EXAMPLES      -> QT_BUILD_EXAMPLES
BUILD_TESTING       -> QT_BUILD_TESTS

This should help to better convey the difference between "BUILD" and
"NO_MAKE".

To configure tests, but not to build them by default, pass the
following to CMake:
-DQT_BUILD_TESTS=ON -DQT_BUILD_TESTS_BY_DEFAULT=OFF

Analoguous for examples:
-DQT_BUILD_EXAMPLES=ON -DQT_BUILD_EXAMPLES_BY_DEFAULT=OFF

Tools can be excluded from the default build with:
-DBUILD_TOOLS_BY_DEFAULT=OFF

The variable BUILD_TESTING is still available and initialized with the
value of QT_BUILD_TESTS.

Change-Id: Ie5f29dfbdca8bfa8d687981dfe8c19c0397ca080
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit fb21a5ce1a5831fab2af5e4d301600d6a6211e5d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Joerg Bornemann 2020-10-19 13:35:15 +02:00 committed by Qt Cherry-pick Bot
parent c1f9e6ce98
commit 4cd9ac52ed
13 changed files with 51 additions and 51 deletions

View File

@ -96,9 +96,9 @@ if(NOT QT_BUILD_STANDALONE_TESTS)
add_subdirectory(src) add_subdirectory(src)
endif() endif()
if(BUILD_TESTING) if(QT_BUILD_TESTS)
add_subdirectory(tests) add_subdirectory(tests)
if(QT_NO_MAKE_TESTS) if(NOT QT_BUILD_TESTS_BY_DEFAULT)
set_property(DIRECTORY tests PROPERTY EXCLUDE_FROM_ALL TRUE) set_property(DIRECTORY tests PROPERTY EXCLUDE_FROM_ALL TRUE)
endif() endif()
endif() endif()
@ -129,9 +129,9 @@ endif()
qt_build_repo_end() qt_build_repo_end()
if(NOT QT_BUILD_STANDALONE_TESTS AND BUILD_EXAMPLES) if(NOT QT_BUILD_STANDALONE_TESTS AND QT_BUILD_EXAMPLES)
add_subdirectory(examples) add_subdirectory(examples)
if(QT_NO_MAKE_EXAMPLES) if(NOT QT_BUILD_EXAMPLES_BY_DEFAULT)
set_property(DIRECTORY examples PROPERTY EXCLUDE_FROM_ALL TRUE) set_property(DIRECTORY examples PROPERTY EXCLUDE_FROM_ALL TRUE)
endif() endif()
endif() endif()

View File

@ -372,7 +372,7 @@ macro(qt_build_repo)
# If testing is enabled, try to find the qtbase Test package. # If testing is enabled, try to find the qtbase Test package.
# Do this before adding src, because there might be test related conditions # Do this before adding src, because there might be test related conditions
# in source. # in source.
if (BUILD_TESTING AND NOT QT_BUILD_STANDALONE_TESTS) if (QT_BUILD_TESTS AND NOT QT_BUILD_STANDALONE_TESTS)
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test) find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Test)
endif() endif()
@ -386,20 +386,20 @@ macro(qt_build_repo)
endif() endif()
endif() endif()
if (BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt") if (QT_BUILD_TESTS AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt")
add_subdirectory(tests) add_subdirectory(tests)
if(QT_NO_MAKE_TESTS) if(NOT QT_BUILD_TESTS_BY_DEFAULT)
set_property(DIRECTORY tests PROPERTY EXCLUDE_FROM_ALL TRUE) set_property(DIRECTORY tests PROPERTY EXCLUDE_FROM_ALL TRUE)
endif() endif()
endif() endif()
qt_build_repo_end() qt_build_repo_end()
if (BUILD_EXAMPLES AND BUILD_SHARED_LIBS if(QT_BUILD_EXAMPLES AND BUILD_SHARED_LIBS
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt"
AND NOT QT_BUILD_STANDALONE_TESTS) AND NOT QT_BUILD_STANDALONE_TESTS)
add_subdirectory(examples) add_subdirectory(examples)
if(QT_NO_MAKE_EXAMPLES) if(NOT QT_BUILD_EXAMPLES_BY_DEFAULT)
set_property(DIRECTORY examples PROPERTY EXCLUDE_FROM_ALL TRUE) set_property(DIRECTORY examples PROPERTY EXCLUDE_FROM_ALL TRUE)
endif() endif()
endif() endif()

View File

@ -39,11 +39,11 @@ set(QT_SOURCE_TREE "@QT_SOURCE_TREE@" CACHE PATH
"A path to the source tree of the previously configured QtBase project." FORCE) "A path to the source tree of the previously configured QtBase project." FORCE)
# Propagate decision of building tests and examples to other repositories. # Propagate decision of building tests and examples to other repositories.
set(BUILD_TESTING @BUILD_TESTING@ CACHE BOOL "Build the testing tree.") set(QT_BUILD_TESTS @QT_BUILD_TESTS@ CACHE BOOL "Build the testing tree.")
set(BUILD_EXAMPLES @BUILD_EXAMPLES@ CACHE BOOL "Build Qt examples") set(QT_BUILD_EXAMPLES @QT_BUILD_EXAMPLES@ CACHE BOOL "Build Qt examples")
set(QT_NO_MAKE_TESTS @QT_NO_MAKE_TESTS@ CACHE BOOL set(QT_BUILD_TESTS_BY_DEFAULT @QT_BUILD_TESTS_BY_DEFAULT@ CACHE BOOL
"Should tests be built as part of the default 'all' target.") "Should tests be built as part of the default 'all' target.")
set(QT_NO_MAKE_EXAMPLES @QT_NO_MAKE_EXAMPLES@ CACHE BOOL set(QT_BUILD_EXAMPLES_BY_DEFAULT @QT_BUILD_EXAMPLES_BY_DEFAULT@ CACHE BOOL
"Should examples be built as part of the default 'all' target.") "Should examples be built as part of the default 'all' target.")
# Propagate usage of ccache. # Propagate usage of ccache.

View File

@ -642,11 +642,11 @@ endfunction()
function(qt_get_build_parts out_var) function(qt_get_build_parts out_var)
set(parts "libs") set(parts "libs")
if(BUILD_EXAMPLES AND NOT QT_NO_MAKE_EXAMPLES) if(QT_BUILD_EXAMPLES AND QT_BUILD_EXAMPLES_BY_DEFAULT)
list(APPEND parts "examples") list(APPEND parts "examples")
endif() endif()
if(BUILD_TESTING AND NOT QT_NO_MAKE_TESTS) if(QT_BUILD_TESTS AND QT_BUILD_TESTS_BY_DEFAULT)
list(APPEND parts "tests") list(APPEND parts "tests")
endif() endif()

View File

@ -664,11 +664,11 @@ drop_input(nomake)
foreach(part ${INPUT_nomake}) foreach(part ${INPUT_nomake})
if("${part}" STREQUAL "tests") if("${part}" STREQUAL "tests")
push("-DBUILD_TESTING=OFF") push("-DQT_BUILD_TESTS=OFF")
continue() continue()
endif() endif()
if("${part}" STREQUAL "examples") if("${part}" STREQUAL "examples")
push("-DBUILD_EXAMPLES=OFF") push("-DQT_BUILD_EXAMPLES=OFF")
continue() continue()
endif() endif()
qtConfAddWarning("'-nomake ${part}' is not implemented yet.") qtConfAddWarning("'-nomake ${part}' is not implemented yet.")
@ -676,11 +676,11 @@ endforeach()
foreach(part ${INPUT_make}) foreach(part ${INPUT_make})
if("${part}" STREQUAL "tests") if("${part}" STREQUAL "tests")
push("-DBUILD_TESTING=ON") push("-DQT_BUILD_TESTS=ON")
continue() continue()
endif() endif()
if("${part}" STREQUAL "examples") if("${part}" STREQUAL "examples")
push("-DBUILD_EXAMPLES=ON") push("-DQT_BUILD_EXAMPLES=ON")
continue() continue()
endif() endif()
if("${part}" STREQUAL "tools") if("${part}" STREQUAL "tools")

View File

@ -106,13 +106,13 @@ if(FEATURE_developer_build)
else() else()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif() endif()
set(QT_BUILD_TESTING ON) set(_qt_build_tests_default ON)
set(__build_benchmarks ON) set(__build_benchmarks ON)
# Tests are not built by default with qmake for iOS and friends, and thus the overall build # Tests are not built by default with qmake for iOS and friends, and thus the overall build
# tends to fail. Disable them by default when targeting uikit. # tends to fail. Disable them by default when targeting uikit.
if(UIKIT OR ANDROID) if(UIKIT OR ANDROID)
set(QT_BUILD_TESTING OFF) set(_qt_build_tests_default OFF)
endif() endif()
# Disable benchmarks for single configuration generators which do not build # Disable benchmarks for single configuration generators which do not build
@ -121,41 +121,41 @@ if(FEATURE_developer_build)
set(__build_benchmarks OFF) set(__build_benchmarks OFF)
endif() endif()
else() else()
set(QT_BUILD_TESTING OFF) set(_qt_build_tests_default OFF)
set(__build_benchmarks OFF) set(__build_benchmarks OFF)
endif() endif()
## Set up testing ## Set up testing
option(BUILD_TESTING "Build the testing tree." ${QT_BUILD_TESTING}) option(QT_BUILD_TESTS "Build the testing tree." ${_qt_build_tests_default})
unset(_qt_build_tests_default)
option(QT_BUILD_TESTS_BY_DEFAULT "Should tests be built as part of the default 'all' target." ON)
if(QT_BUILD_STANDALONE_TESTS) if(QT_BUILD_STANDALONE_TESTS)
set(QT_BUILD_TESTING ON)
# BuildInternals might have set it to OFF on initial configuration. So force it to ON when # BuildInternals might have set it to OFF on initial configuration. So force it to ON when
# building standalone tests. # building standalone tests.
set(BUILD_TESTING ON CACHE BOOL "Build the testing tree." FORCE) set(QT_BUILD_TESTS ON CACHE BOOL "Build the testing tree." FORCE)
# Also force the tests to be built as part of the default build target. # Also force the tests to be built as part of the default build target.
set(QT_NO_MAKE_TESTS OFF CACHE BOOL set(QT_BUILD_TESTS_BY_DEFAULT ON CACHE BOOL
"Should examples be built as part of the default 'all' target." FORCE) "Should tests be built as part of the default 'all' target." FORCE)
endif() endif()
option(QT_NO_MAKE_TESTS "Should tests be built as part of the default 'all' target." OFF) set(BUILD_TESTING ${QT_BUILD_TESTS} CACHE INTERNAL "")
# When cross-building, we don't build tools by default. Sometimes this also covers Qt apps as well. # When cross-building, we don't build tools by default. Sometimes this also covers Qt apps as well.
# Like in qttools/assistant/assistant.pro, load(qt_app), which is guarded by a qtNomakeTools() call. # Like in qttools/assistant/assistant.pro, load(qt_app), which is guarded by a qtNomakeTools() call.
set(qt_no_make_tools_default OFF) set(_qt_build_tools_by_default_default ON)
if(CMAKE_CROSSCOMPILING AND NOT QT_BUILD_TOOLS_WHEN_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING AND NOT QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
set(qt_no_make_tools_default ON) set(_qt_build_tools_by_default_default OFF)
endif() endif()
option(QT_NO_MAKE_TOOLS "Should tools be built as part of the default 'all' target." option(QT_BUILD_TOOLS_BY_DEFAULT "Should tools be built as part of the default 'all' target."
"${qt_no_make_tools_default}") "${_qt_build_tools_by_default_default}")
unset(qt_no_make_tools_default) unset(_qt_build_tools_by_default_default)
include(CTest) include(CTest)
enable_testing() enable_testing()
option(BUILD_EXAMPLES "Build Qt examples" OFF) option(QT_BUILD_EXAMPLES "Build Qt examples" OFF)
option(QT_NO_MAKE_EXAMPLES "Should examples be built as part of the default 'all' target." OFF) option(QT_BUILD_EXAMPLES_BY_DEFAULT "Should examples be built as part of the default 'all' target." ON)
# Build Benchmarks # Build Benchmarks
option(QT_BUILD_BENCHMARKS "Build Qt Benchmarks" ${__build_benchmarks}) option(QT_BUILD_BENCHMARKS "Build Qt Benchmarks" ${__build_benchmarks})

View File

@ -417,11 +417,11 @@ function(qt_check_if_tools_will_be_built)
endfunction() endfunction()
# Equivalent of qmake's qtNomakeTools(directory1 directory2). # Equivalent of qmake's qtNomakeTools(directory1 directory2).
# If QT_NO_MAKE_TOOLS is true, then targets within the given directories will be excluded from the # If QT_BUILD_TOOLS_BY_DEFAULT is true, then targets within the given directories will be excluded
# default 'all' target, as well as from install phase. # from the default 'all' target, as well as from install phase. The private variable is checked by
# The private variable is checked by qt_internal_add_executable. # qt_internal_add_executable.
function(qt_exclude_tool_directories_from_default_target) function(qt_exclude_tool_directories_from_default_target)
if(QT_NO_MAKE_TOOLS) if(NOT QT_BUILD_TOOLS_BY_DEFAULT)
set(absolute_path_directories "") set(absolute_path_directories "")
foreach(directory ${ARGV}) foreach(directory ${ARGV})
list(APPEND absolute_path_directories "${CMAKE_CURRENT_SOURCE_DIR}/${directory}") list(APPEND absolute_path_directories "${CMAKE_CURRENT_SOURCE_DIR}/${directory}")

View File

@ -128,7 +128,7 @@ machine you're building on, regardless of the architecure you are targeting.
Build Qt regularly for your host system and install it into a directory of your choice using the Build Qt regularly for your host system and install it into a directory of your choice using the
``CMAKE_INSTALL_PREFIX`` variable. You are free to disable the build of tests and examples by ``CMAKE_INSTALL_PREFIX`` variable. You are free to disable the build of tests and examples by
passing ``-DBUILD_EXAMPLES=OFF`` and ``-DBUILD_TESTING=OFF``. passing ``-DQT_BUILD_EXAMPLES=OFF`` and ``-DQT_BUILD_TESTS=OFF``.
With this installation of Qt in place, which contains all tools needed, we can proceed to create a With this installation of Qt in place, which contains all tools needed, we can proceed to create a
new build of Qt that is cross-compiled to the target architecture of choice. You may proceed by new build of Qt that is cross-compiled to the target architecture of choice. You may proceed by

View File

@ -102,10 +102,10 @@ The effort of this is tracked in QTBUG-85373 and QTBUG-85349.
| -android-javac-source | -DQT_ANDROID_JAVAC_SOURCE=7 | Set the javac build source version. | | -android-javac-source | -DQT_ANDROID_JAVAC_SOURCE=7 | Set the javac build source version. |
| -android-javac-target | -DQT_ANDROID_JAVAC_TARGET=7 | Set the javac build target version. | | -android-javac-target | -DQT_ANDROID_JAVAC_TARGET=7 | Set the javac build target version. |
| -skip <repo> | -DBUILD_<repo>=OFF | | | -skip <repo> | -DBUILD_<repo>=OFF | |
| -make <part> | -DBUILD_TESTING=ON | A way to turn on tools explicitly is missing. | | -make <part> | -DQT_BUILD_TESTS=ON | A way to turn on tools explicitly is missing. |
| | -DBUILD_EXAMPLES=ON | | | | -DQT_BUILD_EXAMPLES=ON | |
| -nomake <part> | -DBUILD_TESTING=OFF | A way to turn off tools explicitly is missing. | | -nomake <part> | -DQT_BUILD_TESTS=OFF | A way to turn off tools explicitly is missing. |
| | -DBUILD_EXAMPLES=OFF | | | | -DQT_BUILD_EXAMPLES=OFF | |
| -no-gui | | | | -no-gui | | |
| -no-widgets | -DFEATURE_widgets=OFF | | | -no-widgets | -DFEATURE_widgets=OFF | |
| -no-dbus | -DFEATURE_dbus=OFF | | | -no-dbus | -DFEATURE_dbus=OFF | |

View File

@ -19,7 +19,7 @@ instructions:
- type: EnvironmentVariable - type: EnvironmentVariable
variableName: COIN_CMAKE_ARGS variableName: COIN_CMAKE_ARGS
# The lack of space between the non qtbase configure args and the rest of the args is important! # The lack of space between the non qtbase configure args and the rest of the args is important!
variableValue: "{{.Env.NON_QTBASE_CONFIGURE_ARGS}} -DBUILD_TESTING=OFF -DCMAKE_AUTOGEN_VERBOSE=ON {{.SourceDir}}" variableValue: "{{.Env.NON_QTBASE_CONFIGURE_ARGS}} -DQT_BUILD_TESTS=OFF -DCMAKE_AUTOGEN_VERBOSE=ON {{.SourceDir}}"
- !include "{{qt/qtbase}}/call_host_cmake.yaml" - !include "{{qt/qtbase}}/call_host_cmake.yaml"
- type: ExecuteCommand - type: ExecuteCommand
command: "{{.Env.ENV_PREFIX}} cmake --build . --parallel -v" command: "{{.Env.ENV_PREFIX}} cmake --build . --parallel -v"
@ -49,7 +49,7 @@ instructions:
- type: EnvironmentVariable - type: EnvironmentVariable
variableName: COIN_CMAKE_ARGS variableName: COIN_CMAKE_ARGS
# The lack of space between the non qtbase configure args and the rest of the args is important! # The lack of space between the non qtbase configure args and the rest of the args is important!
variableValue: "{{.Env.NON_QTBASE_TARGET_CONFIGURE_ARGS}} -DBUILD_TESTING=OFF -DCMAKE_AUTOGEN_VERBOSE=ON {{.SourceDir}}" variableValue: "{{.Env.NON_QTBASE_TARGET_CONFIGURE_ARGS}} -DQT_BUILD_TESTS=OFF -DCMAKE_AUTOGEN_VERBOSE=ON {{.SourceDir}}"
- !include "{{qt/qtbase}}/call_target_cmake.yaml" - !include "{{qt/qtbase}}/call_target_cmake.yaml"
- type: ExecuteCommand - type: ExecuteCommand
command: "{{.Env.TARGET_ENV_PREFIX}} cmake --build . --parallel -v" command: "{{.Env.TARGET_ENV_PREFIX}} cmake --build . --parallel -v"

View File

@ -17,7 +17,7 @@ instructions:
- type: ChangeDirectory - type: ChangeDirectory
directory: "{{.BuildDir}}" directory: "{{.BuildDir}}"
- type: ExecuteCommand - type: ExecuteCommand
command: "{{.Env.ENV_PREFIX}} cmake {{.Env.CONFIGURE_ARGS}} -DCMAKE_INSTALL_PREFIX:PATH={{.InstallDir}}/host -DBUILD_TESTING=OFF -DCMAKE_AUTOGEN_VERBOSE=ON {{.SourceDir}}" command: "{{.Env.ENV_PREFIX}} cmake {{.Env.CONFIGURE_ARGS}} -DCMAKE_INSTALL_PREFIX:PATH={{.InstallDir}}/host -DQT_BUILD_TESTS=OFF -DCMAKE_AUTOGEN_VERBOSE=ON {{.SourceDir}}"
executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution
maxTimeInSeconds: 6000 maxTimeInSeconds: 6000
maxTimeBetweenOutput: 1200 maxTimeBetweenOutput: 1200
@ -63,7 +63,7 @@ instructions:
property: platformDependency property: platformDependency
equals_value: null equals_value: null
- type: ExecuteCommand - type: ExecuteCommand
command: "{{.Env.TARGET_ENV_PREFIX}} cmake {{.Env.TARGET_CONFIGURE_ARGS}} -DCMAKE_INSTALL_PREFIX:PATH={{.InstallDir}}/target -DBUILD_TESTING=OFF -DCMAKE_AUTOGEN_VERBOSE=ON {{.SourceDir}}" command: "{{.Env.TARGET_ENV_PREFIX}} cmake {{.Env.TARGET_CONFIGURE_ARGS}} -DCMAKE_INSTALL_PREFIX:PATH={{.InstallDir}}/target -DQT_BUILD_TESTS=OFF -DCMAKE_AUTOGEN_VERBOSE=ON {{.SourceDir}}"
executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution
maxTimeInSeconds: 6000 maxTimeInSeconds: 6000
maxTimeBetweenOutput: 1200 maxTimeBetweenOutput: 1200

View File

@ -9,7 +9,7 @@ instructions:
- type: EnvironmentVariable - type: EnvironmentVariable
variableName: COIN_CMAKE_ARGS variableName: COIN_CMAKE_ARGS
# The lack of space between the non qtbase configure args and the rest of the args is important! # The lack of space between the non qtbase configure args and the rest of the args is important!
variableValue: "{{.Env.NON_QTBASE_CONFIGURE_ARGS}} -DBUILD_TESTING=OFF -DCMAKE_AUTOGEN_VERBOSE=ON {{.SourceDir}}" variableValue: "{{.Env.NON_QTBASE_CONFIGURE_ARGS}} -DQT_BUILD_TESTS=OFF -DCMAKE_AUTOGEN_VERBOSE=ON {{.SourceDir}}"
- !include "{{qt/qtbase}}/call_cmake.yaml" - !include "{{qt/qtbase}}/call_cmake.yaml"
- type: ExecuteCommand - type: ExecuteCommand
command: "{{.Env.ENV_PREFIX}} cmake --build . --parallel -v" command: "{{.Env.ENV_PREFIX}} cmake --build . --parallel -v"

View File

@ -7,7 +7,7 @@ instructions:
- type: ChangeDirectory - type: ChangeDirectory
directory: "{{.BuildDir}}" directory: "{{.BuildDir}}"
- type: ExecuteCommand - type: ExecuteCommand
command: "{{.Env.ENV_PREFIX}} cmake {{.Env.CONFIGURE_ARGS}} -DCMAKE_INSTALL_PREFIX:PATH={{.InstallDir}} -DBUILD_TESTING=OFF {{.SourceDir}}" command: "{{.Env.ENV_PREFIX}} cmake {{.Env.CONFIGURE_ARGS}} -DCMAKE_INSTALL_PREFIX:PATH={{.InstallDir}} -DQT_BUILD_TESTS=OFF {{.SourceDir}}"
executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution executeCommandArgumentSplitingBehavior: SplitAfterVariableSubstitution
maxTimeInSeconds: 6000 maxTimeInSeconds: 6000
maxTimeBetweenOutput: 1200 maxTimeBetweenOutput: 1200