Skip to content

Commit

Permalink
export/import attributes for Core lib
Browse files Browse the repository at this point in the history
  • Loading branch information
kambala-decapitator committed Dec 25, 2019
1 parent 4d985e6 commit 547ddf4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/core-static.qbs
@@ -1,11 +1,13 @@
StaticLibrary {
name: "core-static"
cpp.cxxLanguageVersion: "c++11"
cpp.defines: "CORE_STATIC"
files: ["core.h", "core.cpp"]
Depends { name: "cpp" }
Depends { name: "header-only" }
Export {
Depends { name: "cpp" }
cpp.defines: "CORE_STATIC"
cpp.includePaths: [product.sourceDirectory]
}
}
8 changes: 7 additions & 1 deletion core/core.h
@@ -1,7 +1,13 @@
#ifndef LIB_H
#define LIB_H

class Core
#ifdef CORE_STATIC
#define CORE_EXPORT
#else
#include "core_dynamic.h"
#endif

class CORE_EXPORT Core
{
public:
Core();
Expand Down
1 change: 1 addition & 0 deletions core/core.qbs
@@ -1,5 +1,6 @@
DynamicLibrary {
name: "core"
cpp.defines: "CORE_LIBRARY"
Depends { name: "core-static"; cpp.linkWholeArchive: true }
Export {
Depends { name: "cpp" }
Expand Down
18 changes: 18 additions & 0 deletions core/core_dynamic.h
@@ -0,0 +1,18 @@
#ifndef CORE_DYNAMIC_H
#define CORE_DYNAMIC_H

#if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
# define Q_DECL_EXPORT __declspec(dllexport)
# define Q_DECL_IMPORT __declspec(dllimport)
#else
# define Q_DECL_EXPORT __attribute__((visibility("default")))
# define Q_DECL_IMPORT __attribute__((visibility("default")))
#endif

#if defined(CORE_LIBRARY)
# define CORE_EXPORT Q_DECL_EXPORT
#else
# define CORE_EXPORT Q_DECL_IMPORT
#endif

#endif // CORE_DYNAMIC_H

0 comments on commit 547ddf4

Please sign in to comment.