Skip to content

Commit b87f6db

Browse files
cinemastcdunn2001
authored andcommitted
Fix for #798
Add preprocessor definitions for MSVC dllexport/dllimport statements (cherry picked from commit 2654b6b)
1 parent ee34ac1 commit b87f6db

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

meson.build

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ install_headers(
4646
jsoncpp_headers,
4747
subdir : 'json')
4848

49+
if get_option('default_library') == 'shared' and meson.get_compiler('cpp').get_id() == 'msvc'
50+
dll_export_flag = '-DJSON_DLL_BUILD'
51+
dll_import_flag = '-DJSON_DLL'
52+
else
53+
dll_export_flag = ''
54+
dll_import_flag = ''
55+
endif
56+
4957
jsoncpp_lib = library(
5058
'jsoncpp',
5159
[ jsoncpp_gen_sources,
@@ -56,7 +64,8 @@ jsoncpp_lib = library(
5664
'src/lib_json/json_writer.cpp'],
5765
soversion : 20,
5866
install : true,
59-
include_directories : jsoncpp_include_directories)
67+
include_directories : jsoncpp_include_directories,
68+
cpp_args: dll_export_flag)
6069

6170
import('pkgconfig').generate(
6271
libraries : jsoncpp_lib,
@@ -82,7 +91,8 @@ jsoncpp_test = executable(
8291
'src/test_lib_json/main.cpp'],
8392
include_directories : jsoncpp_include_directories,
8493
link_with : jsoncpp_lib,
85-
install : false)
94+
install : false,
95+
cpp_args: dll_import_flag)
8696
test(
8797
'unittest_jsoncpp_test',
8898
jsoncpp_test)
@@ -92,7 +102,8 @@ jsontestrunner = executable(
92102
'src/jsontestrunner/main.cpp',
93103
include_directories : jsoncpp_include_directories,
94104
link_with : jsoncpp_lib,
95-
install : false)
105+
install : false,
106+
cpp_args: dll_import_flag)
96107
test(
97108
'unittest_jsontestrunner',
98109
python,

0 commit comments

Comments
 (0)