mirror of
https://github.com/ZDoom/zdoom-macos-deps.git
synced 2024-11-25 05:11:49 +00:00
wip
[skip build]
This commit is contained in:
parent
961e571183
commit
b91d5920d9
6 changed files with 727 additions and 6 deletions
|
@ -126,22 +126,40 @@ class ModPlugTarget(base.ConfigureMakeStaticDependencyTarget):
|
|||
return line
|
||||
|
||||
|
||||
class OpusFileTarget(base.ConfigureMakeStaticDependencyTarget):
|
||||
class OpusFileTarget(base.CMakeStaticDependencyTarget):
|
||||
def __init__(self, name='opusfile'):
|
||||
super().__init__(name)
|
||||
|
||||
def prepare_source(self, state: BuildState):
|
||||
state.download_source(
|
||||
'https://ftp.osuosl.org/pub/xiph/releases/opus/opusfile-0.12.tar.gz',
|
||||
'118d8601c12dd6a44f52423e68ca9083cc9f2bfe72da7a8c1acb22a80ae3550b')
|
||||
|
||||
def detect(self, state: BuildState) -> bool:
|
||||
return state.has_source_file('opusfile.pc.in')
|
||||
'118d8601c12dd6a44f52423e68ca9083cc9f2bfe72da7a8c1acb22a80ae3550b',
|
||||
patches='opusfile-add-cmake')
|
||||
|
||||
def configure(self, state: BuildState):
|
||||
state.options['--enable-http'] = 'no'
|
||||
# TODO: figure out why it looks for headers in prefix root instead of opus subdirectory
|
||||
headers = ('opus.h', 'opus_defines.h', 'opus_multistream.h', 'opus_projection.h', 'opus_types.h')
|
||||
|
||||
for header in headers:
|
||||
dest_path = state.include_path / header
|
||||
|
||||
if not dest_path.exists():
|
||||
os.link(state.include_path / 'opus' / header, dest_path)
|
||||
|
||||
opts = state.options
|
||||
opts['OP_DISABLE_DOCS'] = 'YES'
|
||||
opts['OP_DISABLE_EXAMPLES'] = 'YES'
|
||||
opts['OP_DISABLE_HTTP'] = 'YES'
|
||||
|
||||
super().configure(state)
|
||||
|
||||
def post_build(self, state: BuildState):
|
||||
super().post_build(state)
|
||||
|
||||
self.write_pc_file(state,
|
||||
description='High-level Opus decoding library', version='0.12',
|
||||
requires_private='ogg >= 1.3 opus >= 1.0.1', cflags='-I${includedir}/opus')
|
||||
|
||||
|
||||
class PngTarget(base.CMakeStaticDependencyTarget):
|
||||
def __init__(self, name='png'):
|
||||
|
|
76
deps/opusfile/lib/cmake/opusfile/OpusFileConfig.cmake
vendored
Normal file
76
deps/opusfile/lib/cmake/opusfile/OpusFileConfig.cmake
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
|
||||
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
|
||||
####### Any changes to this file will be overwritten by the next CMake run ####
|
||||
####### The input file was OpusFileConfig.cmake.in ########
|
||||
|
||||
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
|
||||
|
||||
macro(set_and_check _var _file)
|
||||
set(${_var} "${_file}")
|
||||
if(NOT EXISTS "${_file}")
|
||||
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(check_required_components _NAME)
|
||||
foreach(comp ${${_NAME}_FIND_COMPONENTS})
|
||||
if(NOT ${_NAME}_${comp}_FOUND)
|
||||
if(${_NAME}_FIND_REQUIRED_${comp})
|
||||
set(${_NAME}_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
####################################################################################
|
||||
|
||||
# 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()
|
||||
|
||||
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)
|
||||
set_target_properties(PkgConfig::Ogg PROPERTIES IMPORTED_GLOBAL TRUE)
|
||||
add_library(Ogg::ogg ALIAS PkgConfig::Ogg)
|
||||
endif()
|
||||
|
||||
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)
|
||||
set_target_properties(PkgConfig::Opus PROPERTIES IMPORTED_GLOBAL TRUE)
|
||||
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)
|
||||
|
||||
if (NOT YES)
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(OpenSSL)
|
||||
endif()
|
||||
|
||||
# Including targets of opusfile
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/opusfileTargets.cmake")
|
||||
|
||||
check_required_components(opusfile)
|
48
deps/opusfile/lib/cmake/opusfile/OpusFileConfigVersion.cmake
vendored
Normal file
48
deps/opusfile/lib/cmake/opusfile/OpusFileConfigVersion.cmake
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
# This is a basic version file for the Config-mode of find_package().
|
||||
# It is used by write_basic_package_version_file() as input file for configure_file()
|
||||
# to create a version-file which can be installed along a config.cmake file.
|
||||
#
|
||||
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
|
||||
# the requested version string are exactly the same and it sets
|
||||
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
|
||||
# The variable CVF_VERSION must be set before calling configure_file().
|
||||
|
||||
set(PACKAGE_VERSION "0.12")
|
||||
|
||||
if (PACKAGE_FIND_VERSION_RANGE)
|
||||
# Package version must be in the requested version range
|
||||
if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
|
||||
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
|
||||
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
endif()
|
||||
else()
|
||||
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# if the installed project requested no architecture check, don't perform the check
|
||||
if("FALSE")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
|
||||
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
|
||||
math(EXPR installedBits "8 * 8")
|
||||
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
endif()
|
19
deps/opusfile/lib/cmake/opusfile/OpusFileTargets-release.cmake
vendored
Normal file
19
deps/opusfile/lib/cmake/opusfile/OpusFileTargets-release.cmake
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
#----------------------------------------------------------------
|
||||
# Generated CMake target import file for configuration "Release".
|
||||
#----------------------------------------------------------------
|
||||
|
||||
# Commands may need to know the format version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
|
||||
# Import target "OpusFile::opusfile" for configuration "Release"
|
||||
set_property(TARGET OpusFile::opusfile APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(OpusFile::opusfile PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libopusfile.a"
|
||||
)
|
||||
|
||||
list(APPEND _cmake_import_check_targets OpusFile::opusfile )
|
||||
list(APPEND _cmake_import_check_files_for_OpusFile::opusfile "${_IMPORT_PREFIX}/lib/libopusfile.a" )
|
||||
|
||||
# Commands beyond this point should not need to know the version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
107
deps/opusfile/lib/cmake/opusfile/OpusFileTargets.cmake
vendored
Normal file
107
deps/opusfile/lib/cmake/opusfile/OpusFileTargets.cmake
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
# Generated by CMake
|
||||
|
||||
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
|
||||
message(FATAL_ERROR "CMake >= 2.8.0 required")
|
||||
endif()
|
||||
if(CMAKE_VERSION VERSION_LESS "2.8.3")
|
||||
message(FATAL_ERROR "CMake >= 2.8.3 required")
|
||||
endif()
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(VERSION 2.8.3...3.23)
|
||||
#----------------------------------------------------------------
|
||||
# Generated CMake target import file.
|
||||
#----------------------------------------------------------------
|
||||
|
||||
# Commands may need to know the format version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
|
||||
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
|
||||
set(_cmake_targets_defined "")
|
||||
set(_cmake_targets_not_defined "")
|
||||
set(_cmake_expected_targets "")
|
||||
foreach(_cmake_expected_target IN ITEMS OpusFile::opusfile)
|
||||
list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
|
||||
if(TARGET "${_cmake_expected_target}")
|
||||
list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
|
||||
else()
|
||||
list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_cmake_expected_target)
|
||||
if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
|
||||
unset(_cmake_targets_defined)
|
||||
unset(_cmake_targets_not_defined)
|
||||
unset(_cmake_expected_targets)
|
||||
unset(CMAKE_IMPORT_FILE_VERSION)
|
||||
cmake_policy(POP)
|
||||
return()
|
||||
endif()
|
||||
if(NOT _cmake_targets_defined STREQUAL "")
|
||||
string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
|
||||
string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
|
||||
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
|
||||
endif()
|
||||
unset(_cmake_targets_defined)
|
||||
unset(_cmake_targets_not_defined)
|
||||
unset(_cmake_expected_targets)
|
||||
|
||||
|
||||
# Compute the installation prefix relative to this file.
|
||||
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
||||
if(_IMPORT_PREFIX STREQUAL "/")
|
||||
set(_IMPORT_PREFIX "")
|
||||
endif()
|
||||
|
||||
# Create imported target OpusFile::opusfile
|
||||
add_library(OpusFile::opusfile STATIC IMPORTED)
|
||||
|
||||
set_target_properties(OpusFile::opusfile PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/opus;${_IMPORT_PREFIX}/include/opus"
|
||||
INTERFACE_LINK_LIBRARIES "Ogg::ogg;Opus::opus;\$<\$<BOOL:1>:m>"
|
||||
)
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 2.8.12)
|
||||
message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
|
||||
endif()
|
||||
|
||||
# Load information for each installed configuration.
|
||||
file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/OpusFileTargets-*.cmake")
|
||||
foreach(_cmake_config_file IN LISTS _cmake_config_files)
|
||||
include("${_cmake_config_file}")
|
||||
endforeach()
|
||||
unset(_cmake_config_file)
|
||||
unset(_cmake_config_files)
|
||||
|
||||
# Cleanup temporary variables.
|
||||
set(_IMPORT_PREFIX)
|
||||
|
||||
# Loop over all imported files and verify that they actually exist
|
||||
foreach(_cmake_target IN LISTS _cmake_import_check_targets)
|
||||
foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}")
|
||||
if(NOT EXISTS "${_cmake_file}")
|
||||
message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file
|
||||
\"${_cmake_file}\"
|
||||
but this file does not exist. Possible reasons include:
|
||||
* The file was deleted, renamed, or moved to another location.
|
||||
* An install or uninstall procedure did not complete successfully.
|
||||
* The installation package was faulty and contained
|
||||
\"${CMAKE_CURRENT_LIST_FILE}\"
|
||||
but not all the files it references.
|
||||
")
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_cmake_file)
|
||||
unset("_cmake_import_check_files_for_${_cmake_target}")
|
||||
endforeach()
|
||||
unset(_cmake_target)
|
||||
unset(_cmake_import_check_targets)
|
||||
|
||||
# This file does not depend on other imported targets which have
|
||||
# been exported from the same project but in a separate export set.
|
||||
|
||||
# Commands beyond this point should not need to know the version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
||||
cmake_policy(POP)
|
453
patch/opusfile-add-cmake.diff
Normal file
453
patch/opusfile-add-cmake.diff
Normal file
|
@ -0,0 +1,453 @@
|
|||
--- /dev/null
|
||||
+++ a/CMakeLists.txt
|
||||
@@ -0,0 +1,302 @@
|
||||
+cmake_minimum_required(VERSION 3.16)
|
||||
+
|
||||
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
+
|
||||
+include(OpusFilePackageVersion)
|
||||
+get_package_version(PACKAGE_VERSION PROJECT_VERSION)
|
||||
+string(REPLACE "." ";" PROJECT_VERSION_LIST ${PROJECT_VERSION})
|
||||
+list(GET PROJECT_VERSION_LIST 0 PROJECT_VERSION_MAJOR)
|
||||
+list(GET PROJECT_VERSION_LIST 1 PROJECT_VERSION_MINOR)
|
||||
+
|
||||
+project(OpusFile
|
||||
+ VERSION ${PROJECT_VERSION}
|
||||
+ LANGUAGES C
|
||||
+)
|
||||
+
|
||||
+option(OP_DISABLE_HTTP "Disable HTTP support" OFF)
|
||||
+option(OP_DISABLE_FLOAT_API "Disable floating-point API" OFF)
|
||||
+option(OP_FIXED_POINT "Enable fixed-point calculation" OFF)
|
||||
+option(OP_ENABLE_ASSERTIONS "Enable assertions in code" OFF)
|
||||
+option(OP_DISABLE_EXAMPLES "Do not build example applications" OFF)
|
||||
+option(OP_DISABLE_DOCS "Do not build API documentation" OFF)
|
||||
+
|
||||
+include(GNUInstallDirs)
|
||||
+
|
||||
+find_package(Ogg REQUIRED)
|
||||
+find_package(Opus REQUIRED)
|
||||
+
|
||||
+include(CMakePushCheckState)
|
||||
+include(CheckSymbolExists)
|
||||
+cmake_push_check_state(RESET)
|
||||
+include(CheckLibraryExists)
|
||||
+check_library_exists(m lrintf "" OP_HAVE_LIBM)
|
||||
+if(OP_HAVE_LIBM)
|
||||
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "m")
|
||||
+endif()
|
||||
+check_symbol_exists(lrintf "math.h" OP_HAVE_LRINTF)
|
||||
+cmake_pop_check_state()
|
||||
+
|
||||
+add_library(opusfile
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/include/opusfile.h"
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/info.c"
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/internal.c"
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/internal.h"
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/opusfile.c"
|
||||
+ "${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"
|
||||
+ VERSION ${PROJECT_VERSION}
|
||||
+ SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
+)
|
||||
+target_include_directories(opusfile
|
||||
+ PRIVATE
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
+ INTERFACE
|
||||
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/opus>
|
||||
+)
|
||||
+target_link_libraries(opusfile
|
||||
+ PUBLIC
|
||||
+ Ogg::ogg
|
||||
+ Opus::opus
|
||||
+ $<$<BOOL:${OP_HAVE_LIBM}>:m>
|
||||
+)
|
||||
+target_compile_options(opusfile
|
||||
+ PRIVATE
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4267>
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4244>
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4090>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-std=c89>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-pedantic>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wall>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wextra>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wno-parentheses>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wno-long-long>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-fvisibility=hidden>
|
||||
+)
|
||||
+target_compile_definitions(opusfile
|
||||
+ PRIVATE
|
||||
+ $<$<BOOL:${OP_DISABLE_FLOAT_API}>:OP_DISABLE_FLOAT_API>
|
||||
+ $<$<BOOL:${OP_FIXED_POINT}>:OP_FIXED_POINT>
|
||||
+ $<$<BOOL:${OP_ENABLE_ASSERTIONS}>:OP_ENABLE_ASSERTIONS>
|
||||
+ $<$<BOOL:${OP_HAVE_LRINTF}>:OP_HAVE_LRINTF>
|
||||
+)
|
||||
+install(TARGETS opusfile
|
||||
+ EXPORT OpusFileTargets
|
||||
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
+ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus"
|
||||
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus"
|
||||
+)
|
||||
+
|
||||
+if(NOT OP_DISABLE_HTTP)
|
||||
+ find_package(OpenSSL REQUIRED)
|
||||
+
|
||||
+ include(CheckIncludeFile)
|
||||
+ include(CheckCSourceCompiles)
|
||||
+ cmake_push_check_state(RESET)
|
||||
+ if(NOT WIN32)
|
||||
+ check_include_file("sys/socket.h" OP_HAVE_SYS_SOCKET_H)
|
||||
+ if(NOT OP_HAVE_SYS_SOCKET_H)
|
||||
+ message(FATAL_ERROR "HTTP support requires a POSIX socket library")
|
||||
+ endif()
|
||||
+ endif()
|
||||
+ check_c_source_compiles(
|
||||
+ "#include <time.h>
|
||||
+ int main(void)
|
||||
+ {
|
||||
+ struct timespec ts;
|
||||
+ return clock_gettime(CLOCK_REALTIME, &ts);
|
||||
+ }"
|
||||
+ OP_HAVE_CLOCK_GETTIME
|
||||
+ )
|
||||
+ if(NOT OP_HAVE_CLOCK_GETTIME)
|
||||
+ check_symbol_exists(ftime "sys/timeb.h" OP_HAVE_FTIME)
|
||||
+ if(NOT OP_HAVE_FTIME)
|
||||
+ message(FATAL_ERROR "HTTP support requires either clock_gettime() or ftime()")
|
||||
+ endif()
|
||||
+ endif()
|
||||
+ 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"
|
||||
+ )
|
||||
+ add_library(OpusFile::opusurl ALIAS opusurl)
|
||||
+ if(WIN32)
|
||||
+ target_sources(opusurl PRIVATE
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/wincerts.c"
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/winerrno.h"
|
||||
+ )
|
||||
+ endif()
|
||||
+ set_target_properties(opusurl PROPERTIES
|
||||
+ PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/opusfile.h"
|
||||
+ VERSION ${PROJECT_VERSION}
|
||||
+ SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
+ )
|
||||
+ target_include_directories(opusurl
|
||||
+ PRIVATE
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
+ INTERFACE
|
||||
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/opus>
|
||||
+ )
|
||||
+ target_compile_definitions(opusurl
|
||||
+ PRIVATE
|
||||
+ $<$<BOOL:${OP_DISABLE_FLOAT_API}>:OP_DISABLE_FLOAT_API>
|
||||
+ $<$<BOOL:${OP_FIXED_POINT}>:OP_FIXED_POINT>
|
||||
+ $<$<BOOL:${OP_ENABLE_ASSERTIONS}>:OP_ENABLE_ASSERTIONS>
|
||||
+ $<$<BOOL:${OP_HAVE_LRINTF}>:OP_HAVE_LRINTF>
|
||||
+ $<$<BOOL:${OP_HAVE_CLOCK_GETTIME}>:OP_HAVE_CLOCK_GETTIME>
|
||||
+ $<$<BOOL:${OP_HAVE_FTIME}>:OP_HAVE_FTIME>
|
||||
+ OP_ENABLE_HTTP
|
||||
+ )
|
||||
+ target_link_libraries(opusurl
|
||||
+ PRIVATE
|
||||
+ opusfile
|
||||
+ OpenSSL::SSL
|
||||
+ $<$<C_COMPILER_ID:MSVC>:ws2_32>
|
||||
+ $<$<C_COMPILER_ID:MSVC>:crypt32>
|
||||
+ $<$<BOOL:${OP_HAVE_LIBM}>:m>
|
||||
+ )
|
||||
+ target_compile_options(opusurl
|
||||
+ PRIVATE
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4267>
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4244>
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4090>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-std=c89>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-pedantic>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wall>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wextra>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wno-parentheses>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wno-long-long>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-fvisibility=hidden>
|
||||
+ )
|
||||
+ install(TARGETS opusurl
|
||||
+ EXPORT OpusFileTargets
|
||||
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
+ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus"
|
||||
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus"
|
||||
+ )
|
||||
+endif()
|
||||
+
|
||||
+if(NOT OP_DISABLE_EXAMPLES)
|
||||
+ add_executable(opusfile_example
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/examples/opusfile_example.c"
|
||||
+ )
|
||||
+ add_executable(OpusFile::opusfile_example ALIAS opusfile_example)
|
||||
+ if(WIN32)
|
||||
+ target_sources(opusfile_example PRIVATE
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/examples/win32utf8.c"
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/examples/win32utf8.h"
|
||||
+ )
|
||||
+ endif()
|
||||
+ target_include_directories(opusfile_example
|
||||
+ PRIVATE
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/examples"
|
||||
+ )
|
||||
+ target_link_libraries(opusfile_example
|
||||
+ PRIVATE
|
||||
+ opusfile
|
||||
+ opusurl
|
||||
+ )
|
||||
+ target_compile_options(opusfile_example
|
||||
+ PRIVATE
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4267>
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4244>
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4090>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-std=c89>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-pedantic>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wall>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wextra>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wno-parentheses>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wno-long-long>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-fvisibility=hidden>
|
||||
+ )
|
||||
+
|
||||
+ add_executable(seeking_example
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/examples/seeking_example.c"
|
||||
+ )
|
||||
+ add_executable(OpusFile::seeking_example ALIAS seeking_example)
|
||||
+ if(WIN32)
|
||||
+ target_sources(seeking_example PRIVATE
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/examples/win32utf8.c"
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/examples/win32utf8.h"
|
||||
+ )
|
||||
+ endif()
|
||||
+ target_include_directories(seeking_example
|
||||
+ PRIVATE
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/examples"
|
||||
+ )
|
||||
+ target_link_libraries(seeking_example
|
||||
+ PRIVATE
|
||||
+ opusfile
|
||||
+ opusurl
|
||||
+ )
|
||||
+ target_compile_options(seeking_example
|
||||
+ PRIVATE
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4267>
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4244>
|
||||
+ $<$<C_COMPILER_ID:MSVC>:/wd4090>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-std=c89>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-pedantic>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wall>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wextra>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wno-parentheses>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-Wno-long-long>
|
||||
+ $<$<C_COMPILER_ID:Clang,GNU>:-fvisibility=hidden>
|
||||
+ )
|
||||
+endif()
|
||||
+
|
||||
+if(NOT OP_DISABLE_DOCS)
|
||||
+ find_package(Doxygen OPTIONAL_COMPONENTS dot)
|
||||
+
|
||||
+ set(DOXYGEN_PROJECT_BRIEF "Stand-alone decoder library for .opus files.")
|
||||
+ set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
|
||||
+
|
||||
+ set(DOXYGEN_QUIET YES)
|
||||
+ set(DOXYGEN_WARNINGS YES)
|
||||
+ set(DOXYGEN_WARN_IF_UNDOCUMENTED YES)
|
||||
+ set(DOXYGEN_WARN_IF_DOC_ERROR YES)
|
||||
+ set(DOXYGEN_WARN_NO_PARAMDOC YES)
|
||||
+
|
||||
+ set(DOXYGEN_JAVADOC_AUTOBRIEF YES)
|
||||
+ set(DOXYGEN_SORT_MEMBER_DOCS NO)
|
||||
+
|
||||
+ set(DOXYGEN_PROJECT_LOGO "${CMAKE_CURRENT_SOURCE_DIR}/doc/opus_logo.svg")
|
||||
+
|
||||
+ set(DOXYGEN_FULL_PATH_NAMES NO)
|
||||
+
|
||||
+ doxygen_add_docs(doxygen "${CMAKE_CURRENT_SOURCE_DIR}/include/opusfile.h" ALL USE_STAMP_FILE)
|
||||
+endif()
|
||||
+
|
||||
+install(EXPORT OpusFileTargets
|
||||
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/opusfile"
|
||||
+ NAMESPACE OpusFile::
|
||||
+)
|
||||
+include(CMakePackageConfigHelpers)
|
||||
+configure_package_config_file(
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/OpusFileConfig.cmake.in"
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/OpusFileConfig.cmake"
|
||||
+ INSTALL_DESTINATION
|
||||
+ "${CMAKE_INSTALL_LIBDIR}/cmake/opusfile"
|
||||
+)
|
||||
+write_basic_package_version_file(
|
||||
+ "OpusFileConfigVersion.cmake"
|
||||
+ VERSION "${PACKAGE_VERSION}"
|
||||
+ COMPATIBILITY AnyNewerVersion
|
||||
+)
|
||||
+install(
|
||||
+ FILES
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/OpusFileConfig.cmake"
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/OpusFileConfigVersion.cmake"
|
||||
+ DESTINATION
|
||||
+ "${CMAKE_INSTALL_LIBDIR}/cmake/opusfile"
|
||||
+)
|
||||
--- /dev/null
|
||||
+++ a/cmake/FindOgg.cmake
|
||||
@@ -0,0 +1,7 @@
|
||||
+find_package(Ogg CONFIG)
|
||||
+if(NOT TARGET Ogg::ogg)
|
||||
+ find_package(PkgConfig REQUIRED)
|
||||
+ pkg_check_modules(Ogg REQUIRED IMPORTED_TARGET ogg)
|
||||
+ set_target_properties(PkgConfig::Ogg PROPERTIES IMPORTED_GLOBAL TRUE)
|
||||
+ add_library(Ogg::ogg ALIAS PkgConfig::Ogg)
|
||||
+endif()
|
||||
--- /dev/null
|
||||
+++ a/cmake/FindOpus.cmake
|
||||
@@ -0,0 +1,7 @@
|
||||
+find_package(Opus CONFIG)
|
||||
+if(NOT TARGET Opus::opus)
|
||||
+ find_package(PkgConfig REQUIRED)
|
||||
+ pkg_check_modules(Opus REQUIRED IMPORTED_TARGET opus)
|
||||
+ set_target_properties(PkgConfig::Opus PROPERTIES IMPORTED_GLOBAL TRUE)
|
||||
+ add_library(Opus::opus ALIAS PkgConfig::Opus)
|
||||
+endif()
|
||||
--- /dev/null
|
||||
+++ a/cmake/OpusFileConfig.cmake.in
|
||||
@@ -0,0 +1,52 @@
|
||||
+@PACKAGE_INIT@
|
||||
+
|
||||
+# 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()
|
||||
+
|
||||
+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)
|
||||
+ set_target_properties(PkgConfig::Ogg PROPERTIES IMPORTED_GLOBAL TRUE)
|
||||
+ add_library(Ogg::ogg ALIAS PkgConfig::Ogg)
|
||||
+endif()
|
||||
+
|
||||
+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)
|
||||
+ set_target_properties(PkgConfig::Opus PROPERTIES IMPORTED_GLOBAL TRUE)
|
||||
+ 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)
|
||||
+
|
||||
+if (NOT @OP_DISABLE_HTTP@)
|
||||
+ include(CMakeFindDependencyMacro)
|
||||
+ find_dependency(OpenSSL)
|
||||
+endif()
|
||||
+
|
||||
+# Including targets of opusfile
|
||||
+include("${CMAKE_CURRENT_LIST_DIR}/opusfileTargets.cmake")
|
||||
+
|
||||
+check_required_components(opusfile)
|
||||
--- /dev/null
|
||||
+++ a/cmake/OpusFilePackageVersion.cmake
|
||||
@@ -0,0 +1,70 @@
|
||||
+if(__opusfile_version)
|
||||
+ return()
|
||||
+endif()
|
||||
+set(__opusfile_version INCLUDED)
|
||||
+
|
||||
+function(get_package_version PACKAGE_VERSION PROJECT_VERSION)
|
||||
+
|
||||
+ find_package(Git)
|
||||
+ if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
|
||||
+ execute_process(COMMAND ${GIT_EXECUTABLE}
|
||||
+ --git-dir=${CMAKE_CURRENT_LIST_DIR}/.git describe
|
||||
+ --tags --match "v*" OUTPUT_VARIABLE OPUSFILE_PACKAGE_VERSION)
|
||||
+ if(OPUSFILE_PACKAGE_VERSION)
|
||||
+ string(STRIP ${OPUSFILE_PACKAGE_VERSION}, OPUSFILE_PACKAGE_VERSION)
|
||||
+ string(REPLACE \n
|
||||
+ ""
|
||||
+ OPUSFILE_PACKAGE_VERSION
|
||||
+ ${OPUSFILE_PACKAGE_VERSION})
|
||||
+ string(REPLACE ,
|
||||
+ ""
|
||||
+ OPUSFILE_PACKAGE_VERSION
|
||||
+ ${OPUSFILE_PACKAGE_VERSION})
|
||||
+
|
||||
+ string(SUBSTRING ${OPUSFILE_PACKAGE_VERSION}
|
||||
+ 1
|
||||
+ -1
|
||||
+ OPUSFILE_PACKAGE_VERSION)
|
||||
+ message(STATUS "Opus package version from git repo: ${OPUSFILE_PACKAGE_VERSION}")
|
||||
+ endif()
|
||||
+
|
||||
+ elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/package_version"
|
||||
+ AND NOT OPUSFILE_PACKAGE_VERSION)
|
||||
+ # Not a git repo, lets' try to parse it from package_version file if exists
|
||||
+ file(STRINGS package_version OPUSFILE_PACKAGE_VERSION
|
||||
+ LIMIT_COUNT 1
|
||||
+ REGEX "PACKAGE_VERSION=")
|
||||
+ string(REPLACE "PACKAGE_VERSION="
|
||||
+ ""
|
||||
+ OPUSFILE_PACKAGE_VERSION
|
||||
+ ${OPUSFILE_PACKAGE_VERSION})
|
||||
+ string(REPLACE "\""
|
||||
+ ""
|
||||
+ OPUSFILE_PACKAGE_VERSION
|
||||
+ ${OPUSFILE_PACKAGE_VERSION})
|
||||
+ # In case we have a unknown dist here we just replace it with 0
|
||||
+ string(REPLACE "unknown"
|
||||
+ "0"
|
||||
+ OPUSFILE_PACKAGE_VERSION
|
||||
+ ${OPUSFILE_PACKAGE_VERSION})
|
||||
+ message(STATUS "Opus package version from package_version file: ${OPUSFILE_PACKAGE_VERSION}")
|
||||
+ endif()
|
||||
+
|
||||
+ if(OPUSFILE_PACKAGE_VERSION)
|
||||
+ string(REGEX
|
||||
+ REPLACE "^([0-9]+.[0-9]+\\.?([0-9]+)?).*"
|
||||
+ "\\1"
|
||||
+ OPUSFILE_PROJECT_VERSION
|
||||
+ ${OPUSFILE_PACKAGE_VERSION})
|
||||
+ else()
|
||||
+ # fail to parse version from git and package version
|
||||
+ message(WARNING "Could not get package version.")
|
||||
+ set(OPUSFILE_PACKAGE_VERSION 0)
|
||||
+ set(OPUSFILE_PROJECT_VERSION 0)
|
||||
+ endif()
|
||||
+
|
||||
+ message(STATUS "Opus project version: ${OPUSFILE_PROJECT_VERSION}")
|
||||
+
|
||||
+ set(PACKAGE_VERSION ${OPUSFILE_PACKAGE_VERSION} PARENT_SCOPE)
|
||||
+ set(PROJECT_VERSION ${OPUSFILE_PROJECT_VERSION} PARENT_SCOPE)
|
||||
+endfunction()
|
Loading…
Reference in a new issue