I'm trying to build a little cross-platform application using curses. To use curses cross-platform, I'm using the instructions from this answer. It's almost working, except that on Windows (when running
cmake -G "MinGW Makefiles" .. && cmake --build .
from my build folder), I get a bunch of errors about PCONSOLE_SCREEN_BUFFER_INFOEX
not being defined. To fix this error, pdcurses says to set INFOEX=N
in the mingw32-make
call. I can compile it fine using mingw32-make -f Makefile INFOEX=N
, but I can't figure out how to pass INFOEX=N
from CMakeLists.txt
.
Asked
Active
Viewed 572 times
0

ThatCoolCoder
- 249
- 3
- 16
-
https://stackoverflow.com/questions/40693190/passing-arguments-in-cmakes-build-tool-mode ? You do `cmake --build . -- INFOEX=N` I think you could also use https://cmake.org/cmake/help/latest/variable/CMAKE_MAKE_PROGRAM.html – KamilCuk May 23 '21 at 06:16
1 Answers
0
A quick search through the repository indicates that the value is only used to add the HAVE_NO_INFOEX
compiler definition. To allow the user to pass a configuration when configuring your project, you should add a cache variable which allows to pass the value when configuring the project (cmake -D VARIABLE_NAME=VALUE -G "MinGW Makefiles" ..
).
Adjusting the CMakeLists.txt
file presented in the linked answer it could be done like this:
...
if (WIN32)
# variable set to False unless provided by user
set(PDCURSES_INFOEX_MISSING False CACHE BOOL "Does pdcurses need to define CONSOLE_SCREEN_BUFFER_INFOEX?")
endif()
add_library(PDcurses
# all of the sources
...
)
if (WIN32 AND PDCURSES_INFOEX_MISSING)
target_compile_definitions(PDcurses PRIVATE HAVE_NO_INFOEX)
endif()
...
cmake -D PDCURSES_INFOEX_MISSING=True -G "MinGW Makefiles" ..
Note: If you want to avoid requiring the user to make this choice and possibly getting it wrong you could also use try_compile
to check, source including windows.h
and using CONSOLE_SCREEN_BUFFER_INFOEX
would compile or not for windows target system...

fabian
- 80,457
- 12
- 86
- 114
-
Thanks for the answer, but I've managed to solve my problem a different way. While this probably does work, I realised that I was asking a bit of an XY Problem and instead just installed a slightly older version of pdcurses into MinGW in the 'Conventional' way. – ThatCoolCoder May 23 '21 at 07:41