diff --git a/cmake/modules/FindASIO.cmake b/cmake/modules/FindASIO.cmake index d67cf42b9..6c43429ed 100644 --- a/cmake/modules/FindASIO.cmake +++ b/cmake/modules/FindASIO.cmake @@ -61,11 +61,18 @@ if(ASIO_ROOT) message(STATUS "Found ASIO SDK: ${ASIO_ROOT}") if(ASIO_FOUND AND NOT TARGET ASIO::host) + #patch asiolist.cpp + if(NOT EXISTS "${ASIO_ROOT}/host/pc/patched_asiolist.cpp") + file(READ "${ASIO_ROOT}/host/pc/asiolist.cpp" FILE_CONTENTS) + string(REPLACE "delete lpdrv" "delete[] lpdrv" FILE_CONTENTS "${FILE_CONTENTS}") + file(WRITE "${ASIO_ROOT}/host/pc/patched_asiolist.cpp" "${FILE_CONTENTS}") + message(STATUS "Done patching asiolist.cpp into patched_asiolist.cpp") + endif() add_library(ASIO::host INTERFACE IMPORTED) target_sources(ASIO::host INTERFACE "${ASIO_ROOT}/common/asio.cpp" "${ASIO_ROOT}/host/asiodrivers.cpp" - "${ASIO_ROOT}/host/pc/asiolist.cpp" + "${ASIO_ROOT}/host/pc/patched_asiolist.cpp" ) target_include_directories(ASIO::host INTERFACE "${ASIO_ROOT}/common" diff --git a/src/hostapi/asio/ASIO-README.txt b/src/hostapi/asio/ASIO-README.txt index 9c4f817a0..8653fa21b 100644 --- a/src/hostapi/asio/ASIO-README.txt +++ b/src/hostapi/asio/ASIO-README.txt @@ -87,6 +87,8 @@ To fix this issue replace the line: with: delete [] lpdrv; +In the cmake build of portaudio this is already done for you. + Explanation: lpdrv is allocated as an array on the line: lpdrv = new ASIODRVSTRUCT[1]; Hence it must also be deleted as an array as per standard C++ rules.