set(ncurses_srcs
        tty/hardscroll.c
        tty/hashmap.c
        tty/lib_mvcur.c
        tty/lib_tstp.c
        tty/lib_twait.c
        tty/lib_vidattr.c
        tty/tty_update.c
        base/define_key.c
        base/key_defined.c
        base/keybound.c
        base/keyok.c
        base/legacy_coding.c
        base/lib_addch.c
        base/lib_addstr.c
        base/lib_beep.c
        base/lib_bkgd.c
        base/lib_box.c
        base/lib_chgat.c
        base/lib_clear.c
        base/lib_clearok.c
        base/lib_clrbot.c
        base/lib_clreol.c
        base/lib_color.c
        base/lib_colorset.c
        base/lib_delch.c
        base/lib_delwin.c
        base/lib_dft_fgbg.c
        base/lib_echo.c
        base/lib_endwin.c
        base/lib_erase.c
        base/lib_flash.c
        base/lib_freeall.c
        base/lib_getch.c
        base/lib_getstr.c
        base/lib_hline.c
        base/lib_immedok.c
        base/lib_inchstr.c
        base/lib_initscr.c
        base/lib_insch.c
        base/lib_insdel.c
        base/lib_insnstr.c
        base/lib_instr.c
        base/lib_isendwin.c
        base/lib_leaveok.c
        base/lib_mouse.c
        base/lib_move.c
        base/lib_mvwin.c
        base/lib_newterm.c
        base/lib_newwin.c
        base/lib_nl.c
        base/lib_overlay.c
        base/lib_pad.c
        base/lib_printw.c
        base/lib_redrawln.c
        base/lib_refresh.c
        base/lib_restart.c
        base/lib_scanw.c
        base/lib_screen.c
        base/lib_scroll.c
        base/lib_scrollok.c
        base/lib_scrreg.c
        base/lib_set_term.c
        base/lib_slk.c
        base/lib_slkatr_set.c
        base/lib_slkatrof.c
        base/lib_slkatron.c
        base/lib_slkatrset.c
        base/lib_slkattr.c
        base/lib_slkclear.c
        base/lib_slkcolor.c
        base/lib_slkinit.c
        base/lib_slklab.c
        base/lib_slkrefr.c
        base/lib_slkset.c
        base/lib_slktouch.c
        base/lib_touch.c
        base/lib_ungetch.c
        base/lib_vline.c
        base/lib_wattroff.c
        base/lib_wattron.c
        base/lib_winch.c
        base/lib_window.c
        base/nc_panel.c
        base/resizeterm.c
        base/safe_sprintf.c
        base/tries.c
        base/use_window.c
        base/version.c
        base/vsscanf.c
        base/wresize.c
        tinfo/access.c
        tinfo/add_tries.c
        tinfo/alloc_entry.c
        tinfo/alloc_ttype.c
        tinfo/captoinfo.c
        tinfo/comp_error.c
        tinfo/comp_expand.c
        tinfo/comp_hash.c
        tinfo/comp_parse.c
        tinfo/comp_scan.c
        tinfo/db_iterator.c
        tinfo/doalloc.c
        tinfo/entries.c
        tinfo/free_ttype.c
        tinfo/getenv_num.c
        tinfo/hashed_db.c
        tinfo/home_terminfo.c
        tinfo/init_keytry.c
        tinfo/lib_acs.c
        tinfo/lib_baudrate.c
        tinfo/lib_cur_term.c
        tinfo/lib_data.c
        tinfo/lib_has_cap.c
        tinfo/lib_kernel.c
        tinfo/lib_longname.c
        tinfo/lib_napms.c
        tinfo/lib_options.c
        tinfo/lib_print.c
        tinfo/lib_raw.c
        tinfo/lib_setup.c
        tinfo/lib_termcap.c
        tinfo/lib_termname.c
        tinfo/lib_tgoto.c
        tinfo/lib_ti.c
        tinfo/lib_tparm.c
        tinfo/lib_tputs.c
        tinfo/lib_ttyflags.c
        tinfo/name_match.c
        tinfo/obsolete.c
        tinfo/parse_entry.c
        tinfo/read_entry.c
        tinfo/read_termcap.c
        tinfo/strings.c
        tinfo/trim_sgr0.c
        tinfo/use_screen.c
        tinfo/write_entry.c
        trace/lib_trace.c
        trace/varargs.c
        trace/visbuf.c
        codes.c
        comp_captab.c
        expanded.c
        fallback.c
        lib_gen.c
        lib_keyname.c
        names.c
        unctrl.c
        )

PREPEND(ncurses_src_with_path "ncurses/ncurses" ${ncurses_srcs})
add_library(ncurses ${ncurses_src_with_path})
target_compile_options(ncurses PRIVATE -std=gnu89)
target_compile_definitions(ncurses PRIVATE
        -DHAVE_CONFIG_H -D_XOPEN_SOURCE -D_POSIX_C_SOURCE -DNDEBUG)
target_include_directories(ncurses PRIVATE
        "${CMAKE_CURRENT_SOURCE_DIR}/include/ncurses"
        "${CMAKE_CURRENT_SOURCE_DIR}/ncurses/include"
        "${CMAKE_CURRENT_SOURCE_DIR}/ncurses/ncurses"
        )
