ncurses-meson-dep

Meson ncurses detection 100% real no fake
git clone git://git.sgregoratto.me/ncurses-meson-dep
Log | Files | Refs | README

meson.build (1538B)


      1 # Ultimate ncurses detection 100% real no fake
      2 nc_libs = [
      3 	'ncursesw',
      4 	'ncurses',
      5 	'curses'
      6 ]
      7 nc_headers = [
      8 	'ncursesw/ncurses.h',
      9 	'ncursesw.h',
     10 	'ncurses/ncurses.h',
     11 	'ncurses/curses.h',
     12 	'ncurses.h',
     13 	'curses.h',
     14 ]
     15 nc_progs = [
     16 	'ncursesw6',
     17 	'ncursesw5',
     18 	'ncurses6',
     19 	'ncurses5',
     20 ]
     21 wide_incantations = [
     22 	'-D_XOPEN_SOURCE_EXTENDED',
     23 	'-DNCURSES_WIDECHAR',
     24 ]
     25 
     26 found = false
     27 foreach h : nc_headers
     28 	if cc.has_header(h)
     29 		found = true
     30 		conf.set('CURSES_HEADER', h)
     31 		break
     32 	endif
     33 endforeach
     34 if not found
     35 	error('ncurses header not found')
     36 endif
     37 
     38 foreach l : nc_libs
     39 	curses = dependency(l, required: false)
     40 	if curses.found()
     41 		subdir_done()
     42 	endif
     43 endforeach
     44 foreach p : nc_progs
     45 	# Method is whitelisted for specific libraries, darn.
     46 	#curses = dependency(p, method: 'config', required: false)
     47 	#if curses.found()
     48 	#	subdir_done()
     49 	#endif
     50 	name = p + '-config'
     51 	prog = find_program([name,
     52 		'/bin' / name,
     53 		'/usr' / 'bin' / name,
     54 		'/usr' / 'local' / 'bin' / name],
     55 		required: false
     56 	)
     57 	if not prog.found()
     58 		continue
     59 	endif
     60 	libs	= run_command(prog, '--libs-only-l').stdout().strip()
     61 	cflags	= run_command(prog, '--cflags').stdout().strip()
     62 	version = run_command(prog, '--version').stdout().strip()
     63 
     64 	cflags = ' '.join([cflags] + wide_incantations)
     65 	curses	= declare_dependency(
     66 		compile_args: cflags,
     67 		link_args: libs,
     68 		version: version,
     69 	)
     70 	subdir_done()
     71 endforeach
     72 foreach l : nc_libs
     73 	curses = cc.find_library(l, required: false)
     74 	if curses.found()
     75 		subdir_done()
     76 	endif
     77 endforeach
     78 
     79 error('ncurses library not found')