project(ncurses C CXX ASM) cmake_minimum_required(VERSION 3.0) set(UPSTREAM_VERSION 6.4.0) set(SO_VERSION 6) add_definitions( # -DUSE_TERMLIB=true -D_GNU_SOURCE -D_XOPEN_SOURCE -D_POSIX ) set(CFLAGS ${CFLAGS} "-Warning=implicit-function-declaration" ) list(APPEND DEFS "#define NCURSES_EXT_COLORS 1" "#define USE_HASHMAP 1" "#define USE_SCROLL_HINTS 0" "#define USE_WIDEC_SUPPORT 1" "#define CCHARW_MAX 6" "#define SIG_ATOMIC_T sig_atomic_t" "#define HAVE_UNISTD_H 1" "#define HAVE_WCTYPE_H 1" "#define NCURSES_WIDECHAR 1" "#define HAVE_SIGACTION 1" "#define HAVE_PUTWC 1" "#define HAVE_BTOWC 1" "#define HAVE_WCTOB 1" "#define HAVE_WMEMCHR 1" "#define HAVE_MBTOWC 1" "#define HAVE_WCTOMB 1" "#define HAVE_MBLEN 1" "#define HAVE_MBRLEN 1" "#define HAVE_MBRTOWC 1" "#define HAVE_WCSRTOMBS 1" "#define HAVE_MBSRTOWCS 1" "#define HAVE_WCSTOMBS 1" "#define HAVE_MBSTOWCS 1" "#define USE_TERM_DRIVER 1" ) string (REPLACE ";" "\n" DEFS "${DEFS}") configure_file(${CMAKE_SOURCE_DIR}/include/ncurses_cfg.hin ${CMAKE_BINARY_DIR}/ncurses_cfg.h @ONLY) include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/include ) file(GLOB baseSrcs "${CMAKE_SOURCE_DIR}/*.c" "${CMAKE_SOURCE_DIR}/*.list" "${CMAKE_SOURCE_DIR}/ncurses/base/lib_*.c" ) add_library(ncurses SHARED ${baseSrcs} ) add_custom_target(makedef COMMAND ../include/MKncurses_def.sh ../include/ncurses_defs > "${CMAKE_CURRENT_BINARY_DIR}/ncurses_def.h" ) add_dependencies(ncurses makedef) target_include_directories(ncurses PRIVATE "${CMAKE_SOURCE_DIR}/ncurses" ) set_property(TARGET ncurses PROPERTY VERSION ${UPSTREAM_VERSION}) set_property(TARGET ncurses PROPERTY SOVERSION ${SO_VERSION}) file(GLOB tinfoSrsc "${CMAKE_SOURCE_DIR}/*.c" "${CMAKE_SOURCE_DIR}/*.list" "${CMAKE_SOURCE_DIR}/ncurses/tinfo/lib_*.c" ) add_library(tinfo SHARED ${tinfoSrsc} ) target_link_libraries(tinfo ncurses ) target_include_directories(tinfo PRIVATE "${CMAKE_SOURCE_DIR}/ncurses" ) set_property(TARGET tinfo PROPERTY VERSION ${UPSTREAM_VERSION}) set_property(TARGET tinfo PROPERTY SOVERSION ${SO_VERSION}) file(GLOB traceSrsc "${CMAKE_SOURCE_DIR}/*.c" "${CMAKE_SOURCE_DIR}/*.list" "${CMAKE_SOURCE_DIR}/ncurses/trace/lib_*.c" ) add_library(trace SHARED ${traceSrsc} ) target_link_libraries(trace ncurses ) target_include_directories(trace PRIVATE "${CMAKE_SOURCE_DIR}/ncurses" ) set_property(TARGET trace PROPERTY VERSION ${UPSTREAM_VERSION}) set_property(TARGET trace PROPERTY SOVERSION ${SO_VERSION}) file(GLOB ttySrsc "${CMAKE_SOURCE_DIR}/*.c" "${CMAKE_SOURCE_DIR}/*.list" "${CMAKE_SOURCE_DIR}/ncurses/tty/lib_*.c" ) add_library(tty SHARED ${traceSrsc} ) target_link_libraries(tty ncurses ) target_include_directories(tty PRIVATE "${CMAKE_SOURCE_DIR}/ncurses" ) set_property(TARGET tty PROPERTY VERSION ${UPSTREAM_VERSION}) set_property(TARGET tty PROPERTY SOVERSION ${SO_VERSION}) file(GLOB wideSrsc "${CMAKE_SOURCE_DIR}/*.c" "${CMAKE_SOURCE_DIR}/*.list" "${CMAKE_SOURCE_DIR}/ncurses/widechar/lib_*.c" ) add_library(wide SHARED ${wideSrsc} ) target_link_libraries(wide ncurses ) target_include_directories(wide PRIVATE "${CMAKE_SOURCE_DIR}/ncurses" ) set_property(TARGET wide PROPERTY VERSION ${UPSTREAM_VERSION}) set_property(TARGET wide PROPERTY SOVERSION ${SO_VERSION}) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ncurses.pc" prefix=${CMAKE_INSTALL_PREFIX} exec_prefix=${CMAKE_INSTALL_PREFIX}/bin libdir=${CMAKE_INSTALL_PREFIX}/lib includedir=${CMAKE_INSTALL_PREFIX}/include abi_version=${SO_VERSION} major_version=${SO_VERSION} version=${UPSTREAM_VERSION} Name: ${name}${suffix} Description: $desc Version: \${UPSTREAM_VERSION} URL: https://invisible-island.net/ncurses Requires.private: $reqs Cflags: ${CFLAGS} ) install( TARGETS ncurses tinfo trace tty wide DESTINATION lib ) install(DIRECTORY include/ DESTINATION include ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ncurses_cfg.h" "${CMAKE_CURRENT_BINARY_DIR}/ncurses_def.h" DESTINATION include ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ncurses.pc DESTINATION lib/pkgconfig )