Doc: Use find_package(Qt6 REQUIRED COMPONENTS ...) idiom

Using REQUIRED as a prefix instead of suffix works better with
OPTIONAL_COMPONENTS, and is also the order in the CMake manual.

Task-number: QTBUG-98867
Change-Id: I1ab68408b95d8edf06272a3b9fceccd8d8e597fc
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit b34be3868bd0933813f02c6a0fcbb5afd18b4105)
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Kai Köhne 2021-11-29 16:41:58 +01:00
parent a847de9d3b
commit 1816989af2
19 changed files with 19 additions and 19 deletions

View File

@ -1,4 +1,4 @@
#! [cmake_use]
find_package(Qt6 COMPONENTS Concurrent REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Concurrent)
target_link_libraries(mytarget PRIVATE Qt6::Concurrent)
#! [cmake_use]

View File

@ -1,2 +1,2 @@
find_package(Qt6 COMPONENTS Core REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)

View File

@ -1,6 +1,6 @@
project(my_app)
cmake_minimum_required(VERSION 3.16)
find_package(Qt6 COMPONENTS Widgets Qml REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Widgets Qml)
#! [AUTORCC]
set(CMAKE_AUTORCC ON)

View File

@ -33,7 +33,7 @@ The following CMake commands are defined when Qt6::Core is loaded, for instance
with
\code
find_package(Qt6 COMPONENTS Core REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Core)
\endcode
\sa{CMake Command Reference}

View File

@ -33,7 +33,7 @@ The following CMake variables are defined when Qt6::Core is loaded, for instance
with
\badcode
find_package(Qt6 COMPONENTS Core REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Core)
\endcode
\sa{CMake Variable Reference}

View File

@ -1,5 +1,5 @@
The command is defined in the \c Core component of the \c Qt6 package. Load the package with:
\code
find_package(Qt6 COMPONENTS Core REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Core)
\endcode

View File

@ -1,4 +1,4 @@
#! [cmake_use]
find_package(Qt6 COMPONENTS DBus REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS DBus)
target_link_libraries(mytarget PRIVATE Qt6::DBus)
#! [cmake_use]

View File

@ -1,5 +1,5 @@
The command is defined in the \c DBus component of the \c Qt6 package. Load the package with:
\code
find_package(Qt6 COMPONENTS DBus REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS DBus)
\endcode

View File

@ -33,7 +33,7 @@ The following CMake commands are defined when Qt6::DBus is loaded, for instance
with
\code
find_package(Qt6 COMPONENTS DBus REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS DBus)
\endcode
\sa{CMake Command Reference}

View File

@ -1,2 +1,2 @@
find_package(Qt6 COMPONENTS Gui REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)

View File

@ -7,6 +7,6 @@ add_executable(mytarget
)
# ![0]
find_package(Qt6 COMPONENTS Network REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
# ![0]

View File

@ -1,4 +1,4 @@
#! [cmake_use]
find_package(Qt6 COMPONENTS OpenGL REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS OpenGL)
target_link_libraries(mytarget PRIVATE Qt6::OpenGL)
#! [cmake_use]

View File

@ -1,4 +1,4 @@
#! [cmake_use]
find_package(Qt6 COMPONENTS PrintSupport REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS PrintSupport)
target_link_libraries(mytarget PRIVATE Qt6::PrintSupport)
#! [cmake_use]

View File

@ -1,4 +1,4 @@
#! [cmake_use]
find_package(Qt6 COMPONENTS Sql REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Sql)
target_link_libraries(mytarget PRIVATE Qt6::Sql)
#! [cmake_use]

View File

@ -1,4 +1,4 @@
#! [cmake_use]
find_package(Qt6 COMPONENTS Test REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Test)
target_link_libraries(mytarget PRIVATE Qt6::Test)
#! [cmake_use]

View File

@ -1,6 +1,6 @@
project(mytest LANGUAGES CXX)
find_package(Qt6 COMPONENTS Test REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Test)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

View File

@ -1,4 +1,4 @@
#! [cmake_use]
find_package(Qt6 COMPONENTS Widgets REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
#! [cmake_use]

View File

@ -1,5 +1,5 @@
The command is defined in the \c Widgets component of the \c Qt6 package. Load the package with:
\code
find_package(Qt6 COMPONENTS Widgets REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
\endcode

View File

@ -1,4 +1,4 @@
#! [cmake_use]
find_package(Qt6 COMPONENTS Xml REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Xml)
target_link_libraries(mytarget PRIVATE Qt6::Xml)
#! [cmake_use]