--- a/CMakeLists.txt Sat Jan 09 02:35:00 2016 +0200 +++ b/CMakeLists.txt Sat Jan 09 17:41:21 2016 +0200 @@ -1,6 +1,7 @@ cmake_minimum_required (VERSION 2.4) cmake_policy (SET CMP0003 NEW) -project (zfc9000) +project (ZFC9000) +string (TOLOWER ${CMAKE_PROJECT_NAME} TARGET_NAME) add_library (huffman STATIC huffman/bitreader.cpp @@ -22,31 +23,120 @@ sources/network/udpsocket.cpp ) -set (CURSES_NEED_NCURSES, True) -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -W -Wall") +set (HEADER_FILES + sources/basics.h + sources/coloredline.h + sources/geometry.h + sources/interface.h + sources/list.h + sources/main.h + sources/md5.h + sources/mystring.h + sources/network/bytestream.h + sources/network/ipaddress.h + sources/network/rconsession.h + sources/network/udpsocket.h + sources/range.h + sources/version.h +) if (NOT WIN32) - find_package (Curses) + find_package (Curses REQUIRED) endif() if (MINGW) set (CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") endif() -include_directories (${CURSES_INCUDE_DIRS}) include_directories (${CMAKE_CURRENT_BINARY_DIR}) include_directories (huffman) -add_executable (${PROJECT_NAME} ${SOURCE_FILES}) -target_link_libraries (${PROJECT_NAME} huffman) +add_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES}) +target_link_libraries (${TARGET_NAME} huffman) + +if (WIN32) + if (PDCURSES_PATH OR PDCURSES_WIN32A_PATH) + if (NOT PDCURSES_PATH) + set (PDCURSES_PATH "${PDCURSES_WIN32A_PATH}") + add_definitions (-DHAVE_PDCURSES_WIN32A) + message (STATUS "Using external PDCurses-win32a in ${PDCURSES_WIN32A_PATH}") + else() + message (STATUS "Using external PDCurses in ${PDCURSES_PATH}") + endif() + + include_directories (${PDCURSES_PATH}/include) -if (NOT WIN32) - target_link_libraries (${PROJECT_NAME} ${CURSES_LIBRARIES}) + if (MINGW) + target_link_libraries (${TARGET_NAME} ${PDCURSES_PATH}/lib/pdcurses.a) + else() + target_link_libraries (${TARGET_NAME} ${PDCURSES_PATH}/lib/pdcurses.lib) + endif() + else() + add_library (pdcurses STATIC + pdcurses/addch.c + pdcurses/addchstr.c + pdcurses/addstr.c + pdcurses/attr.c + pdcurses/beep.c + pdcurses/bkgd.c + pdcurses/border.c + pdcurses/clear.c + pdcurses/color.c + pdcurses/debug.c + pdcurses/delch.c + pdcurses/deleteln.c + pdcurses/deprec.c + pdcurses/getch.c + pdcurses/getstr.c + pdcurses/getyx.c + pdcurses/inch.c + pdcurses/inchstr.c + pdcurses/initscr.c + pdcurses/inopts.c + pdcurses/insch.c + pdcurses/insstr.c + pdcurses/instr.c + pdcurses/kernel.c + pdcurses/keyname.c + pdcurses/mouse.c + pdcurses/move.c + pdcurses/outopts.c + pdcurses/overlay.c + pdcurses/pad.c + pdcurses/panel.c + pdcurses/pdcclip.c + pdcurses/pdcdisp.c + pdcurses/pdcgetsc.c + pdcurses/pdckbd.c + pdcurses/pdcscrn.c + pdcurses/pdcsetsc.c + pdcurses/pdcutil.c + pdcurses/printw.c + pdcurses/refresh.c + pdcurses/scanw.c + pdcurses/scroll.c + pdcurses/scr_dump.c + pdcurses/slk.c + pdcurses/termattr.c + pdcurses/terminfo.c + pdcurses/touch.c + pdcurses/util.c + pdcurses/window.c + ) + target_link_libraries (${TARGET_NAME} pdcurses) + message (STATUS "Using internal pdcurses") + endif() + + add_definitions (-D_CRT_SECURE_NO_WARNINGS) + target_link_libraries (${TARGET_NAME} wsock32 ws2_32) + include_directories (pdcurses) else() - target_link_libraries (${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR}/pdcurses.a wsock32 ws2_32) + include_directories (${CURSES_INCUDE_DIRS}) # sic + target_link_libraries (${TARGET_NAME} ${CURSES_LIBRARIES}) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -std=c++0x") endif() add_custom_target (make_hginfo_h COMMAND python "${CMAKE_SOURCE_DIR}/updaterevision/updaterevision.py" "${CMAKE_CURRENT_BINARY_DIR}/hginfo.h") -add_dependencies (${PROJECT_NAME} make_hginfo_h) +add_dependencies (${TARGET_NAME} make_hginfo_h)