Add export macros to enable builds on Windows
As we build the generated OpenAPI clients as libraries, we
actually need to export symbols. That was not noticed while we
only had builds on Linux and macOS, because AFAIK all symbols are
exported there by default.
Now when we want to add Windows builds, we actually need to
introduce the proper export macros, that would expand to dllexport
or dllimport.
We use the logic from Qt, also relying on the QT_SHARED and
QT_STATIC definitions. That should be fine since we're anyway
using qt_add_library() to create the libraries, and it inherits
the build type from Qt.
Since the client is separated into a common library and a client
library, we need to introduce two separate export macros, because
otherwise we won't be able to link the client library with the
common library.
We add two new templates:
* common/common-exports.mustache for the exports from the common
library
* exports.mustache for the exports from the client library
Task-number: QTBUG-138968
Change-Id: Ib6464cb542acd7783bfcb2dbbcd565c322128173
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
| commit | 01eb75b80d46c3fd35f9c8c80887512fd5f9ccb6 |
| parent | 256bade991f680557d6899da56f5ef8202d73a50 |
| author | Ivan Solovev <ivan.solovev@qt.io> |
| committer | Ivan Solovev <ivan.solovev@qt.io> |
| commit time | Fri, 31 Oct 2025 11:24:36 +0100 |
- M src/tools/qtopenapi-generator/src/main/java/org/qtproject/qt/codegen/CppQt6ClientGenerator.java
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/CMakeLists.txt.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/api-header.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/CMakeLists.txt.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/HttpFileElement.h.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/HttpRequest.h.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-header.mustache
- A src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/common-exports.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/enum.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/helpers-header.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/object.mustache
- A src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/exports.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/model-header.mustache
- M tests/auto/colorpalette/client/client/CMakeLists.txt
- M tests/auto/colorpalette/client/client/QtOAIColor.h
- M tests/auto/colorpalette/client/client/QtOAIColorPage.h
- M tests/auto/colorpalette/client/client/QtOAIColorsApi.h
- M tests/auto/colorpalette/client/client/QtOAIDefaultApi.h
- A tests/auto/colorpalette/client/client/QtOAIExports.h
- M tests/auto/colorpalette/client/client/QtOAIRegisterApi.h
- M tests/auto/colorpalette/client/client/QtOAITestObject.h
- M tests/auto/colorpalette/client/client/QtOAITestOperation_request.h
- M tests/auto/colorpalette/client/client/QtOAIUpdateUser_request.h
- M tests/auto/colorpalette/client/client/QtOAIUser.h
- M tests/auto/colorpalette/client/client/QtOAIUserPage.h
- M tests/auto/colorpalette/client/client/QtOAIUsersApi.h
- M tests/auto/colorpalette/client/common/CMakeLists.txt
- M tests/auto/colorpalette/client/common/QtOAIBaseApi.h
- A tests/auto/colorpalette/client/common/QtOAICommonExports.h
- M tests/auto/colorpalette/client/common/QtOAIEnum.h
- A tests/auto/colorpalette/client/common/QtOAIExports.h
- M tests/auto/colorpalette/client/common/QtOAIHelpers.h
- M tests/auto/colorpalette/client/common/QtOAIHttpFileElement.h
- M tests/auto/colorpalette/client/common/QtOAIHttpRequest.h
- M tests/auto/colorpalette/client/common/QtOAIObject.h
- M tests/auto/colorpalette/qmlclient/client/CMakeLists.txt
- M tests/auto/colorpalette/qmlclient/client/OAIColor.h
- M tests/auto/colorpalette/qmlclient/client/OAIColorPage.h
- M tests/auto/colorpalette/qmlclient/client/OAIColorsApi.h
- M tests/auto/colorpalette/qmlclient/client/OAIDefaultApi.h
- A tests/auto/colorpalette/qmlclient/client/OAIExports.h
- M tests/auto/colorpalette/qmlclient/client/OAIRegisterApi.h
- M tests/auto/colorpalette/qmlclient/client/OAITestObject.h
- M tests/auto/colorpalette/qmlclient/client/OAITestOperation_request.h
- M tests/auto/colorpalette/qmlclient/client/OAIUpdateUser_request.h
- M tests/auto/colorpalette/qmlclient/client/OAIUser.h
- M tests/auto/colorpalette/qmlclient/client/OAIUserPage.h
- M tests/auto/colorpalette/qmlclient/client/OAIUsersApi.h
- M tests/auto/colorpalette/qmlclient/common/CMakeLists.txt
- M tests/auto/colorpalette/qmlclient/common/OAIBaseApi.h
- A tests/auto/colorpalette/qmlclient/common/OAICommonExports.h
- M tests/auto/colorpalette/qmlclient/common/OAIEnum.h
- A tests/auto/colorpalette/qmlclient/common/OAIExports.h
- M tests/auto/colorpalette/qmlclient/common/OAIHelpers.h
- M tests/auto/colorpalette/qmlclient/common/OAIHttpFileElement.h
- M tests/auto/colorpalette/qmlclient/common/OAIHttpRequest.h
- M tests/auto/colorpalette/qmlclient/common/OAIObject.h
- M tests/auto/compression/client/client/CMakeLists.txt
- A tests/auto/compression/client/client/QtOAIExports.h
- M tests/auto/compression/client/client/QtOAITestApi.h
- M tests/auto/compression/client/common/CMakeLists.txt
- M tests/auto/compression/client/common/QtOAIBaseApi.h
- A tests/auto/compression/client/common/QtOAICommonExports.h
- M tests/auto/compression/client/common/QtOAIEnum.h
- A tests/auto/compression/client/common/QtOAIExports.h
- M tests/auto/compression/client/common/QtOAIHelpers.h
- M tests/auto/compression/client/common/QtOAIHttpFileElement.h
- M tests/auto/compression/client/common/QtOAIHttpRequest.h
- M tests/auto/compression/client/common/QtOAIObject.h
- M tests/auto/linking_several_clients/client1/client/CMakeLists.txt
- M tests/auto/linking_several_clients/client1/client/QtOAIClient1TestApi.h
- A tests/auto/linking_several_clients/client1/client/QtOAIExports.h
- M tests/auto/linking_several_clients/client1/common/CMakeLists.txt
- M tests/auto/linking_several_clients/client1/common/QtOAIBaseApi.h
- A tests/auto/linking_several_clients/client1/common/QtOAICommonExports.h
- M tests/auto/linking_several_clients/client1/common/QtOAIEnum.h
- A tests/auto/linking_several_clients/client1/common/QtOAIExports.h
- M tests/auto/linking_several_clients/client1/common/QtOAIHelpers.h
- M tests/auto/linking_several_clients/client1/common/QtOAIHttpFileElement.h
- M tests/auto/linking_several_clients/client1/common/QtOAIHttpRequest.h
- M tests/auto/linking_several_clients/client1/common/QtOAIObject.h
- M tests/auto/linking_several_clients/client2/client/CMakeLists.txt
- M tests/auto/linking_several_clients/client2/client/QtOAIClient2TestApi.h
- A tests/auto/linking_several_clients/client2/client/QtOAIExports.h
- M tests/auto/mediatype/client/client/CMakeLists.txt
- A tests/auto/mediatype/client/client/QtOAIExports.h
- M tests/auto/mediatype/client/client/QtOAIPostApplicationJsonSeveralObjects_request.h
- M tests/auto/mediatype/client/client/QtOAIPostMultiPartData_request_formObject.h
- M tests/auto/mediatype/client/client/QtOAITestApi.h
- M tests/auto/mediatype/client/client/QtOAIUser.h
- M tests/auto/mediatype/client/common/CMakeLists.txt
- M tests/auto/mediatype/client/common/QtOAIBaseApi.h
- A tests/auto/mediatype/client/common/QtOAICommonExports.h
- M tests/auto/mediatype/client/common/QtOAIEnum.h
- A tests/auto/mediatype/client/common/QtOAIExports.h
- M tests/auto/mediatype/client/common/QtOAIHelpers.h
- M tests/auto/mediatype/client/common/QtOAIHttpFileElement.h
- M tests/auto/mediatype/client/common/QtOAIHttpRequest.h
- M tests/auto/mediatype/client/common/QtOAIObject.h
- M tests/auto/openapi2.0/client/client/CMakeLists.txt
- A tests/auto/openapi2.0/client/client/QtOAIExports.h
- M tests/auto/openapi2.0/client/client/QtOAIFakeApi.h
- M tests/auto/openapi2.0/client/common/CMakeLists.txt
- M tests/auto/openapi2.0/client/common/QtOAIBaseApi.h
- A tests/auto/openapi2.0/client/common/QtOAICommonExports.h
- M tests/auto/openapi2.0/client/common/QtOAIEnum.h
- A tests/auto/openapi2.0/client/common/QtOAIExports.h
- M tests/auto/openapi2.0/client/common/QtOAIHelpers.h
- M tests/auto/openapi2.0/client/common/QtOAIHttpFileElement.h
- M tests/auto/openapi2.0/client/common/QtOAIHttpRequest.h
- M tests/auto/openapi2.0/client/common/QtOAIObject.h
- M tests/auto/operation-parameters/client/client/CMakeLists.txt
- M tests/auto/operation-parameters/client/client/QtOAIDoubleResponse.h
- A tests/auto/operation-parameters/client/client/QtOAIExports.h
- M tests/auto/operation-parameters/client/client/QtOAIFloatResponse.h
- M tests/auto/operation-parameters/client/client/QtOAITestApi.h
- M tests/auto/operation-parameters/client/client/QtOAITestObject.h
- M tests/auto/operation-parameters/client/common/CMakeLists.txt
- M tests/auto/operation-parameters/client/common/QtOAIBaseApi.h
- A tests/auto/operation-parameters/client/common/QtOAICommonExports.h
- M tests/auto/operation-parameters/client/common/QtOAIEnum.h
- A tests/auto/operation-parameters/client/common/QtOAIExports.h
- M tests/auto/operation-parameters/client/common/QtOAIHelpers.h
- M tests/auto/operation-parameters/client/common/QtOAIHttpFileElement.h
- M tests/auto/operation-parameters/client/common/QtOAIHttpRequest.h
- M tests/auto/operation-parameters/client/common/QtOAIObject.h
- M tests/auto/petstore/client/client/CMakeLists.txt
- M tests/auto/petstore/client/client/QtOAIApiResponse.h
- M tests/auto/petstore/client/client/QtOAICategory.h
- A tests/auto/petstore/client/client/QtOAIExports.h
- M tests/auto/petstore/client/client/QtOAIOrder.h
- M tests/auto/petstore/client/client/QtOAIPet.h
- M tests/auto/petstore/client/client/QtOAIPetApi.h
- M tests/auto/petstore/client/client/QtOAIStoreApi.h
- M tests/auto/petstore/client/client/QtOAITag.h
- M tests/auto/petstore/client/client/QtOAIUser.h
- M tests/auto/petstore/client/client/QtOAIUserApi.h
- M tests/auto/petstore/client/common/CMakeLists.txt
- M tests/auto/petstore/client/common/QtOAIBaseApi.h
- A tests/auto/petstore/client/common/QtOAICommonExports.h
- M tests/auto/petstore/client/common/QtOAIEnum.h
- A tests/auto/petstore/client/common/QtOAIExports.h
- M tests/auto/petstore/client/common/QtOAIHelpers.h
- M tests/auto/petstore/client/common/QtOAIHttpFileElement.h
- M tests/auto/petstore/client/common/QtOAIHttpRequest.h
- M tests/auto/petstore/client/common/QtOAIObject.h
- M tests/auto/petstore/qmlclient/client/CMakeLists.txt
- M tests/auto/petstore/qmlclient/client/OAIApiResponse.h
- M tests/auto/petstore/qmlclient/client/OAICategory.h
- A tests/auto/petstore/qmlclient/client/OAIExports.h
- M tests/auto/petstore/qmlclient/client/OAIOrder.h
- M tests/auto/petstore/qmlclient/client/OAIPet.h
- M tests/auto/petstore/qmlclient/client/OAIPetApi.h
- M tests/auto/petstore/qmlclient/client/OAIStoreApi.h
- M tests/auto/petstore/qmlclient/client/OAITag.h
- M tests/auto/petstore/qmlclient/client/OAIUser.h
- M tests/auto/petstore/qmlclient/client/OAIUserApi.h
- M tests/auto/petstore/qmlclient/common/CMakeLists.txt
- M tests/auto/petstore/qmlclient/common/OAIBaseApi.h
- A tests/auto/petstore/qmlclient/common/OAICommonExports.h
- M tests/auto/petstore/qmlclient/common/OAIEnum.h
- A tests/auto/petstore/qmlclient/common/OAIExports.h
- M tests/auto/petstore/qmlclient/common/OAIHelpers.h
- M tests/auto/petstore/qmlclient/common/OAIHttpFileElement.h
- M tests/auto/petstore/qmlclient/common/OAIHttpRequest.h
- M tests/auto/petstore/qmlclient/common/OAIObject.h
- M tests/auto/responses/client/client/CMakeLists.txt
- M tests/auto/responses/client/client/QtOAIApplicationJsonObjectResponse_200_response.h
- A tests/auto/responses/client/client/QtOAIExports.h
- M tests/auto/responses/client/client/QtOAITestApi.h
- M tests/auto/responses/client/common/CMakeLists.txt
- M tests/auto/responses/client/common/QtOAIBaseApi.h
- A tests/auto/responses/client/common/QtOAICommonExports.h
- M tests/auto/responses/client/common/QtOAIEnum.h
- A tests/auto/responses/client/common/QtOAIExports.h
- M tests/auto/responses/client/common/QtOAIHelpers.h
- M tests/auto/responses/client/common/QtOAIHttpFileElement.h
- M tests/auto/responses/client/common/QtOAIHttpRequest.h
- M tests/auto/responses/client/common/QtOAIObject.h