ref: 061728e6bd4d4c6168e0e07d6720ba75614b100e
parent: eb9f22293a1635c1af2687deaafdf7a0f201b4cc
author: Hendrik <git@h3ndrk.de>
date: Mon May 31 15:49:20 EDT 2021
Add find modules, minor fixes to include paths etc. Signed-off-by: Ralph Giles <giles@thaumas.net> Signed-off-by: evpobr <evpobr@gmail.com>
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,11 +38,14 @@
"${CMAKE_CURRENT_SOURCE_DIR}/src/stream.c"
)
add_library(opusfile::opusfile ALIAS opusfile)
+set_target_properties(opusfile PROPERTIES
+ PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/opusfile.h"
+)
target_include_directories(opusfile
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include"
INTERFACE
- $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(opusfile
@@ -76,6 +79,7 @@
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
if(NOT OP_DISABLE_HTTP)
@@ -113,6 +117,7 @@
cmake_pop_check_state()
add_library(opusurl
+ "${CMAKE_CURRENT_SOURCE_DIR}/include/opusfile.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/http.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/internal.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/internal.h"
@@ -124,11 +129,14 @@
"${CMAKE_CURRENT_SOURCE_DIR}/src/winerrno.h"
)
endif()
+ set_target_properties(opusfile PROPERTIES
+ PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/opusfile.h"
+ )
target_include_directories(opusurl
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include"
INTERFACE
- $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_definitions(opusurl
@@ -167,6 +175,7 @@
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()
--- /dev/null
+++ b/cmake/FindOgg.cmake
@@ -1,0 +1,6 @@
+find_package(Ogg CONFIG)
+if(NOT TARGET Ogg::ogg)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(Ogg REQUIRED IMPORTED_TARGET ogg)
+ add_library(Ogg::ogg ALIAS PkgConfig::Ogg)
+endif()
--- /dev/null
+++ b/cmake/FindOpus.cmake
@@ -1,0 +1,6 @@
+find_package(Opus CONFIG)
+if(NOT TARGET Opus::opus)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(Opus REQUIRED IMPORTED_TARGET opus)
+ add_library(Opus::opus ALIAS PkgConfig::Opus)
+endif()
--- a/opusfileConfig.cmake
+++ b/opusfileConfig.cmake
@@ -1,14 +1,41 @@
-include(CMakeFindDependencyMacro)
-find_dependency(
- Ogg
- Opus
-)
+# Ported from CMakeFindDependencyMacro.cmake (finding configs and using pkgconfig as fallback)
+set(cmake_quiet_arg)
+if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
+ set(cmake_quiet_arg QUIET)
+endif()
+set(cmake_required_arg)
+if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
+ set(cmake_required_arg REQUIRED)
+endif()
-include("${CMAKE_CURRENT_LIST_DIR}/opusfileTargets.cmake")
+find_package(Ogg CONFIG ${cmake_quiet_arg})
+if(NOT TARGET Ogg::ogg)
+ find_package(PkgConfig REQUIRED ${cmake_quiet_arg})
+ pkg_check_modules(Ogg ${cmake_required_arg} ${cmake_quiet_arg} IMPORTED_TARGET ogg)
+ add_library(Ogg::ogg ALIAS PkgConfig::Ogg)
+endif()
-# Load information for each installed configuration.
-get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
-file(GLOB CONFIG_FILES "${_DIR}/opusfileTargets-*.cmake")
-foreach(f ${CONFIG_FILES})
- include(${f})
-endforeach()
+if (NOT TARGET Ogg::ogg)
+ set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency Ogg could not be found.")
+ set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
+ return()
+endif()
+
+find_package(Opus CONFIG ${cmake_quiet_arg})
+if(NOT TARGET Opus::opus)
+ find_package(PkgConfig REQUIRED ${cmake_quiet_arg})
+ pkg_check_modules(Opus ${cmake_required_arg} ${cmake_quiet_arg} IMPORTED_TARGET opus)
+ add_library(Opus::opus ALIAS PkgConfig::Opus)
+endif()
+
+if (NOT TARGET Opus::opus)
+ set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency Opus could not be found.")
+ set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
+ return()
+endif()
+
+set(cmake_fd_required_arg)
+set(cmake_fd_quiet_arg)
+
+# Including targets of opusfile
+include("${CMAKE_CURRENT_LIST_DIR}/opusfileTargets.cmake")