diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a945419b..306354f7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1037,6 +1037,10 @@ else() set(PRIVATE_KEYWORD "PRIVATE") endif() +if(BUILD_SHARED_LIBS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINPR_DLL") +endif() + add_subdirectory(winpr) # Sub-directories diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index ab9d8cd35..2da25a426 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -158,6 +158,10 @@ if(NOT DEFINED BUILD_SHARED_LIBS) set(BUILD_SHARED_LIBS ON) endif() +if(BUILD_SHARED_LIBS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINPR_DLL") +endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINPR_EXPORTS") # Enable 64bit file support on linux and FreeBSD. diff --git a/winpr/include/winpr/winpr.h b/winpr/include/winpr/winpr.h index 9961e985e..a2da2001d 100644 --- a/winpr/include/winpr/winpr.h +++ b/winpr/include/winpr/winpr.h @@ -21,6 +21,7 @@ #include +#ifdef WINPR_DLL #if defined _WIN32 || defined __CYGWIN__ #ifdef WINPR_EXPORTS #ifdef __GNUC__ @@ -42,6 +43,9 @@ #define WINPR_API #endif #endif +#else /* WINPR_DLL */ +#define WINPR_API +#endif /* Thread local storage keyword define */ #if defined _WIN32 || defined __CYGWIN__