]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
allow win32 to build shared lib
authorWolf Vollprecht <w.vollprecht@gmail.com>
Sat, 18 Apr 2020 19:06:07 +0000 (21:06 +0200)
committerWolf Vollprecht <w.vollprecht@gmail.com>
Sat, 18 Apr 2020 19:06:07 +0000 (21:06 +0200)
src/CMakeLists.txt
win32/config.h [new file with mode: 0644]
win32/getopt.c
win32/getopt.h

index 6abb3adb3bce410c976af3d015fb627f40b43eb4..b34ebc6d8b6d519b172b64b517e8887f491b9494 100644 (file)
@@ -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 (file)
index 0000000..68eca63
--- /dev/null
@@ -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
index 1e7e451087e2e0914009c7176e3684d620a97cab..c4fc96432204b4d4d536d20486de5d5d4075cece 100644 (file)
@@ -5,8 +5,10 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-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
 
index 35cbd358b52855fb1596da7970c84c18dd0f1cdb..861ff0b39547b6b2f42b78b053fae2116094a88e 100644 (file)
@@ -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;