diff options
Diffstat (limited to 'tests/auto/cmake')
66 files changed, 1049 insertions, 264 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 4ea9f882f..2533156d5 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -1,4 +1,5 @@ -# special case skip regeneration +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause # This is an automatic test for the CMake configuration files. # To run it manually, @@ -63,5 +64,5 @@ if (TARGET Qt6::Widgets) endif() if(TARGET Qt6::lupdate) - _qt_internal_test_expect_pass(test_translation_api) + add_subdirectory(linguist) endif() diff --git a/tests/auto/cmake/linguist/CMakeLists.txt b/tests/auto/cmake/linguist/CMakeLists.txt index e137478c1..0d657b391 100644 --- a/tests/auto/cmake/linguist/CMakeLists.txt +++ b/tests/auto/cmake/linguist/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # This is an automatic test for the CMake configuration files. # To run it manually, # 1) mkdir build # Create a build directory @@ -55,6 +58,14 @@ endforeach() include("${_Qt6CTestMacros}") _qt_internal_test_expect_pass(test_add_translation_macro) -if (TARGET Qt6::lupdate) - _qt_internal_test_expect_pass(test_create_translation_macro) +_qt_internal_test_expect_pass(test_create_translation_macro) +_qt_internal_test_expect_pass(test_create_translation_same_base_names) +_qt_internal_test_expect_pass(test_translation_api) +_qt_internal_test_expect_pass(test_i18n_auto_ts_file_names) +_qt_internal_test_expect_pass(test_i18n_exclusion) +_qt_internal_test_expect_pass(test_i18n_filter_autogen_files) +_qt_internal_test_expect_pass(test_i18n_source_language) +if(NOT CMAKE_CROSSCOMPILING) + _qt_internal_test_expect_pass(test_i18n_find_package_in_subdir BINARY app1) + _qt_internal_test_expect_pass(test_i18n_subdir BINARY app1) endif() diff --git a/tests/auto/cmake/linguist/test_add_translation_macro/CMakeLists.txt b/tests/auto/cmake/linguist/test_add_translation_macro/CMakeLists.txt index 6a51231b1..9812734f1 100644 --- a/tests/auto/cmake/linguist/test_add_translation_macro/CMakeLists.txt +++ b/tests/auto/cmake/linguist/test_add_translation_macro/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + cmake_minimum_required(VERSION 3.16) project(test_add_translation_macro) diff --git a/tests/auto/cmake/linguist/test_add_translation_macro/myi18nobject.cpp b/tests/auto/cmake/linguist/test_add_translation_macro/myi18nobject.cpp index d5e4aba9d..ed518ab5f 100644 --- a/tests/auto/cmake/linguist/test_add_translation_macro/myi18nobject.cpp +++ b/tests/auto/cmake/linguist/test_add_translation_macro/myi18nobject.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QCoreApplication> #include <QLocale> diff --git a/tests/auto/cmake/linguist/test_add_translation_macro/some_dir/some_include.h b/tests/auto/cmake/linguist/test_add_translation_macro/some_dir/some_include.h index 2f8411b45..f2577ba2e 100644 --- a/tests/auto/cmake/linguist/test_add_translation_macro/some_dir/some_include.h +++ b/tests/auto/cmake/linguist/test_add_translation_macro/some_dir/some_include.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef SOME_INCLUDE_H #define SOME_INCLUDE_H diff --git a/tests/auto/cmake/linguist/test_create_translation_macro/CMakeLists.txt b/tests/auto/cmake/linguist/test_create_translation_macro/CMakeLists.txt index 163d21793..9e57ee802 100644 --- a/tests/auto/cmake/linguist/test_create_translation_macro/CMakeLists.txt +++ b/tests/auto/cmake/linguist/test_create_translation_macro/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + cmake_minimum_required(VERSION 3.16) project(test_create_translation_macros) diff --git a/tests/auto/cmake/linguist/test_create_translation_macro/myi18nobject.cpp b/tests/auto/cmake/linguist/test_create_translation_macro/myi18nobject.cpp index c990d2f66..fdc373734 100644 --- a/tests/auto/cmake/linguist/test_create_translation_macro/myi18nobject.cpp +++ b/tests/auto/cmake/linguist/test_create_translation_macro/myi18nobject.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QCoreApplication> #include <QTranslator> diff --git a/tests/auto/cmake/linguist/test_create_translation_macro/myobject_de.ts b/tests/auto/cmake/linguist/test_create_translation_macro/myobject_de.ts index f4f9f4b7b..67c56ed98 100644 --- a/tests/auto/cmake/linguist/test_create_translation_macro/myobject_de.ts +++ b/tests/auto/cmake/linguist/test_create_translation_macro/myobject_de.ts @@ -4,7 +4,7 @@ <context> <name>main</name> <message> - <location filename="myi18nobject.cpp" line="45"/> + <location filename="myi18nobject.cpp" line="20"/> <source>Hello, world!</source> <translation>Hallo, Welt!</translation> </message> diff --git a/tests/auto/cmake/linguist/test_create_translation_macro/some_dir/some_include.h b/tests/auto/cmake/linguist/test_create_translation_macro/some_dir/some_include.h index 2f8411b45..f2577ba2e 100644 --- a/tests/auto/cmake/linguist/test_create_translation_macro/some_dir/some_include.h +++ b/tests/auto/cmake/linguist/test_create_translation_macro/some_dir/some_include.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef SOME_INCLUDE_H #define SOME_INCLUDE_H diff --git a/tests/auto/cmake/linguist/test_create_translation_same_base_names/CMakeLists.txt b/tests/auto/cmake/linguist/test_create_translation_same_base_names/CMakeLists.txt new file mode 100644 index 000000000..e395cd2b6 --- /dev/null +++ b/tests/auto/cmake/linguist/test_create_translation_same_base_names/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) + +project(test_create_translation_same_base_names) + +find_package(Qt6 COMPONENTS Core LinguistTools REQUIRED) + +set(my_srcs myi18nobject.cpp) + +set(ts_files "") +foreach(language de fr) + set(ts_file ${language}/myobject.ts) + set_property(SOURCE ${ts_file} + PROPERTY OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${language}) + list(APPEND ts_files ${ts_file}) +endforeach() +qt_create_translation(qm_files ${my_srcs} ${ts_files}) + +add_executable(myobject ${my_srcs} ${qm_files}) +target_link_libraries(myobject Qt::Core) diff --git a/tests/auto/cmake/linguist/test_create_translation_same_base_names/de/myobject.ts b/tests/auto/cmake/linguist/test_create_translation_same_base_names/de/myobject.ts new file mode 100644 index 000000000..4d4292e5b --- /dev/null +++ b/tests/auto/cmake/linguist/test_create_translation_same_base_names/de/myobject.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="de_DE"> +<context> + <name>main</name> + <message> + <location filename="../myi18nobject.cpp" line="26"/> + <source>Hello, world!</source> + <translation>Hallo, Welt!</translation> + </message> +</context> +</TS> diff --git a/tests/auto/cmake/linguist/test_create_translation_same_base_names/fr/myobject.ts b/tests/auto/cmake/linguist/test_create_translation_same_base_names/fr/myobject.ts new file mode 100644 index 000000000..ab96d20e3 --- /dev/null +++ b/tests/auto/cmake/linguist/test_create_translation_same_base_names/fr/myobject.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="fr"> +<context> + <name>main</name> + <message> + <location filename="../myi18nobject.cpp" line="26"/> + <source>Hello, world!</source> + <translation>Bonjour le monde!</translation> + </message> +</context> +</TS> diff --git a/tests/auto/cmake/linguist/test_create_translation_same_base_names/myi18nobject.cpp b/tests/auto/cmake/linguist/test_create_translation_same_base_names/myi18nobject.cpp new file mode 100644 index 000000000..2f2b31ff6 --- /dev/null +++ b/tests/auto/cmake/linguist/test_create_translation_same_base_names/myi18nobject.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QCoreApplication> +#include <QTranslator> +#include <QLocale> + +#include <cstdio> + +using namespace Qt::Literals::StringLiterals; + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + QTranslator *translator = new QTranslator(); + QLocale frenchLocale = QLocale(QLocale::French); + QLocale::setDefault(frenchLocale); + if (!translator->load(QLocale(), "myobject.qm"_L1, {}, + qApp->applicationDirPath() + "/fr/"_L1)) { + qFatal("Could not load translation file!"); + } + + app.installTranslator(translator); + + QString text = QCoreApplication::translate("main", "Hello, world!"); + if (text != "Bonjour le monde!"_L1) + qFatal("Translation not found!"); + + std::fprintf(stdout, "%s\n", qPrintable(text)); + return 0; +} diff --git a/tests/auto/cmake/linguist/test_i18n_auto_ts_file_names/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_auto_ts_file_names/CMakeLists.txt new file mode 100644 index 000000000..04e84edd4 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_auto_ts_file_names/CMakeLists.txt @@ -0,0 +1,115 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(test_i18n_auto_ts_file_names) + +# Set up the project structure. +find_package(Qt6 REQUIRED COMPONENTS Core Gui LinguistTools) +qt_standard_project_setup() + +function(my_add_library target) + qt6_add_library("${target}" ${ARGN}) + target_link_libraries("${target}" PRIVATE Qt6::Core) +endfunction() + +# Remove .ts files from older test runs. +file(GLOB_RECURSE old_ts_files "${CMAKE_CURRENT_SOURCE_DIR}/*.ts") +foreach(f IN LISTS old_ts_files) + message("Removing: ${f}") + file(REMOVE "${f}") +endforeach() + +set(expected_files "") +set(unexpected_files "") + +# Check defaults for the deferred call. +my_add_library(lib1 STATIC lib.cpp) +set(QT_I18N_TRANSLATED_LANGUAGES te st) +qt_add_translations(TARGETS lib1) +list(APPEND expected_files + "${CMAKE_CURRENT_SOURCE_DIR}/test_i18n_auto_ts_file_names_en.ts" # plurals-only file + "${CMAKE_CURRENT_SOURCE_DIR}/test_i18n_auto_ts_file_names_te.ts" + "${CMAKE_CURRENT_SOURCE_DIR}/test_i18n_auto_ts_file_names_st.ts") + +# Check defaults for the immediate call. +my_add_library(lib2 STATIC lib.cpp) +set(QT_I18N_SOURCE_LANGUAGE hu) +set(QT_I18N_TRANSLATED_LANGUAGES hi ho) +qt_add_translations(TARGETS lib2 IMMEDIATE_CALL) +list(APPEND expected_files + "${CMAKE_CURRENT_SOURCE_DIR}/test_i18n_auto_ts_file_names_hu.ts" # plurals-only file + "${CMAKE_CURRENT_SOURCE_DIR}/test_i18n_auto_ts_file_names_hi.ts" + "${CMAKE_CURRENT_SOURCE_DIR}/test_i18n_auto_ts_file_names_ho.ts") + +# Check defaults for deferred/immediate call in a subdir. +add_subdirectory(subdir) +list(APPEND expected_files + "${CMAKE_CURRENT_SOURCE_DIR}/subdir/test_i18n_auto_ts_file_names_eo.ts" # plurals-only file + "${CMAKE_CURRENT_SOURCE_DIR}/subdir/test_i18n_auto_ts_file_names_de.ts" + "${CMAKE_CURRENT_SOURCE_DIR}/subdir/test_i18n_auto_ts_file_names_ee.ts" # plurals-only file + "${CMAKE_CURRENT_SOURCE_DIR}/subdir/test_i18n_auto_ts_file_names_da.ts" +) + +# Check whether TS_FILE_BASE works. +my_add_library(lib5 STATIC lib.cpp) +set(QT_I18N_SOURCE_LANGUAGE ne) +set(QT_I18N_TRANSLATED_LANGUAGES no) +qt_add_translations(TARGETS lib5 TS_FILE_BASE lib5) +list(APPEND expected_files + "${CMAKE_CURRENT_SOURCE_DIR}/lib5_ne.ts" # plurals-only file + "${CMAKE_CURRENT_SOURCE_DIR}/lib5_no.ts") + +# Check whether TS_FILE_DIR works. +my_add_library(lib6 STATIC lib.cpp) +set(QT_I18N_SOURCE_LANGUAGE so) # plurals-only file +set(QT_I18N_TRANSLATED_LANGUAGES sv) +qt_add_translations(TARGETS lib6 TS_FILE_DIR translations) +list(APPEND expected_files + "${CMAKE_CURRENT_SOURCE_DIR}/translations/test_i18n_auto_ts_file_names_sv.ts") + +# Check whether TS_FILE_BASE and TS_FILE_DIR work together. +my_add_library(lib7 STATIC lib.cpp) +set(QT_I18N_SOURCE_LANGUAGE fy) +set(QT_I18N_TRANSLATED_LANGUAGES fi) +qt_add_translations(TARGETS lib7 TS_FILE_BASE lib7 TS_FILE_DIR translations) +list(APPEND expected_files + "${CMAKE_CURRENT_SOURCE_DIR}/translations/lib7_fy.ts" # plurals-only file + "${CMAKE_CURRENT_SOURCE_DIR}/translations/lib7_fi.ts") + +# Check defaults for the deferred call with just the native language set. +my_add_library(lib8 STATIC lib.cpp) +set(QT_I18N_TRANSLATED_LANGUAGES "") +set(QT_I18N_SOURCE_LANGUAGE nl) +qt_add_translations(TARGETS lib8) +list(APPEND expected_files + "${CMAKE_CURRENT_SOURCE_DIR}/test_i18n_auto_ts_file_names_nl.ts") + +# Check whether we can turn off the generation of the plurals-only file. +my_add_library(lib10 STATIC lib.cpp) +set(QT_I18N_TRANSLATED_LANGUAGES cy) +set(QT_I18N_SOURCE_LANGUAGE an) +qt_add_translations(TARGETS lib10 NO_GENERATE_PLURALS_TS_FILE) +list(APPEND expected_files + "${CMAKE_CURRENT_SOURCE_DIR}/test_i18n_auto_ts_file_names_cy.ts") +list(APPEND unexpected_files + "${CMAKE_CURRENT_SOURCE_DIR}/test_i18n_auto_ts_file_names_an.ts") + +function(check_ts_file_paths) + foreach(filepath IN LISTS expected_files) + if(NOT EXISTS "${filepath}") + message(FATAL_ERROR "Expected file '${filepath}' does not exist.") + endif() + endforeach() + foreach(filepath IN LISTS unexpected_files) + if(EXISTS "${filepath}") + message(FATAL_ERROR "File '${filepath}' unexpectedly exists.") + endif() + endforeach() +endfunction() + +if(CMAKE_VERSION VERSION_LESS "3.19") + check_ts_file_paths() +else() + cmake_language(DEFER CALL check_ts_file_paths) +endif() diff --git a/tests/auto/cmake/linguist/test_i18n_auto_ts_file_names/lib.cpp b/tests/auto/cmake/linguist/test_i18n_auto_ts_file_names/lib.cpp new file mode 100644 index 000000000..da1c291b4 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_auto_ts_file_names/lib.cpp @@ -0,0 +1 @@ +int getSomeNumber() { return 42; } diff --git a/tests/auto/cmake/linguist/test_i18n_auto_ts_file_names/subdir/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_auto_ts_file_names/subdir/CMakeLists.txt new file mode 100644 index 000000000..2fcc3cc03 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_auto_ts_file_names/subdir/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +my_add_library(lib3 STATIC ../lib.cpp) +set(QT_I18N_SOURCE_LANGUAGE eo) +set(QT_I18N_TRANSLATED_LANGUAGES de) +qt_add_translations(TARGETS lib3) + +my_add_library(lib4 STATIC ../lib.cpp) +set(QT_I18N_SOURCE_LANGUAGE ee) +set(QT_I18N_TRANSLATED_LANGUAGES da) +qt_add_translations(TARGETS lib4 IMMEDIATE_CALL) + diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_exclusion/CMakeLists.txt new file mode 100644 index 000000000..574567e48 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(test_i18n_exclusion) + +# Set up the project structure. +find_package(Qt6 REQUIRED COMPONENTS Core Gui LinguistTools) +qt_standard_project_setup() +add_subdirectory(libs) +add_subdirectory(apps) +add_subdirectory(tests) + +# Generate a fresh, empty .ts file in the build directory. +set(ts_file "${CMAKE_CURRENT_BINARY_DIR}/test_i18n_exclusion_de.ts") +configure_file(test_i18n_exclusion_de.ts.in "${ts_file}") + +# Set up the 'update_translations' target. +qt_collect_translation_source_targets(i18n_targets) +qt_add_lupdate( + SOURCE_TARGETS ${i18n_targets} + TS_FILES "${ts_file}" +) + +# Build the 'update_translations' target by default and check the content of the updated .ts file. +add_custom_target(force_ts_update ALL + COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/check_ts_file.cmake" +) +add_dependencies(force_ts_update update_translations) diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/apps/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/CMakeLists.txt new file mode 100644 index 000000000..0026828cb --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/CMakeLists.txt @@ -0,0 +1,4 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +add_subdirectory(app1) diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/CMakeLists.txt new file mode 100644 index 000000000..0c1a8af5c --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_add_executable(app1 + main.cpp + excluded1.cpp + subdir/excluded2.cpp + ../shared/excluded3.cpp +) + +# Note: subdir2/excluded4.cpp is deliberately not added to the sources. It's included in main.cpp, +# and lupdate picks up such source files. The exclusion pattern must work for those too. + +set_property(TARGET app1 PROPERTY QT_EXCLUDE_SOURCES_FROM_TRANSLATION + ../shared/* + excluded?.cpp + subdir/* + subdir2/excluded4.cpp +) +target_link_libraries(app1 PRIVATE + Qt6::Gui + lib1 + lib2 +) diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/excluded1.cpp b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/excluded1.cpp new file mode 100644 index 000000000..8e04d3ee1 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/excluded1.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QCoreApplication> + +void excluded1() +{ + QCoreApplication::translate("app1", "excluded1"); +} diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/main.cpp b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/main.cpp new file mode 100644 index 000000000..820d82744 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/main.cpp @@ -0,0 +1,19 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QCoreApplication> +#include "lib1.h" +#include "lib2.h" +#include "subdir2/excluded4.cpp" + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + auto obj1 = new MyObject1(&app); + auto obj2 = new MyObject2(&app); + qDebug() << QCoreApplication::translate("app1", "Hello from app1!") + << obj1->greeting() + << obj2->greeting() + << WossName::greeting(); + return app.exec(); +} diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/subdir/excluded2.cpp b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/subdir/excluded2.cpp new file mode 100644 index 000000000..3cae0ba5f --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/subdir/excluded2.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QCoreApplication> + +void excluded2() +{ + QCoreApplication::translate("app1", "excluded2"); +} diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/subdir2/excluded4.cpp b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/subdir2/excluded4.cpp new file mode 100644 index 000000000..f6ce89cb4 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/app1/subdir2/excluded4.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QCoreApplication> + +class WossName +{ + Q_DECLARE_TR_FUNCTIONS(WossName) +public: + static QString greeting() + { + return tr("excluded4"); + } +}; diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/apps/shared/excluded3.cpp b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/shared/excluded3.cpp new file mode 100644 index 000000000..e3d0784cb --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/apps/shared/excluded3.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QCoreApplication> + +void excluded3() +{ + QCoreApplication::translate("shared", "excluded3"); +} diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/check_ts_file.cmake b/tests/auto/cmake/linguist/test_i18n_exclusion/check_ts_file.cmake new file mode 100644 index 000000000..45b9b434a --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/check_ts_file.cmake @@ -0,0 +1,37 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +set(ts_file "test_i18n_exclusion_de.ts") +file(READ "${ts_file}" ts_file_content) + +set(expected_strings + "<source>Hello from app1!</source>" + "<source>Hello from MyObject1!</source>" +) +foreach(needle IN LISTS expected_strings) + string(FIND "${ts_file_content}" "${needle}" pos) + if(pos EQUAL "-1") + message(FATAL_ERROR + "Expected string '${needle}' was not found in '${ts_file}'. " + "The file content is:\n${ts_file_content}" + ) + endif() +endforeach() + +set(forbidden_strings + "<source>Hello from MyObject2!</source>" + "<source>Hello from test1!</source>" + "<source>excluded1</source>" + "<source>excluded2</source>" + "<source>excluded3</source>" + "<source>excluded4</source>" +) +foreach(needle IN LISTS forbidden_strings) + string(FIND "${ts_file_content}" "${needle}" pos) + if(NOT pos EQUAL "-1") + message(FATAL_ERROR + "Excluded string '${needle}' was found in '${ts_file}'. " + "The file content is:\n${ts_file_content}" + ) + endif() +endforeach() diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/libs/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/CMakeLists.txt new file mode 100644 index 000000000..b75acc2ce --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +add_subdirectory(lib1) +add_subdirectory(lib2) diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib1/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib1/CMakeLists.txt new file mode 100644 index 000000000..7cdc5da8d --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib1/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_add_library(lib1 STATIC lib1.cpp) +target_link_libraries(lib1 PRIVATE Qt6::Core) +target_include_directories(lib1 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib1/lib1.cpp b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib1/lib1.cpp new file mode 100644 index 000000000..187367436 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib1/lib1.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "lib1.h" + +MyObject1::MyObject1(QObject *parent) + : QObject(parent) +{ +} + +QString MyObject1::greeting() const +{ + return tr("Hello from MyObject1!"); +} diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib1/lib1.h b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib1/lib1.h new file mode 100644 index 000000000..42cd3f5c9 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib1/lib1.h @@ -0,0 +1,17 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef _LIB1_H_ +#define _LIB1_H_ + +#include <QObject> + +class MyObject1 : public QObject +{ + Q_OBJECT +public: + MyObject1(QObject *parent = nullptr); + QString greeting() const; +}; + +#endif // _LIB1_H_ diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib2/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib2/CMakeLists.txt new file mode 100644 index 000000000..d29ce8c1b --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib2/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_add_library(lib2 STATIC lib2.cpp) +target_link_libraries(lib2 PRIVATE Qt6::Core) +target_include_directories(lib2 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") +set_property(TARGET lib2 PROPERTY QT_EXCLUDE_FROM_TRANSLATION ON) diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib2/lib2.cpp b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib2/lib2.cpp new file mode 100644 index 000000000..0839c5216 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib2/lib2.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "lib2.h" + +MyObject2::MyObject2(QObject *parent) + : QObject(parent) +{ +} + +QString MyObject2::greeting() const +{ + return tr("Hello from MyObject2!"); +} diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib2/lib2.h b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib2/lib2.h new file mode 100644 index 000000000..610cf038c --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/libs/lib2/lib2.h @@ -0,0 +1,17 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef _LIB2_H_ +#define _LIB2_H_ + +#include <QObject> + +class MyObject2 : public QObject +{ + Q_OBJECT +public: + MyObject2(QObject *parent = nullptr); + QString greeting() const; +}; + +#endif // _LIB2_H_ diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/test_i18n_exclusion_de.ts.in b/tests/auto/cmake/linguist/test_i18n_exclusion/test_i18n_exclusion_de.ts.in new file mode 100644 index 000000000..1552582ed --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/test_i18n_exclusion_de.ts.in @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="de_DE"> +</TS> diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/tests/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_exclusion/tests/CMakeLists.txt new file mode 100644 index 000000000..fc5166707 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/tests/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +add_subdirectory(test1) +set_directory_properties(PROPERTIES QT_EXCLUDE_FROM_TRANSLATION ON) diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/tests/test1/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_exclusion/tests/test1/CMakeLists.txt new file mode 100644 index 000000000..0be774e82 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/tests/test1/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_add_executable(test1 test1.cpp) +target_link_libraries(test1 PRIVATE Qt6::Gui) diff --git a/tests/auto/cmake/linguist/test_i18n_exclusion/tests/test1/test1.cpp b/tests/auto/cmake/linguist/test_i18n_exclusion/tests/test1/test1.cpp new file mode 100644 index 000000000..6af64ece1 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_exclusion/tests/test1/test1.cpp @@ -0,0 +1,12 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QCoreApplication> +#include <QDebug> + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + qDebug() << QCoreApplication::translate("test1", "Hello from test1!"); + return app.exec(); +} diff --git a/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/CMakeLists.txt new file mode 100644 index 000000000..0e3871ef6 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(test_i18n_filter_autogen_files) +set(CMAKE_CXX_STANDARD 20) +find_package(Qt6 COMPONENTS Widgets LinguistTools) +qt_standard_project_setup() +add_subdirectory(app1) +add_subdirectory(app2) + +set(ts_file "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_de.ts") +qt_add_lupdate( + TS_FILES "${ts_file}" + SOURCE_TARGETS app1 app2 + LUPDATE_TARGET update_ts_files + NO_GLOBAL_TARGET +) + +# Make sure that we build the app before creating the .ts file. +# We want to have AUTOMOC and AUTOUIC files generated. +add_dependencies(update_ts_files app1 app2) + +# Update the .ts files by default and check the content of the updated .ts file. +add_custom_target(force_ts_update ALL + COMMENT "Checking .ts file contents..." + COMMAND "${CMAKE_COMMAND}" -DTS_FILE="${ts_file}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_ts_file.cmake" +) +add_dependencies(force_ts_update update_ts_files) diff --git a/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app1/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app1/CMakeLists.txt new file mode 100644 index 000000000..6ff3989e7 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app1/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +qt_add_executable(app1 + main.cpp + mainwindow.ui +) +target_link_libraries(app1 PRIVATE Qt6::Widgets) diff --git a/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app1/main.cpp b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app1/main.cpp new file mode 100644 index 000000000..21db50503 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app1/main.cpp @@ -0,0 +1,27 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtCore/QCoreApplication> + +#include "ui_mainwindow.h" + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = nullptr) + : QObject(parent) + { + qDebug() << tr("Hello from app1!"); + } +}; + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + MyObject obj; + Ui::MainWindow wnd; + app.exec(); +} + +#include "main.moc" diff --git a/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app1/mainwindow.ui b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app1/mainwindow.ui new file mode 100644 index 000000000..2b9bac77c --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app1/mainwindow.ui @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>App1's Main Window</string> + </property> + <widget class="QWidget" name="centralwidget"/> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>22</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar"/> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app2/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app2/CMakeLists.txt new file mode 100644 index 000000000..d5c26b126 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app2/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +qt_add_executable(app2 + main.cpp + mainwindow.ui +) +target_link_libraries(app2 PRIVATE Qt6::Widgets) +set_target_properties(app2 PROPERTIES + AUTOGEN_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/wossname_autogen" +) diff --git a/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app2/main.cpp b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app2/main.cpp new file mode 100644 index 000000000..3b432078f --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app2/main.cpp @@ -0,0 +1,27 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtCore/QCoreApplication> + +#include "ui_mainwindow.h" + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = nullptr) + : QObject(parent) + { + qDebug() << tr("Hello from app2!"); + } +}; + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + MyObject obj; + Ui::MainWindow wnd; + app.exec(); +} + +#include "main.moc" diff --git a/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app2/mainwindow.ui b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app2/mainwindow.ui new file mode 100644 index 000000000..6b0b6f2de --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/app2/mainwindow.ui @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>App2's Main Window</string> + </property> + <widget class="QWidget" name="centralwidget"/> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>22</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar"/> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/check_ts_file.cmake b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/check_ts_file.cmake new file mode 100644 index 000000000..0e0118180 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_filter_autogen_files/check_ts_file.cmake @@ -0,0 +1,31 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +file(READ "${TS_FILE}" ts_file_content) + +set(expected_strings + "<source>Hello from app1!</source>" + "<source>Hello from app2!</source>" +) +foreach(needle IN LISTS expected_strings) + string(FIND "${ts_file_content}" "${needle}" pos) + if(pos EQUAL "-1") + message(FATAL_ERROR + "Expected string '${needle}' was not found in '${TS_FILE}'. " + "The file content is:\n${ts_file_content}" + ) + endif() +endforeach() + +set(forbidden_strings + "/ui_mainwindow.h\"" +) +foreach(needle IN LISTS forbidden_strings) + string(FIND "${ts_file_content}" "${needle}" pos) + if(NOT pos EQUAL "-1") + message(FATAL_ERROR + "Excluded string '${needle}' was found in '${TS_FILE}'. " + "The file content is:\n${ts_file_content}" + ) + endif() +endforeach() diff --git a/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/CMakeLists.txt new file mode 100644 index 000000000..09f688408 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(test_i18n_subdir) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +add_subdirectory(subdir) diff --git a/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/subdir/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/subdir/CMakeLists.txt new file mode 100644 index 000000000..62c577d56 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/subdir/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause +find_package(Qt6 COMPONENTS Gui LinguistTools) +qt_add_executable(app1 + main.cpp) +target_link_libraries(app1 PRIVATE Qt::Gui) +qt_add_translations(app1 + TS_FILES app1_de.ts + NO_GENERATE_PLURALS_TS_FILE +) diff --git a/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/subdir/app1_de.ts b/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/subdir/app1_de.ts new file mode 100644 index 000000000..924515f31 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/subdir/app1_de.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="de_DE"> +<context> + <name>main</name> + <message> + <location filename="main.cpp" line="17"/> + <source>Hello from main!</source> + <translation>Hallo aus der Hauptfunktion!</translation> + </message> +</context> +</TS> diff --git a/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/subdir/main.cpp b/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/subdir/main.cpp new file mode 100644 index 000000000..ed3035d18 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_find_package_in_subdir/subdir/main.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtCore/QCoreApplication> +#include <QtCore/QTranslator> + +#include <iostream> + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + + const QString qmFile = ":/i18n/app1_de.qm"; + std::cout << "Loading translation '" << qPrintable(qmFile) << "'..." << std::endl; + QTranslator *translator = new QTranslator(&app); + if (!translator->load(qmFile)) { + std::cerr << "Error: failed to load the translation" << std::endl; + return 1; + } + app.installTranslator(translator); + + std::cout << "Checking translated text..." << std::endl; + const QString translated = QCoreApplication::translate("main", "Hello from main!"); + if (!translated.startsWith("Hallo aus")) { + std::cerr << "Error: translation doesn't seem to work. " + << "The translated text is '" << qPrintable(translated) << "'" << std::endl; + return 2; + } + + std::cout << "All good." << std::endl; + return 0; +} diff --git a/tests/auto/cmake/linguist/test_i18n_source_language/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_source_language/CMakeLists.txt new file mode 100644 index 000000000..72b5e5cde --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_source_language/CMakeLists.txt @@ -0,0 +1,69 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(test_i18n_source_language) + +# Set up the project structure. +find_package(Qt6 REQUIRED COMPONENTS Core Gui LinguistTools) +qt_standard_project_setup() +set(native_ts_files "") + +function(my_add_library target) + add_library("${target}" STATIC lib.cpp) + target_link_libraries("${target}" PRIVATE Qt6::Core) +endfunction() + +# qt_add_lupdate with just the native translation. +my_add_library(lib1 STATIC lib.cpp) +qt_add_lupdate( + SOURCE_TARGETS lib1 + PLURALS_TS_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib1_en.ts" +) + +# qt_add_lupdate with just the native translation which has already been translated. +# check_ts_files.cmake checks that the numerus translations are preserved. +my_add_library(lib2 STATIC lib.cpp) +configure_file(lib2_en.ts.in lib2_en.ts COPYONLY) +qt_add_lupdate( + SOURCE_TARGETS lib2 + PLURALS_TS_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib2_en.ts" +) + +# qt_add_lupdate with regular translations and the native translation. +my_add_library(lib3 STATIC lib.cpp) +qt_add_lupdate( + SOURCE_TARGETS lib3 + TS_FILES "${CMAKE_CURRENT_BINARY_DIR}/lib3_hi.ts" "${CMAKE_CURRENT_BINARY_DIR}/lib3_ho.ts" + PLURALS_TS_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib3_en.ts" +) + +# qt_add_translations with just the native translation. +my_add_library(lib4 STATIC lib.cpp) +qt_add_translations( + TARGETS lib4 + SOURCE_TARGETS lib4 + PLURALS_TS_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib4_en.ts" +) + +# qt_add_translations with regular translations and the native translation. +my_add_library(lib5 STATIC lib.cpp) +qt_add_translations( + TARGETS lib5 + SOURCE_TARGETS lib5 + TS_FILES "${CMAKE_CURRENT_BINARY_DIR}/lib5_hi.ts" "${CMAKE_CURRENT_BINARY_DIR}/lib5_ho.ts" + PLURALS_TS_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib5_en.ts" +) + +# Find out how many targets we created above. +get_directory_property(targets BUILDSYSTEM_TARGETS) +list(FILTER targets INCLUDE REGEX "^lib[0-9]+$") +list(LENGTH targets targets_length) + +# Build the 'update_translations' target by default and check the native language .ts files. +string(REPLACE ";" "\\\\;" native_ts_files "${native_ts_files}") +add_custom_target(force_ts_update ALL + COMMAND "${CMAKE_COMMAND}" -DNR_OF_TARGETS=${targets_length} + -P "${CMAKE_CURRENT_SOURCE_DIR}/check_ts_files.cmake" +) +add_dependencies(force_ts_update update_translations) diff --git a/tests/auto/cmake/linguist/test_i18n_source_language/check_ts_files.cmake b/tests/auto/cmake/linguist/test_i18n_source_language/check_ts_files.cmake new file mode 100644 index 000000000..4427682f7 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_source_language/check_ts_files.cmake @@ -0,0 +1,47 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +set(ts_files_to_check "") +foreach(i RANGE 1 ${NR_OF_TARGETS}) + list(APPEND ts_files_to_check "lib${i}_en.ts") +endforeach() + +function(check_ts_file ts_file) + message("Checking the content of '${ts_file}'...") + file(READ "${ts_file}" ts_file_content) + + set(expected_strings + "<source>%n argument(s) passed</source>" + ) + if(ts_file MATCHES "^lib2_en\\.ts$") + list(APPEND expected_strings + "<numerusform>one argument passed</numerusform>" + ) + endif() + foreach(needle IN LISTS expected_strings) + string(FIND "${ts_file_content}" "${needle}" pos) + if(pos EQUAL "-1") + message(FATAL_ERROR + "Expected string '${needle}' was not found in '${ts_file}'. " + "The file content is:\n${ts_file_content}" + ) + endif() + endforeach() + + set(forbidden_strings + "<source>We must not see this in the native language" + ) + foreach(needle IN LISTS forbidden_strings) + string(FIND "${ts_file_content}" "${needle}" pos) + if(NOT pos EQUAL "-1") + message(FATAL_ERROR + "Excluded string '${needle}' was found in '${ts_file}'. " + "The file content is:\n${ts_file_content}" + ) + endif() + endforeach() +endfunction() + +foreach(ts_file IN LISTS ts_files_to_check) + check_ts_file("${ts_file}") +endforeach() diff --git a/tests/auto/cmake/linguist/test_i18n_source_language/lib.cpp b/tests/auto/cmake/linguist/test_i18n_source_language/lib.cpp new file mode 100644 index 000000000..f99e0a9bf --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_source_language/lib.cpp @@ -0,0 +1,12 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QCoreApplication> +#include <QDebug> + +void printStuff() +{ + qDebug() + << QObject::tr("We must not see this in the native language's .tr file.") + << QObject::tr("%n argument(s) passed", "", 156); +} diff --git a/tests/auto/cmake/linguist/test_i18n_source_language/lib2_en.ts.in b/tests/auto/cmake/linguist/test_i18n_source_language/lib2_en.ts.in new file mode 100644 index 000000000..bf74b249c --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_source_language/lib2_en.ts.in @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="en_US"> +<context> + <name>QObject</name> + <message> + <source>We must not see this in the native language's .tr file.</source> + <translation>We oughta steer clear of layin' eyes on this thing in da native file yo.</translation> + </message> + <message numerus="yes"> + <source>%n argument(s) passed</source> + <translation> + <numerusform>one argument passed</numerusform> + <numerusform>%n arguments passed</numerusform> + </translation> + </message> +</context> +</TS> diff --git a/tests/auto/cmake/linguist/test_i18n_subdir/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_subdir/CMakeLists.txt new file mode 100644 index 000000000..4bc38b822 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_subdir/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(test_i18n_subdir) +find_package(Qt6 COMPONENTS Gui LinguistTools) +qt_standard_project_setup() +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +add_subdirectory(subdir) diff --git a/tests/auto/cmake/linguist/test_i18n_subdir/subdir/CMakeLists.txt b/tests/auto/cmake/linguist/test_i18n_subdir/subdir/CMakeLists.txt new file mode 100644 index 000000000..c799968d8 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_subdir/subdir/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_add_executable(app1 + main.cpp) +target_link_libraries(app1 PRIVATE Qt::Gui) +qt_add_translations(app1 + TS_FILES app1_de.ts + NO_GENERATE_PLURALS_TS_FILE +) diff --git a/tests/auto/cmake/linguist/test_i18n_subdir/subdir/app1_de.ts b/tests/auto/cmake/linguist/test_i18n_subdir/subdir/app1_de.ts new file mode 100644 index 000000000..924515f31 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_subdir/subdir/app1_de.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="de_DE"> +<context> + <name>main</name> + <message> + <location filename="main.cpp" line="17"/> + <source>Hello from main!</source> + <translation>Hallo aus der Hauptfunktion!</translation> + </message> +</context> +</TS> diff --git a/tests/auto/cmake/linguist/test_i18n_subdir/subdir/main.cpp b/tests/auto/cmake/linguist/test_i18n_subdir/subdir/main.cpp new file mode 100644 index 000000000..ed3035d18 --- /dev/null +++ b/tests/auto/cmake/linguist/test_i18n_subdir/subdir/main.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtCore/QCoreApplication> +#include <QtCore/QTranslator> + +#include <iostream> + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + + const QString qmFile = ":/i18n/app1_de.qm"; + std::cout << "Loading translation '" << qPrintable(qmFile) << "'..." << std::endl; + QTranslator *translator = new QTranslator(&app); + if (!translator->load(qmFile)) { + std::cerr << "Error: failed to load the translation" << std::endl; + return 1; + } + app.installTranslator(translator); + + std::cout << "Checking translated text..." << std::endl; + const QString translated = QCoreApplication::translate("main", "Hello from main!"); + if (!translated.startsWith("Hallo aus")) { + std::cerr << "Error: translation doesn't seem to work. " + << "The translated text is '" << qPrintable(translated) << "'" << std::endl; + return 2; + } + + std::cout << "All good." << std::endl; + return 0; +} diff --git a/tests/auto/cmake/test_translation_api/CMakeLists.txt b/tests/auto/cmake/linguist/test_translation_api/CMakeLists.txt index ea20ff320..781927f37 100644 --- a/tests/auto/cmake/test_translation_api/CMakeLists.txt +++ b/tests/auto/cmake/linguist/test_translation_api/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + cmake_minimum_required(VERSION 3.16) project(test_update_translation_macro) @@ -50,11 +53,12 @@ function(expect_files_in_list list_var) endfunction() # Test NO_GLOBAL_TARGET for lupdate. +# Also, use the old signature where the first argument is the target. create_app(app1) qt6_add_lupdate(app1 NO_GLOBAL_TARGET TS_FILES myobject_de.ts) -expect_target(app1_lupdate) +expect_target(test_update_translation_macro_lupdate) not_expect_target(app1_lrelease) not_expect_target(update_translations) not_expect_target(release_translations) @@ -66,40 +70,48 @@ qt6_add_lrelease(app2 TS_FILES myobject_de.ts myobject_en.ts QM_FILES_OUTPUT_VARIABLE qm_files) not_expect_target(app2_lupdate) -expect_target(app2_lrelease) +expect_target(test_update_translation_macro_lrelease) not_expect_target(update_translations) not_expect_target(release_translations) expect_files_in_list(qm_files myobject_de.qm myobject_en.qm) # Typical usage of qt_add_lupdate/qt_add_lrelease. Pass some options for good measure. create_app(app3) -qt6_add_lupdate(app3 +qt6_add_lupdate( + SOURCE_TARGETS app1 app2 app3 TS_FILES myobject_no.ts myobject_fi.ts OPTIONS -source-language en_US) qt6_add_lrelease(app3 TS_FILES myobject_no.ts myobject_fi.ts + LRELEASE_TARGET app3_lrelease OPTIONS -compress QM_FILES_OUTPUT_VARIABLE qm_files2) -expect_target(app3_lupdate) +expect_target(test_update_translation_macro_lupdate1) expect_target(app3_lrelease) expect_target(release_translations) expect_files_in_list(qm_files2 myobject_no.qm myobject_fi.qm) # Now do the same with qt6_add_translations. create_app(app4) -qt6_add_translations(app4 - TS_FILES myobject_no.ts myobject_fi.ts +qt6_add_translations( + IMMEDIATE_CALL + TARGETS app4 + SOURCE_TARGETS app4 + LUPDATE_TARGET app4_lupdate + LRELEASE_TARGET app4_lrelease + TS_FILES myobject_lv.ts myobject_et.ts QM_FILES_OUTPUT_VARIABLE qm_files LUPDATE_OPTIONS -source-language en_US LRELEASE_OPTIONS -compress) expect_target(app4_lupdate) expect_target(app4_lrelease) expect_target(release_translations) -expect_files_in_list(qm_files myobject_no.qm myobject_fi.qm) +expect_files_in_list(qm_files myobject_lv.qm myobject_et.qm) # Typical usage of qt_add_translations with a generated resource. create_app(app5) qt6_add_translations(app5 + IMMEDIATE_CALL TS_FILES myobject_ru.ts RESOURCE_PREFIX "/tränslehschns") @@ -112,6 +124,8 @@ target_include_directories(staticlib1 target_link_libraries(staticlib1 PRIVATE Qt6::Core) set(staticlib1_resource_targets "") qt6_add_translations(staticlib1 + IMMEDIATE_CALL + SOURCE_TARGETS staticlib1 TS_FILES myobject_da.ts OUTPUT_TARGETS staticlib1_resource_targets) if("${staticlib1_resource_targets}" STREQUAL "") @@ -121,16 +135,28 @@ endif() # Explicitly specify SOURCES. create_app(app6) qt6_add_translations(app6 + IMMEDIATE_CALL + SOURCE_TARGETS app6 TS_FILES myobject_cs.ts SOURCES myi18nobject.cpp) +# Explicitly specify SOURCES with target-less qt_add_lupdate. +qt6_add_lupdate( + TS_FILES myobject_sk.ts + SOURCES myi18nobject.cpp +) + # Explicitly specify INCLUDE_DIRECTORIES. create_app(app7) qt6_add_translations(app7 + IMMEDIATE_CALL + SOURCE_TARGETS app7 TS_FILES myobject_nl.ts INCLUDE_DIRECTORIES some_dir) -# Build the update_translations target -add_custom_target(my_all_target - ALL - DEPENDS update_translations) +# Build 'update_translations' before any of the '*_lrelease' targets. +get_directory_property(lrelease_targets BUILDSYSTEM_TARGETS) +list(FILTER lrelease_targets INCLUDE REGEX "_lrelease[0-9]*$") +foreach(target IN LISTS lrelease_targets) + add_dependencies(${target} update_translations) +endforeach() diff --git a/tests/auto/cmake/linguist/test_translation_api/myi18nobject.cpp b/tests/auto/cmake/linguist/test_translation_api/myi18nobject.cpp new file mode 100644 index 000000000..061d89e10 --- /dev/null +++ b/tests/auto/cmake/linguist/test_translation_api/myi18nobject.cpp @@ -0,0 +1,24 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QDebug> +#include <QCoreApplication> +#include <QLocale> +#include <QTranslator> + +#include "some_include.h" + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + QTranslator *myappTranslator = new QTranslator; + QString localeName = QLocale::system().name(); + if (!myappTranslator->load("myobject_" + localeName + ".qm", qApp->applicationDirPath())) + return 1; + myappTranslator->setObjectName("myobject_" + localeName); + app.installTranslator(myappTranslator); + + qDebug() << QObject::tr("Hello, world!"); + return 0; +} diff --git a/tests/auto/cmake/test_translation_api/myobject_de.ts b/tests/auto/cmake/linguist/test_translation_api/myobject_de.ts index fb4ee6f55..fb4ee6f55 100644 --- a/tests/auto/cmake/test_translation_api/myobject_de.ts +++ b/tests/auto/cmake/linguist/test_translation_api/myobject_de.ts diff --git a/tests/auto/cmake/linguist/test_translation_api/some_dir/some_include.h b/tests/auto/cmake/linguist/test_translation_api/some_dir/some_include.h new file mode 100644 index 000000000..320e1f982 --- /dev/null +++ b/tests/auto/cmake/linguist/test_translation_api/some_dir/some_include.h @@ -0,0 +1,12 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef SOME_INCLUDE_H +#define SOME_INCLUDE_H + +enum { + Non_Empty_File +}; + +#endif diff --git a/tests/auto/cmake/test_translation_api/myi18nobject.cpp b/tests/auto/cmake/test_translation_api/myi18nobject.cpp deleted file mode 100644 index eacce70db..000000000 --- a/tests/auto/cmake/test_translation_api/myi18nobject.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QDebug> -#include <QCoreApplication> -#include <QLocale> -#include <QTranslator> - -#include "some_include.h" - -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - QTranslator *myappTranslator = new QTranslator; - QString localeName = QLocale::system().name(); - if (!myappTranslator->load("myobject_" + localeName + ".qm", qApp->applicationDirPath())) - return 1; - myappTranslator->setObjectName("myobject_" + localeName); - app.installTranslator(myappTranslator); - - qDebug() << QObject::tr("Hello, world!"); - return 0; -} diff --git a/tests/auto/cmake/test_translation_api/some_dir/some_include.h b/tests/auto/cmake/test_translation_api/some_dir/some_include.h deleted file mode 100644 index 627b9e9e3..000000000 --- a/tests/auto/cmake/test_translation_api/some_dir/some_include.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SOME_INCLUDE_H -#define SOME_INCLUDE_H - -enum { - Non_Empty_File -}; - -#endif diff --git a/tests/auto/cmake/test_uiplugin_module/CMakeLists.txt b/tests/auto/cmake/test_uiplugin_module/CMakeLists.txt index 81c692f96..edb62602d 100644 --- a/tests/auto/cmake/test_uiplugin_module/CMakeLists.txt +++ b/tests/auto/cmake/test_uiplugin_module/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + cmake_minimum_required(VERSION 3.16) project(test_uiplugin_module) diff --git a/tests/auto/cmake/test_uiplugin_module/my_designer_plugin.cpp b/tests/auto/cmake/test_uiplugin_module/my_designer_plugin.cpp index 9cb423287..03a1f8a4a 100644 --- a/tests/auto/cmake/test_uiplugin_module/my_designer_plugin.cpp +++ b/tests/auto/cmake/test_uiplugin_module/my_designer_plugin.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Stephen Kelly <steveire@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Stephen Kelly <steveire@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtUiPlugin> #include <QtUiPlugin/QtUiPlugin> diff --git a/tests/auto/cmake/test_uiplugin_via_designer/CMakeLists.txt b/tests/auto/cmake/test_uiplugin_via_designer/CMakeLists.txt index 70901823b..520fbe111 100644 --- a/tests/auto/cmake/test_uiplugin_via_designer/CMakeLists.txt +++ b/tests/auto/cmake/test_uiplugin_via_designer/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + cmake_minimum_required(VERSION 3.16) project(test_uiplugin_via_designer) diff --git a/tests/auto/cmake/test_uiplugin_via_designer/my_designer_plugin.cpp b/tests/auto/cmake/test_uiplugin_via_designer/my_designer_plugin.cpp index be4a331f6..ff4640c39 100644 --- a/tests/auto/cmake/test_uiplugin_via_designer/my_designer_plugin.cpp +++ b/tests/auto/cmake/test_uiplugin_via_designer/my_designer_plugin.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Stephen Kelly <steveire@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Stephen Kelly <steveire@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtDesigner> #include <QtDesigner/QtDesigner> |