@@ -123,6 +123,36 @@ conf_data = configuration_data(
123
123
},
124
124
)
125
125
126
+ #### System-specific Variables
127
+
128
+ SYSTEM = build_machine .system()
129
+ if SYSTEM == ' linux'
130
+ conf_data.set(' OS_LINUX' , true )
131
+ OS_TYPE = ' Linux'
132
+ elif SYSTEM == ' freebsd'
133
+ conf_data.set(' OS_BSD' , true )
134
+ conf_data.set(' OS_FREEBSD' , true )
135
+ OS_TYPE = ' BSD'
136
+ elif SYSTEM == ' netbsd'
137
+ conf_data.set(' OS_BSD' , true )
138
+ conf_data.set(' OS_NETBSD' , true )
139
+ OS_TYPE = ' BSD'
140
+ elif SYSTEM == ' openbsd'
141
+ conf_data.set(' OS_BSD' , true )
142
+ conf_data.set(' OS_OPENBSD' , true )
143
+ OS_TYPE = ' BSD'
144
+ elif SYSTEM == ' sun'
145
+ conf_data.set(' OS_SOLARIS' , true )
146
+ OS_TYPE = ' Solaris'
147
+ elif SYSTEM == ' darwin'
148
+ conf_data.set(' OS_BSD' , true )
149
+ conf_data.set(' OS_OSX' , true )
150
+ OS_TYPE = ' BSD'
151
+ else
152
+ error (f' Build failed: Unsupported system "@SYSTEM@".' )
153
+ endif
154
+ message (f' Detected system "@SYSTEM@".' )
155
+
126
156
#### Programs
127
157
128
158
python_exe = find_program (' python3' , ' python' , required : false )
@@ -261,15 +291,30 @@ foreach dep : ['yang', 'yang-cpp', 'sysrepo', 'sysrepo-cpp']
261
291
endif
262
292
263
293
# Search in /opt.
264
- lib = cpp.find_library (dep, dirs : [f' /opt/@dep@/lib' ], required : false )
265
- if lib.found()
266
- netconf_deps = netconf_deps + {
267
- dep : declare_dependency (
268
- dependencies : [lib],
269
- include_directories : include_directories (f' /opt/@dep@/include' ),
270
- ),
271
- }
272
- endif
294
+ foreach prefix : ['' , ' lib' ]
295
+ path = f' /opt/@prefix@@dep@'
296
+ lib = cpp.find_library (dep, dirs : [f' /@path@/lib' ], required : false )
297
+ if lib.found()
298
+ netconf_deps = netconf_deps + {
299
+ dep : declare_dependency (
300
+ dependencies : [lib],
301
+ include_directories : include_directories (f' /@path@/include' ),
302
+ variables : {' prefix' : f' @path@' },
303
+ ),
304
+ }
305
+ if SYSTEM == ' darwin'
306
+ add_project_link_arguments (
307
+ f' -Wl,-rpath,@path@/lib' ,
308
+ language : ' cpp' ,
309
+ )
310
+ else
311
+ add_project_link_arguments (
312
+ f' -Wl,-rpath=@path@/lib' ,
313
+ language : ' cpp' ,
314
+ )
315
+ endif
316
+ endif
317
+ endforeach
273
318
endforeach
274
319
foreach dep : [' yang' , ' yang-cpp' , ' sysrepo' , ' sysrepo-cpp' ]
275
320
if netconf_deps[dep].found()
@@ -341,36 +386,6 @@ result = cpp.run(
341
386
)
342
387
conf_data.set(' HAVE_STREAM_TRUNCATED_ERROR' , result.returncode() == 0 )
343
388
344
- #### System-specific Variables
345
-
346
- SYSTEM = build_machine .system()
347
- if SYSTEM == ' linux'
348
- conf_data.set(' OS_LINUX' , true )
349
- OS_TYPE = ' Linux'
350
- elif SYSTEM == ' freebsd'
351
- conf_data.set(' OS_BSD' , true )
352
- conf_data.set(' OS_FREEBSD' , true )
353
- OS_TYPE = ' BSD'
354
- elif SYSTEM == ' netbsd'
355
- conf_data.set(' OS_BSD' , true )
356
- conf_data.set(' OS_NETBSD' , true )
357
- OS_TYPE = ' BSD'
358
- elif SYSTEM == ' openbsd'
359
- conf_data.set(' OS_BSD' , true )
360
- conf_data.set(' OS_OPENBSD' , true )
361
- OS_TYPE = ' BSD'
362
- elif SYSTEM == ' sun'
363
- conf_data.set(' OS_SOLARIS' , true )
364
- OS_TYPE = ' Solaris'
365
- elif SYSTEM == ' darwin'
366
- conf_data.set(' OS_BSD' , true )
367
- conf_data.set(' OS_OSX' , true )
368
- OS_TYPE = ' BSD'
369
- else
370
- error (f' Build failed: Unsupported system "@SYSTEM@".' )
371
- endif
372
- message (f' Detected system "@SYSTEM@".' )
373
-
374
389
#### System-specific Compiler Flags
375
390
376
391
compile_args = []
0 commit comments