Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: patch asiolist.cpp as issue #331 explains #997

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading