From 292f2f537928d38ea0371be681d9e5c8614e3981 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 19 Oct 2020 13:35:15 +0200 Subject: 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 (cherry picked from commit fb21a5ce1a5831fab2af5e4d301600d6a6211e5d) Reviewed-by: Qt Cherry-pick Bot --- CMakeLists.txt | 8 ++--- .../QtBuildInternals/QtBuildInternalsConfig.cmake | 10 +++---- cmake/QtBuildInternalsExtra.cmake.in | 8 ++--- cmake/QtPriHelpers.cmake | 4 +-- cmake/QtProcessConfigureArgs.cmake | 8 ++--- cmake/QtSetup.cmake | 34 +++++++++++----------- cmake/QtToolHelpers.cmake | 8 ++--- cmake/README.md | 2 +- cmake/configure-cmake-mapping.md | 8 ++--- ...ross_compilation_module_build_instructions.yaml | 4 +-- ...ross_compilation_qtbase_build_instructions.yaml | 4 +-- .../cmake_module_build_instructions.yaml | 2 +- .../cmake_qtbase_build_instructions.yaml | 2 +- 13 files changed, 51 insertions(+), 51 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f36c73b14e..53daa1721a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,9 +96,9 @@ if(NOT QT_BUILD_STANDALONE_TESTS) add_subdirectory(src) endif() -if(BUILD_TESTING) +if(QT_BUILD_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) endif() endif() @@ -129,9 +129,9 @@ endif() 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) - if(QT_NO_MAKE_EXAMPLES) + if(NOT QT_BUILD_EXAMPLES_BY_DEFAULT) set_property(DIRECTORY examples PROPERTY EXCLUDE_FROM_ALL TRUE) endif() endif() diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index a7b86ed606..5216cebf66 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -372,7 +372,7 @@ macro(qt_build_repo) # If testing is enabled, try to find the qtbase Test package. # Do this before adding src, because there might be test related conditions # 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) endif() @@ -386,20 +386,20 @@ macro(qt_build_repo) 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) - if(QT_NO_MAKE_TESTS) + if(NOT QT_BUILD_TESTS_BY_DEFAULT) set_property(DIRECTORY tests PROPERTY EXCLUDE_FROM_ALL TRUE) endif() endif() 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 NOT QT_BUILD_STANDALONE_TESTS) add_subdirectory(examples) - if(QT_NO_MAKE_EXAMPLES) + if(NOT QT_BUILD_EXAMPLES_BY_DEFAULT) set_property(DIRECTORY examples PROPERTY EXCLUDE_FROM_ALL TRUE) endif() endif() diff --git a/cmake/QtBuildInternalsExtra.cmake.in b/cmake/QtBuildInternalsExtra.cmake.in index 5f58d4e79f..66f11a4364 100644 --- a/cmake/QtBuildInternalsExtra.cmake.in +++ b/cmake/QtBuildInternalsExtra.cmake.in @@ -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) # Propagate decision of building tests and examples to other repositories. -set(BUILD_TESTING @BUILD_TESTING@ CACHE BOOL "Build the testing tree.") -set(BUILD_EXAMPLES @BUILD_EXAMPLES@ CACHE BOOL "Build Qt examples") -set(QT_NO_MAKE_TESTS @QT_NO_MAKE_TESTS@ CACHE BOOL +set(QT_BUILD_TESTS @QT_BUILD_TESTS@ CACHE BOOL "Build the testing tree.") +set(QT_BUILD_EXAMPLES @QT_BUILD_EXAMPLES@ CACHE BOOL "Build Qt examples") +set(QT_BUILD_TESTS_BY_DEFAULT @QT_BUILD_TESTS_BY_DEFAULT@ CACHE BOOL "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.") # Propagate usage of ccache. diff --git a/cmake/QtPriHelpers.cmake b/cmake/QtPriHelpers.cmake index 7d4b6143ec..e0f10d19bb 100644 --- a/cmake/QtPriHelpers.cmake +++ b/cmake/QtPriHelpers.cmake @@ -642,11 +642,11 @@ endfunction() function(qt_get_build_parts out_var) 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") endif() - if(BUILD_TESTING AND NOT QT_NO_MAKE_TESTS) + if(QT_BUILD_TESTS AND QT_BUILD_TESTS_BY_DEFAULT) list(APPEND parts "tests") endif() diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index e8672306dd..258a4a09e1 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -664,11 +664,11 @@ drop_input(nomake) foreach(part ${INPUT_nomake}) if("${part}" STREQUAL "tests") - push("-DBUILD_TESTING=OFF") + push("-DQT_BUILD_TESTS=OFF") continue() endif() if("${part}" STREQUAL "examples") - push("-DBUILD_EXAMPLES=OFF") + push("-DQT_BUILD_EXAMPLES=OFF") continue() endif() qtConfAddWarning("'-nomake ${part}' is not implemented yet.") @@ -676,11 +676,11 @@ endforeach() foreach(part ${INPUT_make}) if("${part}" STREQUAL "tests") - push("-DBUILD_TESTING=ON") + push("-DQT_BUILD_TESTS=ON") continue() endif() if("${part}" STREQUAL "examples") - push("-DBUILD_EXAMPLES=ON") + push("-DQT_BUILD_EXAMPLES=ON") continue() endif() if("${part}" STREQUAL "tools") diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake index 025c0ab425..56684e7e02 100644 --- a/cmake/QtSetup.cmake +++ b/cmake/QtSetup.cmake @@ -106,13 +106,13 @@ if(FEATURE_developer_build) else() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) endif() - set(QT_BUILD_TESTING ON) + set(_qt_build_tests_default ON) set(__build_benchmarks ON) # 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. if(UIKIT OR ANDROID) - set(QT_BUILD_TESTING OFF) + set(_qt_build_tests_default OFF) endif() # Disable benchmarks for single configuration generators which do not build @@ -121,41 +121,41 @@ if(FEATURE_developer_build) set(__build_benchmarks OFF) endif() else() - set(QT_BUILD_TESTING OFF) + set(_qt_build_tests_default OFF) set(__build_benchmarks OFF) endif() ## 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) - set(QT_BUILD_TESTING ON) - # BuildInternals might have set it to OFF on initial configuration. So force it to ON when # 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. - set(QT_NO_MAKE_TESTS OFF CACHE BOOL - "Should examples be built as part of the default 'all' target." FORCE) + set(QT_BUILD_TESTS_BY_DEFAULT ON CACHE BOOL + "Should tests be built as part of the default 'all' target." FORCE) 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. # 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) - set(qt_no_make_tools_default ON) + set(_qt_build_tools_by_default_default OFF) endif() -option(QT_NO_MAKE_TOOLS "Should tools be built as part of the default 'all' target." - "${qt_no_make_tools_default}") -unset(qt_no_make_tools_default) +option(QT_BUILD_TOOLS_BY_DEFAULT "Should tools be built as part of the default 'all' target." + "${_qt_build_tools_by_default_default}") +unset(_qt_build_tools_by_default_default) include(CTest) enable_testing() -option(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 "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}) diff --git a/cmake/QtToolHelpers.cmake b/cmake/QtToolHelpers.cmake index 3d9d53c49b..4cca2990f3 100644 --- a/cmake/QtToolHelpers.cmake +++ b/cmake/QtToolHelpers.cmake @@ -417,11 +417,11 @@ function(qt_check_if_tools_will_be_built) endfunction() # 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 -# default 'all' target, as well as from install phase. -# The private variable is checked by qt_internal_add_executable. +# If QT_BUILD_TOOLS_BY_DEFAULT is true, then targets within the given directories will be excluded +# from the default 'all' target, as well as from install phase. The private variable is checked by +# qt_internal_add_executable. function(qt_exclude_tool_directories_from_default_target) - if(QT_NO_MAKE_TOOLS) + if(NOT QT_BUILD_TOOLS_BY_DEFAULT) set(absolute_path_directories "") foreach(directory ${ARGV}) list(APPEND absolute_path_directories "${CMAKE_CURRENT_SOURCE_DIR}/${directory}") diff --git a/cmake/README.md b/cmake/README.md index 8a3ba27c3c..eaaa781380 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -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 ``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 new build of Qt that is cross-compiled to the target architecture of choice. You may proceed by diff --git a/cmake/configure-cmake-mapping.md b/cmake/configure-cmake-mapping.md index b5e528f1e2..2f669aad9a 100644 --- a/cmake/configure-cmake-mapping.md +++ b/cmake/configure-cmake-mapping.md @@ -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-target | -DQT_ANDROID_JAVAC_TARGET=7 | Set the javac build target version. | | -skip | -DBUILD_=OFF | | -| -make | -DBUILD_TESTING=ON | A way to turn on tools explicitly is missing. | -| | -DBUILD_EXAMPLES=ON | | -| -nomake | -DBUILD_TESTING=OFF | A way to turn off tools explicitly is missing. | -| | -DBUILD_EXAMPLES=OFF | | +| -make | -DQT_BUILD_TESTS=ON | A way to turn on tools explicitly is missing. | +| | -DQT_BUILD_EXAMPLES=ON | | +| -nomake | -DQT_BUILD_TESTS=OFF | A way to turn off tools explicitly is missing. | +| | -DQT_BUILD_EXAMPLES=OFF | | | -no-gui | | | | -no-widgets | -DFEATURE_widgets=OFF | | | -no-dbus | -DFEATURE_dbus=OFF | | diff --git a/coin/instructions/cmake_cross_compilation_module_build_instructions.yaml b/coin/instructions/cmake_cross_compilation_module_build_instructions.yaml index 95b43b39c2..c6818a128d 100644 --- a/coin/instructions/cmake_cross_compilation_module_build_instructions.yaml +++ b/coin/instructions/cmake_cross_compilation_module_build_instructions.yaml @@ -19,7 +19,7 @@ instructions: - type: EnvironmentVariable variableName: COIN_CMAKE_ARGS # 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" - type: ExecuteCommand command: "{{.Env.ENV_PREFIX}} cmake --build . --parallel -v" @@ -49,7 +49,7 @@ instructions: - type: EnvironmentVariable variableName: COIN_CMAKE_ARGS # 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" - type: ExecuteCommand command: "{{.Env.TARGET_ENV_PREFIX}} cmake --build . --parallel -v" diff --git a/coin/instructions/cmake_cross_compilation_qtbase_build_instructions.yaml b/coin/instructions/cmake_cross_compilation_qtbase_build_instructions.yaml index f772c92320..601e952c71 100644 --- a/coin/instructions/cmake_cross_compilation_qtbase_build_instructions.yaml +++ b/coin/instructions/cmake_cross_compilation_qtbase_build_instructions.yaml @@ -17,7 +17,7 @@ instructions: - type: ChangeDirectory directory: "{{.BuildDir}}" - 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 maxTimeInSeconds: 6000 maxTimeBetweenOutput: 1200 @@ -63,7 +63,7 @@ instructions: property: platformDependency equals_value: null - 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 maxTimeInSeconds: 6000 maxTimeBetweenOutput: 1200 diff --git a/coin/instructions/cmake_module_build_instructions.yaml b/coin/instructions/cmake_module_build_instructions.yaml index 85dcbcfe63..e148321d39 100644 --- a/coin/instructions/cmake_module_build_instructions.yaml +++ b/coin/instructions/cmake_module_build_instructions.yaml @@ -9,7 +9,7 @@ instructions: - type: EnvironmentVariable variableName: COIN_CMAKE_ARGS # 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" - type: ExecuteCommand command: "{{.Env.ENV_PREFIX}} cmake --build . --parallel -v" diff --git a/coin/instructions/cmake_qtbase_build_instructions.yaml b/coin/instructions/cmake_qtbase_build_instructions.yaml index 89d95ab4b3..4ed3e1ae6e 100644 --- a/coin/instructions/cmake_qtbase_build_instructions.yaml +++ b/coin/instructions/cmake_qtbase_build_instructions.yaml @@ -7,7 +7,7 @@ instructions: - type: ChangeDirectory directory: "{{.BuildDir}}" - 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 maxTimeInSeconds: 6000 maxTimeBetweenOutput: 1200 -- cgit v1.2.3