From 803c19b4c2c1d62d0e2e80a505f98d40aa6472c8 Mon Sep 17 00:00:00 2001 From: Jose Phillips Date: Sun, 8 Dec 2024 18:10:05 -0500 Subject: [PATCH] check if libserial exists for unsupported libserial OS --- src/include/86box/snd_opl.h | 4 +++- src/include/86box/sound.h | 2 ++ src/sound/CMakeLists.txt | 36 +++++++++++++++++++++--------------- src/sound/snd_opl.c | 3 ++- src/sound/sound.c | 2 ++ 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/include/86box/snd_opl.h b/src/include/86box/snd_opl.h index 95eec2687..8a6a7d6ef 100644 --- a/src/include/86box/snd_opl.h +++ b/src/include/86box/snd_opl.h @@ -60,8 +60,10 @@ extern const device_t ymf289b_ymfm_device; extern const device_t ymf278b_ymfm_device; extern const device_t esfm_esfmu_device; - +#ifdef USE_LIBSERIALPORT extern const device_t ym_opl2board_device; #endif +#endif + #endif /*SOUND_OPL_H*/ diff --git a/src/include/86box/sound.h b/src/include/86box/sound.h index 428f12932..bcf7f2ae5 100644 --- a/src/include/86box/sound.h +++ b/src/include/86box/sound.h @@ -209,8 +209,10 @@ extern const device_t tndy_device; extern const device_t wss_device; extern const device_t ncr_business_audio_device; +#ifdef USE_LIBSERIALPORT /* External Audio device OPL2Board (Host Connected hardware)*/ extern const device_t opl2board_device; +#endif #endif diff --git a/src/sound/CMakeLists.txt b/src/sound/CMakeLists.txt index 315da61e4..a381051ba 100644 --- a/src/sound/CMakeLists.txt +++ b/src/sound/CMakeLists.txt @@ -31,8 +31,6 @@ add_library(snd OBJECT snd_ps1.c snd_adlib.c snd_adlibgold.c - snd_opl2board.c - snd_opl_opl2board.cpp snd_ad1848.c snd_audiopci.c snd_azt2316a.c @@ -172,20 +170,28 @@ if(OPL4ML) target_compile_definitions(snd PRIVATE USE_OPL4ML) target_sources(snd PRIVATE midi_opl4.c midi_opl4_yrw801.c) endif() - -find_package(PkgConfig REQUIRED) -pkg_check_modules(SERIALPORT REQUIRED libserialport) -if(APPLE) - include_directories(${LIBSERIALPORT_ROOT}/include) - target_link_libraries(86Box ${LIBSERIALPORT_ROOT}/lib/libserialport.dylib) -elseif(WIN32) - include_directories(${SERIALPORT_INCLUDE_DIRS}) - target_link_libraries(86Box ${SERIALPORT_LIBRARIES} SetupAPI) -else() - include_directories(${SERIALPORT_INCLUDE_DIRS}) - target_link_libraries(86Box ${SERIALPORT_LIBRARIES}) -endif() + +find_package(PkgConfig ) +pkg_check_modules(SERIALPORT libserialport) +if(SERIALPORT_FOUND OR DEFINED LIBSERIALPORT_ROOT) + add_compile_definitions(USE_LIBSERIALPORT=1) + + if(APPLE) + include_directories(${LIBSERIALPORT_ROOT}/include) + target_link_libraries(86Box ${LIBSERIALPORT_ROOT}/lib/libserialport.dylib) + elseif(WIN32) + include_directories(${SERIALPORT_INCLUDE_DIRS}) + target_link_libraries(86Box ${SERIALPORT_LIBRARIES} SetupAPI) + else() + include_directories(${SERIALPORT_INCLUDE_DIRS}) + target_link_libraries(86Box ${SERIALPORT_LIBRARIES}) + endif() + target_sources(snd PRIVATE + snd_opl2board.c + snd_opl_opl2board.cpp +) +endif() add_subdirectory(resid-fp) target_link_libraries(86Box resid-fp) diff --git a/src/sound/snd_opl.c b/src/sound/snd_opl.c index 931277332..cddc18119 100644 --- a/src/sound/snd_opl.c +++ b/src/sound/snd_opl.c @@ -58,11 +58,12 @@ fm_driver_get(int chip_id, fm_drv_t *drv) drv->priv = device_add_inst(&ymf262_ymfm_device, fm_dev_inst[fm_driver][chip_id]++); } break; - +#ifdef USE_LIBSERIALPORT case FM_OPL2BOARD: *drv = ymfm_opl2board_drv; drv->priv = device_add_inst(&ym_opl2board_device, fm_dev_inst[fm_driver][chip_id]++); break; +#endif case FM_YMF289B: *drv = ymfm_drv; drv->priv = device_add_inst(&ymf289b_ymfm_device, fm_dev_inst[fm_driver][chip_id]++); diff --git a/src/sound/sound.c b/src/sound/sound.c index 851c849e4..7e6a1ac1c 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -153,7 +153,9 @@ static const SOUND_CARD sound_cards[] = { { &ct5880_device }, { &ad1881_device }, { &cs4297a_device }, +#ifdef USE_LIBSERIALPORT /*The following devices required LIBSERIALPORT*/ { &opl2board_device }, +#endif { NULL } // clang-format on };