diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2021-03-11 19:13:03 +0100 |
---|---|---|
committer | Alexey Edelev <alexey.edelev@qt.io> | 2021-03-23 13:10:08 +0100 |
commit | b8935eca5625be034632200adcccf18a398f67a2 (patch) | |
tree | 4dc4117a1383dc71f4292248119910dba2d8184e /tests | |
parent | 2b2de60a369ba195703435328fc3812dbef430e5 (diff) |
Add qt6_target_typelibs function
qt6_target_typelibs should replace the qmake functionality associated
with the TYPELIBS variable. This function adds custom call of the
dumpcpp program to generate typelib-related sources and adds the
sources to the target.
Pick-to: 6.1
Task-number: QTBUG-78167
Change-Id: I7b61a2b1804162e723e862945a9650a00776e678
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests')
14 files changed, 272 insertions, 8 deletions
diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index 2502019..adb25cf 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -2,8 +2,8 @@ add_subdirectory(conversion) add_subdirectory(qaxobject) -# add_subdirectory(dumpcpp) (needs typelib target) # special case -# add_subdirectory(cmake) # special case +add_subdirectory(dumpcpp) +add_subdirectory(cmake) if(NOT GCC) add_subdirectory(qaxscript) endif() diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 4f15a69..7c882c2 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -1,12 +1,44 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.14) -project(qmake_cmake_files) +project(qtactivetqt_cmake_tests) enable_testing() -find_package(Qt5Core REQUIRED) +set(required_packages Core) +set(optional_packages Widgets Gui) -include("${_Qt5CTestMacros}") +# Setup the test when called as a completely standalone project. +if(TARGET Qt6::Core) + # Tests are built as part of the qtactiveqt build tree. + # Setup paths so that the Qt packages are found. + qt_internal_set_up_build_dir_package_paths() +endif() -expect_pass(test_modules) +find_package(Qt6 REQUIRED COMPONENTS ${required_packages}) +find_package(Qt6 OPTIONAL_COMPONENTS ${optional_packages}) + +# Setup common test variables which were previously set by ctest_testcase_common.prf. +set(CMAKE_MODULES_UNDER_TEST "${required_packages}") +foreach(qt_package ${optional_packages}) + set(package_name "${QT_CMAKE_EXPORT_NAMESPACE}${qt_package}") + list(APPEND CMAKE_MODULES_UNDER_TEST "${qt_package}") +endforeach() + +foreach(qt_package ${CMAKE_MODULES_UNDER_TEST}) + if(${package_name}_FOUND) + set(CMAKE_${qt_package}_MODULE_MAJOR_VERSION "${${package_name}_VERSION_MAJOR}") + set(CMAKE_${qt_package}_MODULE_MINOR_VERSION "${${package_name}_VERSION_MINOR}") + set(CMAKE_${qt_package}_MODULE_PATCH_VERSION "${${package_name}_VERSION_PATCH}") + endif() +endforeach() + +include("${_Qt6CTestMacros}") + +if(TARGET Qt6::Widgets AND TARGET Qt6::Gui) + _qt_internal_test_expect_pass(test_target_typelibs) + _qt_internal_test_expect_pass(test_target_typelibs_absolute) + _qt_internal_test_expect_fail(test_target_typelibs_empty_libs) + _qt_internal_test_expect_fail(test_target_typelibs_non_existing_libs) + _qt_internal_test_expect_pass(test_target_typelibs_out_dir) +endif() diff --git a/tests/auto/cmake/test_target_typelibs/CMakeLists.txt b/tests/auto/cmake/test_target_typelibs/CMakeLists.txt new file mode 100644 index 0000000..44ce88f --- /dev/null +++ b/tests/auto/cmake/test_target_typelibs/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.14) +project(tst_typelibs) + +find_package(Qt6 COMPONENTS AxContainer Gui Widgets CONFIG REQUIRED) + +add_executable(tst_typelibs main.cpp) +target_link_libraries(tst_typelibs PRIVATE Qt6::AxContainer Qt6::Gui Qt6::Widgets) + +qt6_target_typelibs(tst_typelibs LIBRARIES "ieframe.dll") diff --git a/tests/auto/cmake/test_target_typelibs/main.cpp b/tests/auto/cmake/test_target_typelibs/main.cpp new file mode 100644 index 0000000..1b848bc --- /dev/null +++ b/tests/auto/cmake/test_target_typelibs/main.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** 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 "ieframe.h" + +int main(int argc, char *argv[]) +{ + SHDocVw::WebBrowser* webBrowser = new SHDocVw::WebBrowser; + delete webBrowser; + return 0; +} diff --git a/tests/auto/cmake/test_target_typelibs_absolute/CMakeLists.txt b/tests/auto/cmake/test_target_typelibs_absolute/CMakeLists.txt new file mode 100644 index 0000000..f8455fa --- /dev/null +++ b/tests/auto/cmake/test_target_typelibs_absolute/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.14) +project(tst_typelibs) + +find_package(Qt6 COMPONENTS AxContainer Gui Widgets CONFIG REQUIRED) + +add_executable(tst_typelibs main.cpp) +target_link_libraries(tst_typelibs PRIVATE Qt6::AxContainer Qt6::Gui Qt6::Widgets) + +qt6_target_typelibs(tst_typelibs LIBRARIES "$ENV{SystemRoot}/System32/ieframe.dll") diff --git a/tests/auto/cmake/test_target_typelibs_absolute/main.cpp b/tests/auto/cmake/test_target_typelibs_absolute/main.cpp new file mode 100644 index 0000000..1b848bc --- /dev/null +++ b/tests/auto/cmake/test_target_typelibs_absolute/main.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** 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 "ieframe.h" + +int main(int argc, char *argv[]) +{ + SHDocVw::WebBrowser* webBrowser = new SHDocVw::WebBrowser; + delete webBrowser; + return 0; +} diff --git a/tests/auto/cmake/test_target_typelibs_empty_libs/CMakeLists.txt b/tests/auto/cmake/test_target_typelibs_empty_libs/CMakeLists.txt new file mode 100644 index 0000000..1bbeed7 --- /dev/null +++ b/tests/auto/cmake/test_target_typelibs_empty_libs/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.14) +project(tst_typelibs) + +find_package(Qt6 COMPONENTS AxContainer Gui Widgets CONFIG REQUIRED) + +add_executable(tst_typelibs main.cpp) +target_link_libraries(tst_typelibs PRIVATE Qt6::AxContainer Qt6::Gui Qt6::Widgets) + +qt6_target_typelibs(tst_typelibs) diff --git a/tests/auto/cmake/test_target_typelibs_empty_libs/main.cpp b/tests/auto/cmake/test_target_typelibs_empty_libs/main.cpp new file mode 100644 index 0000000..1b848bc --- /dev/null +++ b/tests/auto/cmake/test_target_typelibs_empty_libs/main.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** 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 "ieframe.h" + +int main(int argc, char *argv[]) +{ + SHDocVw::WebBrowser* webBrowser = new SHDocVw::WebBrowser; + delete webBrowser; + return 0; +} diff --git a/tests/auto/cmake/test_target_typelibs_non_existing_libs/CMakeLists.txt b/tests/auto/cmake/test_target_typelibs_non_existing_libs/CMakeLists.txt new file mode 100644 index 0000000..448732a --- /dev/null +++ b/tests/auto/cmake/test_target_typelibs_non_existing_libs/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.14) +project(tst_typelibs) + +find_package(Qt6 COMPONENTS AxContainer Gui Widgets CONFIG REQUIRED) + +add_executable(tst_typelibs main.cpp) +target_link_libraries(tst_typelibs PRIVATE Qt6::AxContainer Qt6::Gui Qt6::Widgets) + +qt6_target_typelibs(tst_typelibs LIBRARIES "ieframe.dll" "qt100notexistinglib.dll") diff --git a/tests/auto/cmake/test_target_typelibs_non_existing_libs/main.cpp b/tests/auto/cmake/test_target_typelibs_non_existing_libs/main.cpp new file mode 100644 index 0000000..1b848bc --- /dev/null +++ b/tests/auto/cmake/test_target_typelibs_non_existing_libs/main.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** 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 "ieframe.h" + +int main(int argc, char *argv[]) +{ + SHDocVw::WebBrowser* webBrowser = new SHDocVw::WebBrowser; + delete webBrowser; + return 0; +} diff --git a/tests/auto/cmake/test_target_typelibs_out_dir/CMakeLists.txt b/tests/auto/cmake/test_target_typelibs_out_dir/CMakeLists.txt new file mode 100644 index 0000000..66e753e --- /dev/null +++ b/tests/auto/cmake/test_target_typelibs_out_dir/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.14) +project(tst_typelibs) + +find_package(Qt6 COMPONENTS AxContainer Gui Widgets CONFIG REQUIRED) + +add_executable(tst_typelibs main.cpp) +target_link_libraries(tst_typelibs PRIVATE Qt6::AxContainer Qt6::Gui Qt6::Widgets) +target_include_directories(tst_typelibs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + +qt6_target_typelibs(tst_typelibs LIBRARIES "ieframe.dll" + OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/typelibs" +) diff --git a/tests/auto/cmake/test_target_typelibs_out_dir/main.cpp b/tests/auto/cmake/test_target_typelibs_out_dir/main.cpp new file mode 100644 index 0000000..6a3ecb4 --- /dev/null +++ b/tests/auto/cmake/test_target_typelibs_out_dir/main.cpp @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** 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 "typelibs/ieframe.h" + +int main(int argc, char *argv[]) +{ + SHDocVw::WebBrowser* webBrowser = new SHDocVw::WebBrowser; + delete webBrowser; + return 0; +} diff --git a/tests/auto/dumpcpp/CMakeLists.txt b/tests/auto/dumpcpp/CMakeLists.txt index 91da6c3..051e7f5 100644 --- a/tests/auto/dumpcpp/CMakeLists.txt +++ b/tests/auto/dumpcpp/CMakeLists.txt @@ -4,7 +4,7 @@ ## tst_dumpcpp Test: ##################################################################### -qt_add_test(tst_dumpcpp +qt_internal_add_test(tst_dumpcpp SOURCES tst_dumpcpp.cpp PUBLIC_LIBRARIES @@ -16,5 +16,7 @@ qt_add_test(tst_dumpcpp #### Keys ignored in scope 1:.:.:dumpcpp.pro:<TRUE>: # TYPELIBS = "$$(SystemRoot)\\system32\\ieframe.dll" +qt6_target_typelibs(tst_dumpcpp LIBRARIES "ieframe.dll") # special case + ## Scopes: ##################################################################### diff --git a/tests/manual/dumpcpp/CMakeLists.txt b/tests/manual/dumpcpp/CMakeLists.txt index 44e94a8..6909014 100644 --- a/tests/manual/dumpcpp/CMakeLists.txt +++ b/tests/manual/dumpcpp/CMakeLists.txt @@ -22,5 +22,7 @@ qt_internal_add_manual_test(dumpcpp # special case # TEMPLATE = "app" # TYPELIBS = "$$(SystemRoot)\\system32\\ieframe.dll" +qt6_target_typelibs(tst_dumpcpp LIBRARIES "ieframe.dll") # special case + ## Scopes: ##################################################################### |