fxlink: find SDL2 without -mwindows to stay in console [Windows]

When loading SDL2 with pkg-config the -mwindows flag is added, which
instructs the loader to load the program through WinMain() and not
create a console for it. This is intended for GUI programs. However,
fxlink is a CLI program with just occasionally an SDL window on top of
it. Disable -mwindows to keep the console and terminal output. I don't
know how to do that with the pkg-config CMake module, so use the SDL2
module for the Windows build instead.
This commit is contained in:
Lephenixnoir 2024-08-26 12:00:24 +02:00
parent b83796a382
commit c3d7fd6efa
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
2 changed files with 15 additions and 2 deletions

View file

@ -13,7 +13,14 @@ if(NOT FXLINK_DISABLE_UDISKS2)
pkg_check_modules(udisks2 REQUIRED udisks2 IMPORTED_TARGET)
endif()
if(NOT FXLINK_DISABLE_SDL2)
pkg_check_modules(sdl2 REQUIRED sdl2 IMPORTED_TARGET)
if(WIN32)
set(SDL2_NO_MWINDOWS 1)
find_package(SDL2 REQUIRED)
else()
pkg_check_modules(sdl2 REQUIRED sdl2 IMPORTED_TARGET)
set(SDL2_LIBRARIES PkgConfig::sdl2)
set(SDL2_INCLUDE_DIRS)
endif()
endif()
pkg_check_modules(ncurses REQUIRED ncursesw IMPORTED_TARGET)
@ -87,7 +94,8 @@ if(NOT FXLINK_DISABLE_UDISKS2)
target_link_libraries(fxlink PkgConfig::udisks2)
endif()
if(NOT FXLINK_DISABLE_SDL2)
target_link_libraries(fxlink PkgConfig::sdl2)
target_link_libraries(fxlink ${SDL2_LIBRARIES})
target_include_directories(fxlink PRIVATE ${SDL2_INCLUDE_DIRS})
endif()
# fxsdk-gdb-bridge

View file

@ -16,6 +16,11 @@
#include <errno.h>
#include <locale.h>
#ifndef FXLINK_DISABLE_SDL2
/* Grab main()-related macros */
#include <SDL2/SDL.h>
#endif
static const char *help_string =
"usage: %1$s (-l|-b|-t) [General options]\n"
" %1$s -i [-r] [--fxlink-log[=<FILE>]] [General options]\n"