-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore discovery of libsndfile on Ubuntu (#1454)
- Loading branch information
Showing
8 changed files
with
680 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#[=======================================================================[.rst: | ||
FindFLAC | ||
------- | ||
Finds the FLAC library. | ||
Imported Targets | ||
^^^^^^^^^^^^^^^^ | ||
This module provides the following imported targets, if found: | ||
``FLAC::FLAC`` | ||
The FLAC C library. | ||
``FLAC::FLAC++`` | ||
The FLAC C++ library. | ||
Result Variables | ||
^^^^^^^^^^^^^^^^ | ||
This will define the following variables: | ||
``FLAC_FOUND`` | ||
True if both libraries were found. | ||
``FLAC_FLAC_FOUND`` | ||
True if the C library was found. | ||
``FLAC_FLAC++_FOUND`` | ||
True if the C++ library was found.. | ||
#]=======================================================================] | ||
|
||
# Use pkg-config if available | ||
find_package(PkgConfig QUIET) | ||
pkg_check_modules(PC_FLAC QUIET flac) | ||
pkg_check_modules(PC_FLAC++ QUIET flac++) | ||
|
||
# Find the headers and libraries | ||
find_path( | ||
FLAC_INCLUDE_DIR | ||
NAMES "FLAC/all.h" | ||
HINTS "PC_FLAC_INCLUDEDIR") | ||
|
||
find_path( | ||
FLAC++_INCLUDE_DIR | ||
NAMES "FLAC++/all.h" | ||
HINTS "PC_FLAC++_INCLUDEDIR") | ||
|
||
find_library( | ||
FLAC_LIBRARY | ||
NAMES "FLAC" | ||
HINTS "${PC_FLAC_LIBDIR}") | ||
|
||
find_library( | ||
FLAC++_LIBRARY | ||
NAMES "FLAC++" | ||
HINTS "${PC_FLAC++_LIBDIR}") | ||
|
||
# Handle transitive dependencies | ||
if(PC_FLAC_FOUND) | ||
get_target_properties_from_pkg_config("${FLAC_LIBRARY}" "PC_FLAC" "_flac") | ||
else() | ||
if(NOT TARGET "Ogg::ogg") | ||
find_package(Ogg QUIET) | ||
endif() | ||
set(_flac_link_libraries "Ogg::ogg" ${MATH_LIBRARY}) | ||
endif() | ||
|
||
if(PC_FLAC++_FOUND) | ||
get_target_properties_from_pkg_config("${FLAC++_LIBRARY}" "PC_FLAC++" | ||
"_flac++") | ||
else() | ||
set(_flac++_link_libraries "FLAC::FLAC") | ||
endif() | ||
|
||
# Forward the result to CMake | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args( | ||
FLAC REQUIRED_VARS "FLAC_LIBRARY" "FLAC_INCLUDE_DIR" "FLAC++_LIBRARY" | ||
"FLAC++_INCLUDE_DIR") | ||
|
||
# Create the target | ||
if(FLAC_FOUND AND NOT TARGET FLAC::FLAC) | ||
add_library(FLAC::FLAC UNKNOWN IMPORTED) | ||
set_target_properties( | ||
FLAC::FLAC | ||
PROPERTIES IMPORTED_LOCATION "${FLAC_LIBRARY}" | ||
INTERFACE_COMPILE_OPTIONS "${_flac_compile_options}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}" | ||
INTERFACE_LINK_LIBRARIES "${_flac_link_libraries}" | ||
INTERFACE_LINK_DIRECTORIES "${_flac_link_directories}") | ||
set(FLAC_FLAC_FOUND TRUE) | ||
endif() | ||
|
||
if(FLAC_FOUND AND NOT TARGET FLAC::FLAC++) | ||
add_library(FLAC::FLAC++ UNKNOWN IMPORTED) | ||
set_target_properties( | ||
FLAC::FLAC++ | ||
PROPERTIES IMPORTED_LOCATION "${FLAC++_LIBRARY}" | ||
INTERFACE_COMPILE_OPTIONS "${_flac++_compile_options}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${FLAC++_INCLUDE_DIR}" | ||
INTERFACE_LINK_LIBRARIES "${_flac++_link_libraries}" | ||
INTERFACE_LINK_DIRECTORIES "${_flac++_link_directories}") | ||
set(FLAC_FLAC++_FOUND TRUE) | ||
endif() | ||
|
||
mark_as_advanced(FLAC_LIBRARY FLAC_INCLUDE_DIR FLAC++_LIBRARY | ||
FLAC++_INCLUDE_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#[=======================================================================[.rst: | ||
FindOgg | ||
------- | ||
Finds the Ogg library. | ||
Imported Targets | ||
^^^^^^^^^^^^^^^^ | ||
This module provides the following imported targets, if found: | ||
``Ogg::ogg`` | ||
The Ogg library | ||
Result Variables | ||
^^^^^^^^^^^^^^^^ | ||
This will define the following variables: | ||
``Ogg_FOUND`` | ||
True if the system has the Ogg library. | ||
For compatibility with upstream, the following variables are also set: | ||
``Ogg_INCLUDE_DIR`` | ||
``Ogg_INCLUDE_DIRS`` | ||
``Ogg_LIBRARY`` | ||
``Ogg_LIBRARIES`` | ||
``OGG_INCLUDE_DIR`` | ||
``OGG_INCLUDE_DIRS`` | ||
``OGG_LIBRARY`` | ||
``OGG_LIBRARIES`` | ||
``OGG_FOUND`` | ||
#]=======================================================================] | ||
|
||
# Use pkg-config if available | ||
find_package(PkgConfig QUIET) | ||
pkg_check_modules(PC_OGG QUIET ogg) | ||
|
||
# Find the headers and library | ||
find_path( | ||
Ogg_INCLUDE_DIR | ||
NAMES "ogg/ogg.h" | ||
HINTS "${PC_OGG_INCLUDEDIR}") | ||
|
||
find_library( | ||
_ogg_library | ||
NAMES "ogg" | ||
HINTS "${PC_OGG_LIBDIR}") | ||
|
||
# Extract additional flags if pkg-config is available | ||
if(PC_OGG_FOUND) | ||
get_target_properties_from_pkg_config("${_ogg_library}" "PC_OGG" "_ogg") | ||
endif() | ||
|
||
# Forward the result to CMake | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Ogg REQUIRED_VARS "_ogg_library" | ||
"Ogg_INCLUDE_DIR") | ||
|
||
# Create the target | ||
if(Ogg_FOUND AND NOT TARGET Ogg::ogg) | ||
add_library(Ogg::ogg UNKNOWN IMPORTED) | ||
set_target_properties( | ||
Ogg::ogg | ||
PROPERTIES IMPORTED_LOCATION "${_ogg_library}" | ||
INTERFACE_COMPILE_OPTIONS "${_ogg_compile_options}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${Ogg_INCLUDE_DIR}" | ||
INTERFACE_LINK_LIBRARIES "${_ogg_link_libraries}" | ||
INTERFACE_LINK_DIRECTORIES "${_ogg_link_directories}") | ||
|
||
# Set additional variables for compatibility with upstream config | ||
set(Ogg_INCLUDE_DIRS "${Ogg_INCLUDE_DIR}") | ||
set(Ogg_LIBRARY Ogg::ogg) | ||
set(Ogg_LIBRARIES Ogg::ogg) | ||
set(OGG_INCLUDE_DIR "${${Ogg_INCLUDE_DIR}}") | ||
set(OGG_INCLUDE_DIRS "${${Ogg_INCLUDE_DIR}}") | ||
set(OGG_LIBRARY Ogg::ogg) | ||
set(OGG_LIBRARIES Ogg::ogg) | ||
set(OGG_FOUND TRUE) | ||
endif() | ||
|
||
mark_as_advanced(_ogg_library) |
Oops, something went wrong.