orc: fix static build on windows
authorTim-Philipp Müller <tim@centricular.com>
Fri, 18 May 2018 08:10:17 +0000 (09:10 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 18 May 2018 08:10:17 +0000 (09:10 +0100)
Orc users mustn't use __declspec(dllimport) when
linking against a static liborc.

orc/meson.build
orc/orcutils.h

index 541603f..e629f05 100644 (file)
@@ -118,12 +118,15 @@ orc_sta = static_library ('orc-' + orc_api,
 
 if get_option('default_library') == 'static'
   orc_lib = orc_sta
+  orc_dep_cargs = ['-DORC_STATIC_COMPILATION']
 else
   orc_lib = orc_shr
+  orc_dep_cargs = []
 endif
 
 orc_dep = declare_dependency(include_directories : orc_inc,
                              dependencies : orc_dependencies,
+                             compile_args : orc_dep_cargs,
                              link_with : orc_lib)
 
 executable ('generate-bytecode',
index 9713d6f..dd73ea5 100644 (file)
@@ -202,7 +202,7 @@ typedef unsigned int orc_bool;
 /* FIXME: unused, remove */
 #define ORC_EXPORT
 
-#if defined(_MSC_VER) || defined(_WIN32)
+#if (defined(_MSC_VER) || defined(_WIN32)) && !defined(ORC_STATIC_COMPILATION)
 #define ORC_API_IMPORT __declspec(dllimport) extern
 #else
 #define ORC_API_IMPORT extern