|
| 1 | +cmake_minimum_required(VERSION 3.11) |
| 2 | + |
| 3 | +if(NOT CMAKE_BUILD_TYPE) |
| 4 | + set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "Choose the type of build, options are: Debug, Release, or MinSizeRel." FORCE) |
| 5 | + message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to MinSizeRel.") |
| 6 | +endif() |
| 7 | +set (CMAKE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") |
| 8 | +set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake") |
| 9 | +set (PDCURSES_SRCDIR "${CMAKE_SOURCE_DIR}") |
| 10 | + |
| 11 | +include (get_version) |
| 12 | +project(pdcurses VERSION "${CURSES_VERSION}" LANGUAGES C) |
| 13 | + |
| 14 | +message(STATUS "Generator .............. ${CMAKE_GENERATOR}") |
| 15 | +message(STATUS "Build Type ............. ${CMAKE_BUILD_TYPE}") |
| 16 | + |
| 17 | +include(build_options) |
| 18 | +option(PDC_NO_LEAKS "No Leaks" OFF) |
| 19 | +option(PDC_CHTYPE_16 "CHTYPE_16" OFF) |
| 20 | + |
| 21 | +set (PDCURSES_SOURCES ${PDCURSES_SRCDIR}/pdcurses/addch.c |
| 22 | + ${PDCURSES_SRCDIR}/pdcurses/addchstr.c |
| 23 | + ${PDCURSES_SRCDIR}/pdcurses/addstr.c |
| 24 | + ${PDCURSES_SRCDIR}/pdcurses/attr.c |
| 25 | + ${PDCURSES_SRCDIR}/pdcurses/beep.c |
| 26 | + ${PDCURSES_SRCDIR}/pdcurses/bkgd.c |
| 27 | + ${PDCURSES_SRCDIR}/pdcurses/border.c |
| 28 | + ${PDCURSES_SRCDIR}/pdcurses/clear.c |
| 29 | + ${PDCURSES_SRCDIR}/pdcurses/color.c |
| 30 | + ${PDCURSES_SRCDIR}/pdcurses/debug.c |
| 31 | + ${PDCURSES_SRCDIR}/pdcurses/delch.c |
| 32 | + ${PDCURSES_SRCDIR}/pdcurses/deleteln.c |
| 33 | + ${PDCURSES_SRCDIR}/pdcurses/getch.c |
| 34 | + ${PDCURSES_SRCDIR}/pdcurses/getstr.c |
| 35 | + ${PDCURSES_SRCDIR}/pdcurses/getyx.c |
| 36 | + ${PDCURSES_SRCDIR}/pdcurses/inch.c |
| 37 | + ${PDCURSES_SRCDIR}/pdcurses/inchstr.c |
| 38 | + ${PDCURSES_SRCDIR}/pdcurses/initscr.c |
| 39 | + ${PDCURSES_SRCDIR}/pdcurses/inopts.c |
| 40 | + ${PDCURSES_SRCDIR}/pdcurses/insch.c |
| 41 | + ${PDCURSES_SRCDIR}/pdcurses/insstr.c |
| 42 | + ${PDCURSES_SRCDIR}/pdcurses/instr.c |
| 43 | + ${PDCURSES_SRCDIR}/pdcurses/kernel.c |
| 44 | + ${PDCURSES_SRCDIR}/pdcurses/keyname.c |
| 45 | + ${PDCURSES_SRCDIR}/pdcurses/mouse.c |
| 46 | + ${PDCURSES_SRCDIR}/pdcurses/move.c |
| 47 | + ${PDCURSES_SRCDIR}/pdcurses/outopts.c |
| 48 | + ${PDCURSES_SRCDIR}/pdcurses/overlay.c |
| 49 | + ${PDCURSES_SRCDIR}/pdcurses/pad.c |
| 50 | + ${PDCURSES_SRCDIR}/pdcurses/panel.c |
| 51 | + ${PDCURSES_SRCDIR}/pdcurses/printw.c |
| 52 | + ${PDCURSES_SRCDIR}/pdcurses/refresh.c |
| 53 | + ${PDCURSES_SRCDIR}/pdcurses/scanw.c |
| 54 | + ${PDCURSES_SRCDIR}/pdcurses/scr_dump.c |
| 55 | + ${PDCURSES_SRCDIR}/pdcurses/scroll.c |
| 56 | + ${PDCURSES_SRCDIR}/pdcurses/slk.c |
| 57 | + ${PDCURSES_SRCDIR}/pdcurses/termattr.c |
| 58 | + ${PDCURSES_SRCDIR}/pdcurses/terminfo.c |
| 59 | + ${PDCURSES_SRCDIR}/pdcurses/touch.c |
| 60 | + ${PDCURSES_SRCDIR}/pdcurses/util.c |
| 61 | + ${PDCURSES_SRCDIR}/pdcurses/window.c |
| 62 | + ${PDCURSES_SRCDIR}/x11new/pdcclip.c |
| 63 | + ${PDCURSES_SRCDIR}/x11new/pdcdisp.c |
| 64 | + ${PDCURSES_SRCDIR}/x11new/pdcgetsc.c |
| 65 | + ${PDCURSES_SRCDIR}/x11new/pdckbd.c |
| 66 | + ${PDCURSES_SRCDIR}/x11new/pdcscrn.c |
| 67 | + ${PDCURSES_SRCDIR}/x11new/pdcsetsc.c |
| 68 | + ${PDCURSES_SRCDIR}/x11new/pdcutil.c |
| 69 | + ${PDCURSES_SRCDIR}/x11new/pdcutil.c) |
| 70 | + |
| 71 | +if (PDC_BUILD_SHARED) |
| 72 | + add_library(pdcurses SHARED ${PDCURSES_SOURCES}) |
| 73 | +else () |
| 74 | + add_library(pdcurses STATIC ${PDCURSES_SOURCES}) |
| 75 | +endif () |
| 76 | + |
| 77 | +target_include_directories(pdcurses PRIVATE "${PDCURSES_SRCDIR}" |
| 78 | + "${CMAKE_CURRENT_BINARY_DIR}") |
| 79 | + |
| 80 | +target_compile_options (pdcurses PRIVATE -Wall -Wextra -pedantic -Werror -fPIC) |
| 81 | +if (CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 82 | + target_compile_options (pdcurses PRIVATE -g3) |
| 83 | + target_compile_definitions(pdcurses PUBLIC -DPDCDEBUG) |
| 84 | +else () |
| 85 | + target_compile_options (pdcurses PRIVATE -O3) |
| 86 | +endif () |
| 87 | + |
| 88 | +if (PDC_NO_LEAKS) |
| 89 | + target_compile_definitions(pdcurses PUBLIC -DNO_LEAKS) |
| 90 | +endif () |
| 91 | + |
| 92 | + |
| 93 | +if (PDC_UTF8) |
| 94 | + target_compile_definitions(pdcurses PUBLIC -DPDC_FORCE_UTF8) |
| 95 | +endif () |
| 96 | + |
| 97 | +if (PDC_WIDE) |
| 98 | + target_compile_definitions(pdcurses PUBLIC -DPDC_WIDE) |
| 99 | +endif () |
| 100 | + |
| 101 | +if (PDC_CHTYPE_32) |
| 102 | + target_compile_definitions(pdcurses PUBLIC -DCHTYPE_32) |
| 103 | +endif () |
| 104 | + |
| 105 | +if (PDC_CHTYPE_16) |
| 106 | + target_compile_definitions(pdcurses PUBLIC -DCHTYPE_16) |
| 107 | +endif () |
| 108 | + |
| 109 | +target_link_libraries (pdcurses -lX11 -lpthread) |
| 110 | + |
| 111 | +install (TARGETS pdcurses |
| 112 | + EXPORT pdcurses_Targets |
| 113 | + ARCHIVE DESTINATION lib |
| 114 | + LIBRARY DESTINATION lib |
| 115 | + RUNTIME DESTINATION bin) |
| 116 | +install (FILES "${PDCURSES_SRCDIR}/curses.h" |
| 117 | + "${PDCURSES_SRCDIR}/curspriv.h" |
| 118 | + DESTINATION include) |
| 119 | + |
| 120 | +macro (x11_app dir targ) |
| 121 | + set(bin_name "${PROJECT_NAME}_${targ}") |
| 122 | + |
| 123 | + if(${targ} STREQUAL "tuidemo") |
| 124 | + set(src_files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/tuidemo.c ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/tui.c) |
| 125 | + else() |
| 126 | + set(src_files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${targ}.c) |
| 127 | + endif() |
| 128 | + |
| 129 | + if(${ARGV2}) |
| 130 | + add_executable(${bin_name} WIN32 ${src_files}) |
| 131 | + else() |
| 132 | + add_executable(${bin_name} ${src_files}) |
| 133 | + endif() |
| 134 | + target_include_directories(${bin_name} PRIVATE "${PDCURSES_SRCDIR}" |
| 135 | + "${CMAKE_CURRENT_BINARY_DIR}") |
| 136 | + |
| 137 | + target_link_libraries(${bin_name} pdcurses -lX11 -lpthread) |
| 138 | + |
| 139 | + add_dependencies(${bin_name} pdcurses) |
| 140 | + set_target_properties(${bin_name} PROPERTIES OUTPUT_NAME ${targ}) |
| 141 | +endmacro () |
| 142 | + |
| 143 | +# demos |
| 144 | +x11_app(../demos calendar) |
| 145 | +x11_app(../demos firework) |
| 146 | +x11_app(../demos init_col) |
| 147 | +x11_app(../demos mbrot) |
| 148 | +x11_app(../demos newtest) |
| 149 | +x11_app(../demos ozdemo) |
| 150 | +x11_app(../demos picsview) |
| 151 | +x11_app(../demos ptest) |
| 152 | +x11_app(../demos rain) |
| 153 | +x11_app(../demos speed) |
| 154 | +x11_app(../demos test_pan) |
| 155 | +x11_app(../demos testcurs) |
| 156 | +x11_app(../demos widetest) |
| 157 | +x11_app(../demos worm) |
| 158 | +x11_app(../demos xmas) |
| 159 | +x11_app(../demos tuidemo) |
| 160 | + |
| 161 | +# tests |
| 162 | +x11_app(../tests brk_test) |
| 163 | +x11_app(../tests del_test) |
| 164 | +x11_app(../tests focus) |
| 165 | +x11_app(../tests ins_del) |
| 166 | +x11_app(../tests keytest) |
| 167 | +x11_app(../tests opaque) |
| 168 | +x11_app(../tests restart) |
| 169 | +x11_app(../tests ripoff) |
| 170 | +x11_app(../tests show_col) |
| 171 | +x11_app(../tests show_uni) |
0 commit comments