Skip to content

Commit

Permalink
cmake: patch asiolist.cpp into patched_asiolist.cpp as issue #331 exp…
Browse files Browse the repository at this point in the history
…lains, see also #1004 (#997)
  • Loading branch information
sonoro1234 authored Feb 6, 2025
1 parent 2b80aa7 commit e4fdd66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmake/modules/FindASIO.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/hostapi/asio/ASIO-README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e4fdd66

Please sign in to comment.