Skip to content

Commit

Permalink
Merge pull request #14 from Halmo/FixForStaticLib
Browse files Browse the repository at this point in the history
Fixed shared/static library build config
  • Loading branch information
witwall authored May 7, 2018
2 parents f5ff813 + 93765f0 commit dbba5db
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ set (sources mman.c)

add_library (mman ${sources})

if (BUILD_SHARED_LIBS)
target_compile_definitions(mman
PUBLIC MMAN_LIBRARY_DLL
PRIVATE MMAN_LIBRARY
)
endif()

install (TARGETS mman RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX})
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ endif
ifeq ($(BUILD_SHARED),yes)
TARGETS+=libmman.dll
INSTALL+=shared-install
CFLAGS+=-DMMAN_LIBRARY_DLL -DMMAN_LIBRARY
endif

ifeq ($(BUILD_MSVC),yes)
Expand Down
2 changes: 1 addition & 1 deletion mman-win32.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ QT -= core gui

TARGET = mman
TEMPLATE = lib
# CONFIG += staticlib

DEFINES += MMAN_LIBRARY_DLL
DEFINES += MMAN_LIBRARY

HEADERS += \
Expand Down
9 changes: 8 additions & 1 deletion mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
#include <_mingw.h>
#endif

#if defined(MMAN_LIBRARY_DLL)
/* Windows shared libraries (DLL) must be declared export when building the lib and import when building the
application which links against the library. */
#if defined(MMAN_LIBRARY)
#define MMANSHARED_EXPORT __declspec(dllexport)
#else
#define MMANSHARED_EXPORT __declspec(dllimport)
#endif
#endif /* MMAN_LIBRARY */
#else
/* Static libraries do not require a __declspec attribute.*/
#define MMANSHARED_EXPORT
#endif /* MMAN_LIBRARY_DLL */

/* Determine offset type */
#include <stdint.h>
Expand Down

0 comments on commit dbba5db

Please sign in to comment.