CMake can't find PDCurses on MinGW

753 views Asked by At

I'm trying to build a curses program that uses CMake on Windows with MinGW and PDCurses. I'm using CMake 3.7.1, and all my MinGW packages are up-to-date. Specifically, i have mingw32-libpdcurses 3.4-1 (both dev and dll) and mingw32-pdcurses 3.4-1 (bin, doc and lic) installed.

My full CMakeLists.txt is below, but using find_package(Curses REQUIRED) gives an error: Could NOT find Curses (missing: CURSES_LIBRARY). This other question deals with a similar situation; the answer's author says he hasn't tested PDCurses on MinGW, but that it should work.

(I had the same results using CMake 3.6.3, which is bundled with CLion).

My CMakeLists.txt:

cmake_minimum_required(VERSION 3.3)
project(PROJECT_NAME)

if(WIN32)
    set(PATH "C:\\MinGW")
endif()

find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR})

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g -Wall")

set(SOURCE_FILES src/init.c etc...)

add_executable(project_name ${SOURCE_FILES})
target_link_libraries(project_name ${CURSES_LIBRARIES} m)

Am I doing something wrong? Are there any workarounds?

Thanks a lot!

1

There are 1 answers

0
Enno On

I'm pretty sure find_package(Curses REQUIRED) will not work, since the pdcurses library has a different name (pdcurses.lib). I have a project using curses that tried to first explicitly find PDCurses, and if that fails, falls back to the default cmake curses package.

You may steal my FindPDCurses.cmake from here: https://github.com/eressea/server/blob/develop/cmake/Modules/FindPDCurses.cmake

Place it in a directory among your sources, be sure to include that directory in CMAKE_MODULE_PATH, and use like so:

  find_package (PDCurses)
  if (PDCURSES_FOUND)
    set (CURSES_FOUND ${PDCURSES_FOUND})
    set (CURSES_LIBRARIES ${PDCURSES_LIBRARY})
    set (CURSES_INCLUDE_DIRS ${PDCURSES_INCLUDE_DIR})
  else (PDCURSES_FOUND)
    find_package (Curses REQUIRED)
  endif (PDCURSES_FOUND)