From: Wolf Vollprecht Date: Sat, 18 Apr 2020 19:06:07 +0000 (+0200) Subject: allow win32 to build shared lib X-Git-Tag: 0.7.12~3^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdb333984279ddf8710b1c8bfe95fd30669a398d;p=thirdparty%2Flibsolv.git allow win32 to build shared lib --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6abb3adb..b34ebc6d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,6 +51,7 @@ IF (DISABLE_SHARED) ADD_LIBRARY (libsolv STATIC ${libsolv_SRCS}) ELSE (DISABLE_SHARED) ADD_LIBRARY (libsolv SHARED ${libsolv_SRCS}) +TARGET_COMPILE_DEFINITIONS(libsolv PRIVATE SOLV_EXPORTS) ENDIF (DISABLE_SHARED) SET_TARGET_PROPERTIES(libsolv PROPERTIES OUTPUT_NAME "solv") diff --git a/win32/config.h b/win32/config.h new file mode 100644 index 00000000..68eca634 --- /dev/null +++ b/win32/config.h @@ -0,0 +1,13 @@ +#ifdef _WIN32 + #ifdef SOLV_STATIC_LIB + #define SOLV_API + #else + #ifdef SOLV_EXPORTS + #define SOLV_API __declspec(dllexport) + #else + #define SOLV_API __declspec(dllimport) + #endif + #endif +#else + #define SOLV_API +#endif \ No newline at end of file diff --git a/win32/getopt.c b/win32/getopt.c index 1e7e4510..c4fc9643 100644 --- a/win32/getopt.c +++ b/win32/getopt.c @@ -5,8 +5,10 @@ #include #include -char *optarg; -int optind=1, opterr=1, optopt, __optpos, __optreset=0; +#include "config.h" + +SOLV_API char *optarg; +SOLV_API int optind=1, opterr=1, optopt, __optpos, __optreset=0; #define optpos __optpos diff --git a/win32/getopt.h b/win32/getopt.h index 35cbd358..861ff0b3 100644 --- a/win32/getopt.h +++ b/win32/getopt.h @@ -5,9 +5,12 @@ extern "C" { #endif +#include "config.h" + int getopt(int, char * const [], const char *); -extern char *optarg; -extern int optind, opterr, optopt, optreset; + +SOLV_API extern char *optarg; +SOLV_API extern int optind, opterr, optopt, optreset; struct option { const char *name;