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

Allow using libsamplerate with CMake on Windows #5809

Closed
ericoporto opened this issue Jun 16, 2022 · 4 comments · Fixed by #5812
Closed

Allow using libsamplerate with CMake on Windows #5809

ericoporto opened this issue Jun 16, 2022 · 4 comments · Fixed by #5812

Comments

@ericoporto
Copy link
Contributor

Libsamplerate provides binary releases for Windows and even include a cmake script, it would be nice if it was possible to use it on Windows too!

@madebr
Copy link
Contributor

madebr commented Jun 16, 2022

All binary releases of the next SDL2 release will ship with a CMake script that allows the following use:

find_package(SDL2 REQUIRED)
add_executable(mygame mysource.c)
target_link_libraries(mygame PRIVATE SDL2::SDL2)

@madebr madebr closed this as completed Jun 16, 2022
@ericoporto
Copy link
Contributor Author

ericoporto commented Jun 16, 2022

libsamplerate is only checked in Linux

CheckLibSampleRate()

this should be list(APPEND ... instead of set(, othewise it's hard to pass additional module paths in the command line.

set(CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")

it would be better to use find_package directly - it looks like it is used eventually, but now you need to first pass the include directory to look for it somehow in the command line before it's added through it's own cmake config module.

check_include_file(samplerate.h HAVE_LIBSAMPLERATE_H)

It would be perfect if it had the dynamic api to look for samplerate.dll built by default in the SDL2.dll file.

I also need this to workaround #5538

@ericoporto
Copy link
Contributor Author

Hey thanks! This worked for me!

I ended up adding an additional HINTS "${SAMPLERATE_DIR}" on the find_package, just so I could pass the directory from command line, so now I can do this -DSDL_LIBSAMPLERATE=1 -DSAMPLERATE_DIR="C:\\Lib\\libsamplerate\\lib\\cmake\\SampleRate" when building,

@madebr
Copy link
Contributor

madebr commented Jun 17, 2022

I tested it by adding -DCMAKE_PREFIX_PATH=/tmp/libsamplerate-0.2.2-win64 to the cmake call.
(I extracted the binary tarball in the /tmp folder)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants