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: fix detection of SoundTouch pkgconfig file and version #4209

Merged
merged 2 commits into from
Sep 7, 2021
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ endif()

# SoundTouch
find_package(SoundTouch)
default_option(SoundTouch_STATIC "Link libSoundTouch statically" "NOT SoundTouch_FOUND")
default_option(SoundTouch_STATIC "Link libSoundTouch statically" "NOT SoundTouch_FOUND OR SoundTouch_VERSION VERSION_LESS 2.1.2")
if(SoundTouch_STATIC)
message(STATUS "Preparing internal libSoundTouch")
add_library(SoundTouch STATIC EXCLUDE_FROM_ALL
Expand Down
18 changes: 14 additions & 4 deletions cmake/modules/FindSoundTouch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The following cache variables may also be set:

find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_SoundTouch QUIET SoundTouch>=2.1.1)
pkg_check_modules(PC_SoundTouch QUIET soundtouch)
endif()

find_path(SoundTouch_INCLUDE_DIR
Expand All @@ -61,12 +61,22 @@ find_library(SoundTouch_LIBRARY
)
mark_as_advanced(SoundTouch_LIBRARY)

# Version detection
if(DEFINED PC_SoundTouch_VERSION)
set(SoundTouch_VERSION "${PC_SoundTouch_VERSION}")
else()
if(EXISTS "${SoundTouch_INCLUDE_DIR}/soundtouch/SoundTouch.h")
file(READ "${SoundTouch_INCLUDE_DIR}/soundtouch/SoundTouch.h" SoundTouch_H_CONTENTS)
string(REGEX MATCH "#define SOUNDTOUCH_VERSION[ \t]+\"([0-9]+\.[0-9]+\.[0-9]+)\"" _dummy "${SoundTouch_H_CONTENTS}")
set(SoundTouch_VERSION "${CMAKE_MATCH_1}")
endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
SoundTouch
DEFAULT_MSG
SoundTouch_LIBRARY
SoundTouch_INCLUDE_DIR
REQUIRED_VARS SoundTouch_LIBRARY SoundTouch_INCLUDE_DIR
VERSION_VAR SoundTouch_VERSION
)

if(SoundTouch_FOUND)
Expand Down