summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2021-06-22 17:37:55 +0200
committerAlexey Edelev <alexey.edelev@qt.io>2021-06-24 20:40:49 +0200
commit9bd418aeab6a3d1b814023c35b869a3fc529cbb2 (patch)
tree41b7cab935127dd70e2733c31e715bb4cd6ab512
parent4b850065b1631437b65542b3cb1c16077d2f0230 (diff)
Implement generating of a module cpp export header
Add an option that automatically generates an export header for a Qt module. The header contains only Q_DECL_EXPORT/Q_DECL_IMPORT related content, so it's not a full replacement of 'global' header files. Task-number: QTBUG-90492 Change-Id: I250d1201b11d4096b7e78e61cbf4565945fe6517 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--cmake/QtBaseGlobalTargets.cmake1
-rw-r--r--cmake/QtModuleHelpers.cmake46
-rw-r--r--cmake/modulecppexports.h.in55
-rw-r--r--sync.profile2
-rw-r--r--tests/auto/cmake/CMakeLists.txt2
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/.cmake.conf1
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/CMakeLists.txt19
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt17
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.cpp45
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.h51
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/use_api.cpp47
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt19
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.cpp45
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.h51
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/use_api.cpp47
15 files changed, 442 insertions, 6 deletions
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index 62cb7d7392..79e9518233 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -235,6 +235,7 @@ qt_copy_or_install(FILES
cmake/QtWasmHelpers.cmake
cmake/QtWrapperScriptHelpers.cmake
cmake/QtWriteArgsFile.cmake
+ cmake/modulecppexports.h.in
DESTINATION "${__GlobalConfig_install_dir}"
)
diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake
index 1cb4f718f4..6715c407b3 100644
--- a/cmake/QtModuleHelpers.cmake
+++ b/cmake/QtModuleHelpers.cmake
@@ -12,6 +12,7 @@ macro(qt_internal_get_internal_add_module_keywords option_args single_args multi
NO_CONFIG_HEADER_FILE
NO_ADDITIONAL_TARGET_INFO
NO_GENERATE_METATYPES
+ GENERATE_CPP_EXPORTS # TODO: Rename to NO_GENERATE_CPP_EXPORTS once migration is done
GENERATE_METATYPES # TODO: Remove once it is not used anymore
)
set(${single_args}
@@ -20,6 +21,7 @@ macro(qt_internal_get_internal_add_module_keywords option_args single_args multi
CONFIG_MODULE_NAME
PRECOMPILED_HEADER
CONFIGURE_FILE_PATH
+ CPP_EXPORT_HEADER_NAME
${__default_target_info_args}
)
set(${multi_args}
@@ -139,6 +141,22 @@ function(qt_internal_add_module target)
string(REPLACE "-" "_" module_define_infix "${module_define_infix}")
string(REPLACE "." "_" module_define_infix "${module_define_infix}")
+ if(arg_MODULE_INCLUDE_NAME)
+ set(module_include_name ${arg_MODULE_INCLUDE_NAME})
+ else()
+ set(module_include_name ${module})
+ endif()
+
+ if(arg_GENERATE_CPP_EXPORTS)
+ if(arg_CPP_EXPORT_HEADER_NAME)
+ set(cpp_export_header_name "CPP_EXPORT_HEADER_NAME;${arg_CPP_EXPORT_HEADER_NAME}")
+ endif()
+ qt_internal_generate_cpp_global_exports(${target} ${module_define_infix}
+ ${module_include_name}
+ "${cpp_export_header_name}"
+ )
+ endif()
+
set(property_prefix "INTERFACE_")
if(NOT arg_HEADER_MODULE)
qt_set_common_target_properties(${target})
@@ -259,12 +277,6 @@ function(qt_internal_add_module target)
endif()
endif()
- if(arg_MODULE_INCLUDE_NAME)
- set(module_include_name ${arg_MODULE_INCLUDE_NAME})
- else()
- set(module_include_name ${module})
- endif()
-
# Module headers:
set_property(TARGET "${target}" APPEND PROPERTY EXPORT_PROPERTIES _qt_module_has_headers)
if(${arg_NO_MODULE_HEADERS} OR ${arg_NO_SYNC_QT})
@@ -796,3 +808,25 @@ function(qt_describe_module target)
qt_install(FILES "${descfile_out}" DESTINATION "${install_dir}")
endfunction()
+
+function(qt_internal_generate_cpp_global_exports target module_define_infix module_include_name)
+ cmake_parse_arguments(arg
+ ""
+ "CPP_EXPORT_HEADER_NAME"
+ "" ${ARGN})
+ qt_internal_module_info(module "${target}")
+ if(NOT arg_CPP_EXPORT_HEADER_NAME)
+ set(arg_CPP_EXPORT_HEADER_NAME "qt${module_lower}exports.h")
+ endif()
+
+ set(generated_header_path
+ "${QT_BUILD_DIR}/include/${module_include_name}/${arg_CPP_EXPORT_HEADER_NAME}"
+ )
+
+ configure_file("${QT_CMAKE_DIR}/modulecppexports.h.in"
+ "${generated_header_path}" @ONLY
+ )
+
+ target_sources(${target} PRIVATE "${generated_header_path}")
+ set_property(TARGET ${target} APPEND PROPERTY PUBLIC_HEADER "${generated_header_path}")
+endfunction()
diff --git a/cmake/modulecppexports.h.in b/cmake/modulecppexports.h.in
new file mode 100644
index 0000000000..fb5c0d918c
--- /dev/null
+++ b/cmake/modulecppexports.h.in
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the @module@ module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT@module_define_infix@EXPORTS_H
+#define QT@module_define_infix@EXPORTS_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(QT_SHARED) || !defined(QT_STATIC)
+# if defined(QT_BUILD_@module_define_infix@_LIB)
+# define Q_@module_define_infix@_EXPORT Q_DECL_EXPORT
+# else
+# define Q_@module_define_infix@_EXPORT Q_DECL_IMPORT
+# endif
+#else
+# define Q_@module_define_infix@_EXPORT
+#endif
+
+#endif // QT@module_define_infix@EXPORTS_H
diff --git a/sync.profile b/sync.profile
index f3805528f8..3433b069a3 100644
--- a/sync.profile
+++ b/sync.profile
@@ -23,6 +23,8 @@
"QtMockPlugins2" => "$basedir/tests/auto/cmake/mockplugins/mockplugins2",
"QtMockPlugins3" => "$basedir/tests/auto/cmake/mockplugins/mockplugins3",
"QtMockStaticResources1" => "$basedir/tests/auto/cmake/test_static_resources/mock_static_resources1",
+ "QtTestAutogeneratingCppExports" => "$basedir/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports",
+ "QtTestAutogeneratingCppExportsCustomName" => "$basedir/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name",
);
%moduleheaders = ( # restrict the module headers to those found in relative path
"QtEglFSDeviceIntegration" => "api",
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 8852c7e68b..c2ab33c96b 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -261,3 +261,5 @@ _qt_internal_test_expect_pass(tst_qaddpreroutine
_qt_internal_test_expect_pass(test_static_resources
BINARY "${CMAKE_CTEST_COMMAND}"
BINARY_ARGS "-V")
+
+_qt_internal_test_expect_pass(test_generating_cpp_exports)
diff --git a/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf b/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf
new file mode 100644
index 0000000000..4e73b3d607
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf
@@ -0,0 +1 @@
+set(QT_REPO_MODULE_VERSION "6.2.0")
diff --git a/tests/auto/cmake/test_generating_cpp_exports/CMakeLists.txt b/tests/auto/cmake/test_generating_cpp_exports/CMakeLists.txt
new file mode 100644
index 0000000000..f01f5bb8f1
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 3.15.0)
+
+include(.cmake.conf)
+
+project(TestGeneratingCppExports
+ DESCRIPTION "Test of the generating of cpp exports"
+ HOMEPAGE_URL "https://qt.io/"
+ LANGUAGES CXX C
+ VERSION "${QT_REPO_MODULE_VERSION}"
+)
+
+find_package(Qt6 COMPONENTS Core BuildInternals Test CONFIG REQUIRED)
+
+qt_build_repo_begin()
+
+add_subdirectory(test_autogenerating_cpp_exports)
+add_subdirectory(test_autogenerating_cpp_exports_custom_name)
+
+qt_build_repo_end()
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt
new file mode 100644
index 0000000000..805bce2a93
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt
@@ -0,0 +1,17 @@
+qt_internal_add_module(TestAutogeneratingCppExports
+ GENERATE_CPP_EXPORTS
+ SOURCES
+ module_api.h
+ module_api.cpp
+ PUBLIC_LIBRARIES
+ Qt::Core
+)
+
+qt_internal_extend_target(TestAutogeneratingCppExports
+ CONDITION GCC OR MINGW
+ COMPILE_OPTIONS
+ -fvisibility=hidden
+)
+
+add_executable(TestAutogeneratingCppExportsApp use_api.cpp)
+target_link_libraries(TestAutogeneratingCppExportsApp PRIVATE TestAutogeneratingCppExports)
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.cpp b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.cpp
new file mode 100644
index 0000000000..bc88991ec1
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "module_api.h"
+
+void TestApi::dummy()
+{
+ // Do nothing
+}
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.h b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.h
new file mode 100644
index 0000000000..8d7e897157
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODULE_API_H
+#define MODULE_API_H
+
+#include <QtTestAutogeneratingCppExports/qttestautogeneratingcppexportsexports.h>
+
+struct Q_TESTAUTOGENERATINGCPPEXPORTS_EXPORT TestApi
+{
+ TestApi() = default;
+ void dummy();
+};
+
+#endif //MODULE_API_H
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/use_api.cpp b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/use_api.cpp
new file mode 100644
index 0000000000..40d9469416
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/use_api.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "module_api.h"
+
+int main(int, char*[])
+{
+ TestApi api;
+ api.dummy();
+ return 0;
+}
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt
new file mode 100644
index 0000000000..0eaa2cd0db
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt
@@ -0,0 +1,19 @@
+qt_internal_add_module(TestAutogeneratingCppExportsCustomName
+ GENERATE_CPP_EXPORTS
+ CPP_EXPORT_HEADER_NAME
+ "customname_exports.hpp"
+ SOURCES
+ module_api.h
+ module_api.cpp
+ PUBLIC_LIBRARIES
+ Qt::Core
+)
+
+qt_internal_extend_target(TestAutogeneratingCppExportsCustomName
+ CONDITION GCC OR MINGW
+ COMPILE_OPTIONS
+ -fvisibility=hidden
+)
+
+add_executable(testapp2 use_api.cpp)
+target_link_libraries(testapp2 PRIVATE TestAutogeneratingCppExportsCustomName)
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.cpp b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.cpp
new file mode 100644
index 0000000000..bc88991ec1
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "module_api.h"
+
+void TestApi::dummy()
+{
+ // Do nothing
+}
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.h b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.h
new file mode 100644
index 0000000000..a954032226
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODULE_API_H
+#define MODULE_API_H
+
+#include <QtTestAutogeneratingCppExportsCustomName/customname_exports.hpp>
+
+struct Q_TESTAUTOGENERATINGCPPEXPORTSCUSTOMNAME_EXPORT TestApi
+{
+ TestApi() = default;
+ void dummy();
+};
+
+#endif //MODULE_API_H
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/use_api.cpp b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/use_api.cpp
new file mode 100644
index 0000000000..40d9469416
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/use_api.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "module_api.h"
+
+int main(int, char*[])
+{
+ TestApi api;
+ api.dummy();
+ return 0;
+}