Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cmake-properties.qdoc
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\group cmake-directory-properties-qtlinguisttools
6\title CMake Directory Properties in Qt6 LinguistTools
7
8\l{CMake Command Reference#Qt6::LinguistTools}{CMake Commands} know about the
9following CMake directory properties:
10
11\sa{CMake Property Reference}
12*/
13
14
15/*!
16\page cmake-directory-property-qt-exclude-from-translation.html
17\ingroup cmake-properties-qtlinguisttools
18\ingroup cmake-directory-properties-qtlinguisttools
19\keyword directory property QT_EXCLUDE_FROM_TRANSLATION
20
21\title QT_EXCLUDE_FROM_TRANSLATION
22
23\brief Marks the directory as excluded from translation
24
25\cmakepropertysince 6.7
26
27Set this directory property to \c ON to exclude all targets in the directory and
28its subdirectories from translation. The command
29\l{qt6_collect_translation_source_targets}{qt_collect_translation_source_targets}
30will skip such targets.
31
32To exclude a single target, use the target property \l{target property
33QT_EXCLUDE_FROM_TRANSLATION}{QT_EXCLUDE_FROM_TRANSLATION}.
34
35\section1 Examples
36
37In the following example, translatable strings will not be extracted from
38targets that are defined in the \c tests directory.
39
40\badcode
41add_subdirectory(app)
42add_subdirectory(tests)
43set_property(DIRECTORY tests PROPERTY QT_EXCLUDE_FROM_TRANSLATION ON)
44qt_add_translations(myapp)
45\endcode
46
47Alternatively, you can set the directory property in the \c{CMakeLists.txt} of
48the \c tests subdirectory.
49
50\badcode
51# tests/CMakeLists.txt
52qt_add_executable(...)
53add_test(...)
54set_directory_properties(PROPERTIES QT_EXCLUDE_FROM_TRANSLATION ON)
55\endcode
56
57\sa QT_EXCLUDE_SOURCES_FROM_TRANSLATION
58*/
59
60
61/*!
62\group cmake-target-properties-qtlinguisttools
63\title CMake Target Properties in Qt6 LinguistTools
64
65\l{CMake Command Reference#Qt6::LinguistTools}{CMake Commands} know about the
66following CMake target properties:
67
68\sa{CMake Property Reference}
69*/
70
71
72/*!
73\page cmake-target-property-qt-exclude-from-translation.html
74\ingroup cmake-properties-qtlinguisttools
75\ingroup cmake-target-properties-qtlinguisttools
76\keyword target property QT_EXCLUDE_FROM_TRANSLATION
77
78\title QT_EXCLUDE_FROM_TRANSLATION
79
80\brief Marks the target as excluded from translation
81
82\cmakepropertysince 6.7
83
84Set this target property to \c ON to exclude it from translation. The command
85\l{qt6_collect_translation_source_targets}{qt_collect_translation_source_targets}
86will skip such targets.
87
88To exclude all targets under a subdirectory, use the directory property
89\l{directory property QT_EXCLUDE_FROM_TRANSLATION}{QT_EXCLUDE_FROM_TRANSLATION}.
90
91\section1 Examples
92
93In the following example, translatable strings will not be extracted from the \c
94mytest target.
95
96\badcode
97qt_add_executable(myapp main.cpp)
98qt_add_executable(mytest test.cpp)
99set_property(TARGET mytest PROPERTY QT_EXCLUDE_FROM_TRANSLATION ON)
100qt_add_translations(myapp)
101\endcode
102
103\sa QT_EXCLUDE_SOURCES_FROM_TRANSLATION
104*/
105
106
107/*!
108\page cmake-target-property-qt-exclude-sources-from-translation.html
109\ingroup cmake-properties-qtlinguisttools
110\ingroup cmake-target-properties-qtlinguisttools
111
112\title QT_EXCLUDE_SOURCES_FROM_TRANSLATION
113
114\brief List of source file paths that shall be excluded from translation
115
116\cmakepropertysince 6.7
117
118This target property specifies a list of source file paths that are excluded
119from translation. Source files that match the patterns in this exclusion list
120are ignored by \c{lupdate}.
121
122The paths may be absolute or relative to \c{CMAKE_CURRENT_SOURCE_DIR}. The paths
123may contain wildcards in a format that is accepted by
124\l{QRegularExpression::wildcardToRegularExpression}.
125
126\section1 Examples
127
128Exclude \c untranslatable.cpp and recursively every file under the \c 3rdparty
129directory.
130
131\snippet cmake-macros/examples.cmake exclude sources from i18n
132
133\sa qt_add_lupdate
134\sa {target property QT_EXCLUDE_FROM_TRANSLATION}
135\sa {directory property QT_EXCLUDE_FROM_TRANSLATION}
136*/