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 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\sa {Setting CMake variables and properties}
59*/
60
61
62/*!
63\group cmake-target-properties-qtlinguisttools
64\title CMake Target Properties in Qt6 LinguistTools
65
66\l{CMake Command Reference#Qt6::LinguistTools}{CMake Commands} know about the
67following CMake target properties:
68
69\sa{CMake Property Reference}
70*/
71
72
73/*!
74\page cmake-target-property-qt-exclude-from-translation.html
75\ingroup cmake-properties-qtlinguisttools
76\ingroup cmake-target-properties-qtlinguisttools
77\keyword target property QT_EXCLUDE_FROM_TRANSLATION
78
79\title QT_EXCLUDE_FROM_TRANSLATION
80
81\brief Marks the target as excluded from translation
82
83\cmakepropertysince 6.7
84
85Set this target property to \c ON to exclude it from translation. The command
86\l qt_collect_translation_source_targets()
87will skip such targets.
88
89To exclude all targets under a subdirectory, use the directory property
90\l{directory property QT_EXCLUDE_FROM_TRANSLATION}{QT_EXCLUDE_FROM_TRANSLATION}.
91
92\section1 Examples
93
94In the following example, translatable strings will not be extracted from the \c
95mytest target.
96
97\badcode
98qt_add_executable(myapp main.cpp)
99qt_add_executable(mytest test.cpp)
100set_property(TARGET mytest PROPERTY QT_EXCLUDE_FROM_TRANSLATION ON)
101qt_add_translations(myapp)
102\endcode
103
104\sa QT_EXCLUDE_SOURCES_FROM_TRANSLATION
105\sa {Setting CMake variables and properties}
106*/
107
108
109/*!
110\page cmake-target-property-qt-exclude-sources-from-translation.html
111\ingroup cmake-properties-qtlinguisttools
112\ingroup cmake-target-properties-qtlinguisttools
113
114\title QT_EXCLUDE_SOURCES_FROM_TRANSLATION
115
116\brief List of source file paths that shall be excluded from translation
117
118\cmakepropertysince 6.7
119
120This target property specifies a list of source file paths that are excluded
121from translation. Source files that match the patterns in this exclusion list
122are ignored by \c{lupdate}.
123
124The paths may be absolute or relative to \c{CMAKE_CURRENT_SOURCE_DIR}. The paths
125may contain wildcards in a format that is accepted by
126\l{QRegularExpression::wildcardToRegularExpression}.
127
128\section1 Examples
129
130Exclude \c untranslatable.cpp and recursively every file under the \c 3rdparty
131directory.
132
133\snippet cmake-macros/examples.cmake exclude sources from i18n
134
135\sa qt_add_lupdate()
136\sa {target property QT_EXCLUDE_FROM_TRANSLATION}
137\sa {directory property QT_EXCLUDE_FROM_TRANSLATION}
138\sa {Setting CMake variables and properties}
139*/