From 6d1667f55c0811840cb15173f3e682f08fe57760 Mon Sep 17 00:00:00 2001 From: Daniel Nicoletti Date: Wed, 22 Jun 2022 10:05:50 -0300 Subject: [PATCH] Fix shared builds --- QXlsx/CMakeLists.txt | 3 +++ QXlsx/QXlsx.pri | 2 +- QXlsx/header/xlsxglobal.h | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/QXlsx/CMakeLists.txt b/QXlsx/CMakeLists.txt index 0357c22f..c622113c 100644 --- a/QXlsx/CMakeLists.txt +++ b/QXlsx/CMakeLists.txt @@ -148,6 +148,9 @@ add_library(QXlsx ) add_library(QXlsx::QXlsx ALIAS QXlsx) +if (BUILD_SHARED_LIBS) + target_compile_definitions(QXlsx PUBLIC QXlsx_SHAREDLIB) +endif() target_link_libraries(${PROJECT_NAME} Qt${QT_VERSION_MAJOR}::Core diff --git a/QXlsx/QXlsx.pri b/QXlsx/QXlsx.pri index e9f8e07b..8e2ea599 100644 --- a/QXlsx/QXlsx.pri +++ b/QXlsx/QXlsx.pri @@ -15,7 +15,7 @@ CONFIG += c++11 DEFINES += QT_DEPRECATED_WARNINGS # For DLL visibility -#DEFINES += QXlsx_EXPORTS +#DEFINES += QXlsx_SHAREDLIB QXlsx_EXPORTS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. diff --git a/QXlsx/header/xlsxglobal.h b/QXlsx/header/xlsxglobal.h index e95a96d4..52fd5690 100644 --- a/QXlsx/header/xlsxglobal.h +++ b/QXlsx/header/xlsxglobal.h @@ -16,10 +16,12 @@ #include #include +#if defined(QXlsx_SHAREDLIB) #if defined(QXlsx_EXPORTS) # define QXLSX_EXPORT Q_DECL_EXPORT -#elif defined (QXlsx_IMPORTS) +#else # define QXLSX_EXPORT Q_DECL_IMPORT +#endif #else # define QXLSX_EXPORT #endif