From 5f2fd24d9a8e39c319d7043cd13378df8bc45b5d Mon Sep 17 00:00:00 2001 From: Hendrik Date: Fri, 28 May 2021 18:55:01 +0200 Subject: [PATCH 01/26] Add CMakeLists.txt --- CMakeLists.txt | 132 +++++++++++++++++++++++++++++++++++++++++++ opusfileConfig.cmake | 8 +++ 2 files changed, 140 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 opusfileConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6b86fd5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,132 @@ +cmake_minimum_required(VERSION 3.16) +project(opusfile + VERSION 0.12 # TODO: retrieve version from git + LANGUAGES C +) + +# TODO: port autotools options exactly +option(BUILD_OPUSURL "Build opusurl" OFF) +option(OP_DISABLE_FLOAT_API "Disable floating-point API" OFF) +option(OP_FIXED_POINT "Enable fixed-point calculation" OFF) + +include(GNUInstallDirs) + +find_package(Ogg REQUIRED) +find_package(Opus REQUIRED) + +include(CMakePushCheckState) +include(CheckSymbolExists) +cmake_push_check_state(RESET) +list(APPEND CMAKE_REQUIRED_LIBRARIES "m") +check_symbol_exists(lrintf "math.h" HAVE_LRINTF) +# TODO: OP_HAVE_CLOCK_GETTIME +cmake_pop_check_state() + +# TODO: shared libraries via BUILD_SHARED_LIBS does not work +add_library(opusfile + "${CMAKE_CURRENT_SOURCE_DIR}/src/info.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/internal.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/opusfile.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/stream.c" +) +add_library(opusfile::opusfile ALIAS opusfile) +target_include_directories(opusfile + PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/include" + INTERFACE + $ + $ +) +target_link_libraries(opusfile + PUBLIC + Ogg::ogg + Opus::opus +) +target_compile_options(opusfile + PRIVATE + $<$:/wd4267> + $<$:/wd4244> + $<$:/wd4090> + -std=c89 + -pedantic + -Wall + -Wextra + -Wno-parentheses + -Wno-long-long +) +target_compile_definitions(opusfile + PRIVATE + $<${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}" +) + +if(BUILD_OPUSURL) + find_package(OpenSSL REQUIRED) + + add_library(opusurl + "${CMAKE_CURRENT_SOURCE_DIR}/src/http.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/wincerts.c" + ) + add_library(opusfile::opusurl ALIAS opusurl) + target_include_directories(opusurl + PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/include" + INTERFACE + $ + $ + ) + target_compile_definitions(opusurl + PRIVATE + OP_ENABLE_HTTP + ) + target_link_libraries(opusurl + PRIVATE + opusfile + OpenSSL::SSL + ws2_32.lib + crypt32.lib + ) + target_compile_options(opusurl + PRIVATE + $<$:/wd4267> + $<$:/wd4244> + $<$:/wd4090> + -std=c89 + -pedantic + -Wall + -Wextra + -Wno-parentheses + -Wno-long-long + ) + 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}" + ) +endif() + +install(EXPORT opusfileTargets + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/opusfile" + NAMESPACE opusfile:: +) +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "opusfileConfigVersion.cmake" + VERSION "${PACKAGE_VERSION}" + COMPATIBILITY AnyNewerVersion +) +install( + FILES + "${CMAKE_CURRENT_SOURCE_DIR}/opusfileConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/opusfileConfigVersion.cmake" + DESTINATION + "${CMAKE_INSTALL_LIBDIR}/cmake/opusfile" +) diff --git a/opusfileConfig.cmake b/opusfileConfig.cmake new file mode 100644 index 0000000..e5bcb82 --- /dev/null +++ b/opusfileConfig.cmake @@ -0,0 +1,8 @@ +include(CMakeFindDependencyMacro) +find_dependency( + Ogg + Opus +) + +# TODO: include(...opusfileTargets-debug.cmake)? +include("${CMAKE_CURRENT_LIST_DIR}/opusfileTargets.cmake") From 9a2861292c10c86ea38189f0efc428bc27888622 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sat, 29 May 2021 08:21:51 +0200 Subject: [PATCH 02/26] More improvements in CMakeLists.txt --- CMakeLists.txt | 170 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 145 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b86fd5..dbea5a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,12 @@ project(opusfile LANGUAGES C ) -# TODO: port autotools options exactly -option(BUILD_OPUSURL "Build opusurl" OFF) +# TODO: build documentation? +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) include(GNUInstallDirs) @@ -18,14 +20,15 @@ include(CMakePushCheckState) include(CheckSymbolExists) cmake_push_check_state(RESET) list(APPEND CMAKE_REQUIRED_LIBRARIES "m") -check_symbol_exists(lrintf "math.h" HAVE_LRINTF) -# TODO: OP_HAVE_CLOCK_GETTIME +check_symbol_exists(lrintf "math.h" OP_HAVE_LRINTF) cmake_pop_check_state() # TODO: shared libraries via BUILD_SHARED_LIBS does not work 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" ) @@ -34,8 +37,8 @@ target_include_directories(opusfile PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include" INTERFACE - $ - $ + $ + $ ) target_link_libraries(opusfile PUBLIC @@ -47,16 +50,20 @@ target_compile_options(opusfile $<$:/wd4267> $<$:/wd4244> $<$:/wd4090> - -std=c89 - -pedantic - -Wall - -Wextra - -Wno-parentheses - -Wno-long-long + $<$:-std=c89> + $<$:-pedantic> + $<$:-Wall> + $<$:-Wextra> + $<$:-Wno-parentheses> + $<$:-Wno-long-long> + $<$:-fvisibility=hidden> ) target_compile_definitions(opusfile PRIVATE - $<${HAVE_LRINTF}:OP_HAVE_LRINTF> + $<$:OP_DISABLE_FLOAT_API> + $<$:OP_FIXED_POINT> + $<$:OP_ENABLE_ASSERTIONS> + $<$:OP_HAVE_LRINTF> ) install(TARGETS opusfile EXPORT opusfileTargets @@ -66,43 +73,88 @@ install(TARGETS opusfile INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) -if(BUILD_OPUSURL) +if(NOT OP_DISABLE_HTTP) find_package(OpenSSL REQUIRED) + include(CheckIncludeFile) + include(CheckCSourceCompiles) + cmake_push_check_state(RESET) + if(WIN32) + check_include_file("winsock2.h" OP_HAVE_WINSOCK2_H) + if(NOT OP_HAVE_WINSOCK2_H) + message(FATAL_ERROR "HTTP support requires a Winsock socket library") + endif() + else() + 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 + 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}/src/http.c" - "${CMAKE_CURRENT_SOURCE_DIR}/src/wincerts.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/internal.c" # TODO: duplicated symbols because already defined in opusfile? + "${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() target_include_directories(opusurl PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include" INTERFACE - $ - $ + $ + $ ) target_compile_definitions(opusurl PRIVATE + $<$:OP_DISABLE_FLOAT_API> + $<$:OP_FIXED_POINT> + $<$:OP_ENABLE_ASSERTIONS> + $<$:OP_HAVE_LRINTF> + $<$:OP_HAVE_CLOCK_GETTIME> + $<$:OP_HAVE_FTIME> OP_ENABLE_HTTP ) target_link_libraries(opusurl PRIVATE opusfile OpenSSL::SSL - ws2_32.lib - crypt32.lib + $<$:ws2_32> + $<$:crypt32> ) target_compile_options(opusurl PRIVATE $<$:/wd4267> $<$:/wd4244> $<$:/wd4090> - -std=c89 - -pedantic - -Wall - -Wextra - -Wno-parentheses - -Wno-long-long + $<$:-std=c89> + $<$:-pedantic> + $<$:-Wall> + $<$:-Wextra> + $<$:-Wno-parentheses> + $<$:-Wno-long-long> + $<$:-fvisibility=hidden> ) install(TARGETS opusurl EXPORT opusfileTargets @@ -113,6 +165,74 @@ if(BUILD_OPUSURL) ) 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 + $<$:/wd4267> + $<$:/wd4244> + $<$:/wd4090> + $<$:-std=c89> + $<$:-pedantic> + $<$:-Wall> + $<$:-Wextra> + $<$:-Wno-parentheses> + $<$:-Wno-long-long> + $<$:-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 + $<$:/wd4267> + $<$:/wd4244> + $<$:/wd4090> + $<$:-std=c89> + $<$:-pedantic> + $<$:-Wall> + $<$:-Wextra> + $<$:-Wno-parentheses> + $<$:-Wno-long-long> + $<$:-fvisibility=hidden> + ) +endif() + install(EXPORT opusfileTargets DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/opusfile" NAMESPACE opusfile:: From 03a7f775c340435dd89ffa374b6f4ace975f293b Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sat, 29 May 2021 08:22:19 +0200 Subject: [PATCH 03/26] Add build directory to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 574d0c0..f197dd5 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ test-driver unix/objs unix/opusfile_example unix/seeking_example +build From e4a85b97a729c1af9c032709700622214cd796e4 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sat, 29 May 2021 13:09:36 +0200 Subject: [PATCH 04/26] Remove some TODOs from CMakeLists.txt --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbea5a5..db0a1c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,6 @@ list(APPEND CMAKE_REQUIRED_LIBRARIES "m") check_symbol_exists(lrintf "math.h" OP_HAVE_LRINTF) cmake_pop_check_state() -# TODO: shared libraries via BUILD_SHARED_LIBS does not work add_library(opusfile "${CMAKE_CURRENT_SOURCE_DIR}/include/opusfile.h" "${CMAKE_CURRENT_SOURCE_DIR}/src/info.c" @@ -109,7 +108,7 @@ if(NOT OP_DISABLE_HTTP) add_library(opusurl "${CMAKE_CURRENT_SOURCE_DIR}/src/http.c" - "${CMAKE_CURRENT_SOURCE_DIR}/src/internal.c" # TODO: duplicated symbols because already defined in opusfile? + "${CMAKE_CURRENT_SOURCE_DIR}/src/internal.c" "${CMAKE_CURRENT_SOURCE_DIR}/src/internal.h" ) add_library(opusfile::opusurl ALIAS opusurl) From 112b79bbb03927b12535d1b01da4d3b8cfe18670 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sat, 29 May 2021 13:09:48 +0200 Subject: [PATCH 05/26] Include targets from all configurations --- opusfileConfig.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/opusfileConfig.cmake b/opusfileConfig.cmake index e5bcb82..3a15915 100644 --- a/opusfileConfig.cmake +++ b/opusfileConfig.cmake @@ -4,5 +4,11 @@ find_dependency( Opus ) -# TODO: include(...opusfileTargets-debug.cmake)? include("${CMAKE_CURRENT_LIST_DIR}/opusfileTargets.cmake") + +# 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() From 8ca407f35bfff0f0447832642d6359450c319971 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 15:56:10 +0200 Subject: [PATCH 06/26] Dynamic versions --- CMakeLists.txt | 8 +++- cmake/opusfilePackageVersion.cmake | 70 ++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 cmake/opusfilePackageVersion.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index db0a1c2..aa4a27e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,12 @@ 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) + project(opusfile - VERSION 0.12 # TODO: retrieve version from git + VERSION ${PROJECT_VERSION} LANGUAGES C ) diff --git a/cmake/opusfilePackageVersion.cmake b/cmake/opusfilePackageVersion.cmake new file mode 100644 index 0000000..6efae1e --- /dev/null +++ b/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() From 8ce01f98c9f27f0257fcabeea9ff2cdfe66b3996 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 16:25:10 +0200 Subject: [PATCH 07/26] Build documentation with CMake --- CMakeLists.txt | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa4a27e..f4d2b19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,12 +10,12 @@ project(opusfile LANGUAGES C ) -# TODO: build documentation? 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) @@ -238,6 +238,28 @@ if(NOT OP_DISABLE_EXAMPLES) ) 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:: From 9f0518b4cfc6c4feae9cf8b34a04913795904cce Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 19:49:20 +0200 Subject: [PATCH 08/26] Add find modules, minor fixes to include paths etc. --- CMakeLists.txt | 13 +++++++++-- cmake/FindOgg.cmake | 6 ++++++ cmake/FindOpus.cmake | 6 ++++++ opusfileConfig.cmake | 51 +++++++++++++++++++++++++++++++++----------- 4 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 cmake/FindOgg.cmake create mode 100644 cmake/FindOpus.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f4d2b19..e877e0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,11 +38,14 @@ add_library(opusfile "${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 - $ + $ $ ) target_link_libraries(opusfile @@ -76,6 +79,7 @@ install(TARGETS opusfile 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 @@ if(NOT OP_DISABLE_HTTP) 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 @@ if(NOT OP_DISABLE_HTTP) "${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 - $ + $ $ ) target_compile_definitions(opusurl @@ -167,6 +175,7 @@ if(NOT OP_DISABLE_HTTP) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) endif() diff --git a/cmake/FindOgg.cmake b/cmake/FindOgg.cmake new file mode 100644 index 0000000..2bff939 --- /dev/null +++ b/cmake/FindOgg.cmake @@ -0,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() diff --git a/cmake/FindOpus.cmake b/cmake/FindOpus.cmake new file mode 100644 index 0000000..b570a86 --- /dev/null +++ b/cmake/FindOpus.cmake @@ -0,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() diff --git a/opusfileConfig.cmake b/opusfileConfig.cmake index 3a15915..b56a704 100644 --- 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() + +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() -# 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 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") From a57da31d18da64fcfb07c5bc0a51d3a33ac11bb8 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 20:01:29 +0200 Subject: [PATCH 09/26] Add CMake building to Travis CI and GitLab CI --- .gitlab-ci.yml | 14 ++++++++++++++ .travis.yml | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ebe5a74..94a6214 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,6 +15,20 @@ autotools: tags: - docker +cmake: + stage: build + before_script: + - apt-get update && + apt-get install -y libopus-dev libogg-dev libssl-dev + doxygen + script: + - wget https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-linux-x86_64.tar.gz + - tar xzvf cmake-3.20.3-linux-x86_64.tar.gz + - cmake-3.20.3-linux-x86_64/bin/cmake -Bbuild -H. + - cmake-3.20.3-linux-x86_64/bin/cmake --build build + tags: + - docker + makefile: stage: build before_script: diff --git a/.travis.yml b/.travis.yml index 78c9bb8..132b46e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,14 +13,21 @@ osx_image: xcode11.3 addons: apt: packages: + - doxygen - libogg-dev - libopus-dev + - libssl-dev + - wget homebrew: brewfile: true env: PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/openssl/lib/pkgconfig script: + - wget https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-linux-x86_64.tar.gz + - tar xzvf cmake-3.20.3-linux-x86_64.tar.gz + - cmake-3.20.3-linux-x86_64/bin/cmake -Bbuild -H. + - cmake-3.20.3-linux-x86_64/bin/cmake --build build - ./autogen.sh - ./configure - make From 83d94dcf4b79e99d587ed8ce2a512e15d2db9e7b Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 20:27:07 +0200 Subject: [PATCH 10/26] Add math library (fixes static linking) --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e877e0f..e8bba98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,11 @@ find_package(Opus REQUIRED) include(CMakePushCheckState) include(CheckSymbolExists) cmake_push_check_state(RESET) -list(APPEND CMAKE_REQUIRED_LIBRARIES "m") +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() @@ -52,6 +56,7 @@ target_link_libraries(opusfile PUBLIC Ogg::ogg Opus::opus + $<$:m> ) target_compile_options(opusfile PRIVATE @@ -155,6 +160,7 @@ if(NOT OP_DISABLE_HTTP) OpenSSL::SSL $<$:ws2_32> $<$:crypt32> + $<$:m> ) target_compile_options(opusurl PRIVATE From f1a0ee4e356df4fdbdc4750ac89ac613309acba0 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 20:31:40 +0200 Subject: [PATCH 11/26] Remove verbose output of tar extracting --- .gitlab-ci.yml | 2 +- .travis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94a6214..d699246 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,7 +23,7 @@ cmake: doxygen script: - wget https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-linux-x86_64.tar.gz - - tar xzvf cmake-3.20.3-linux-x86_64.tar.gz + - tar xzf cmake-3.20.3-linux-x86_64.tar.gz - cmake-3.20.3-linux-x86_64/bin/cmake -Bbuild -H. - cmake-3.20.3-linux-x86_64/bin/cmake --build build tags: diff --git a/.travis.yml b/.travis.yml index 132b46e..5ff931f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ env: PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/openssl/lib/pkgconfig script: - wget https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-linux-x86_64.tar.gz - - tar xzvf cmake-3.20.3-linux-x86_64.tar.gz + - tar xzf cmake-3.20.3-linux-x86_64.tar.gz - cmake-3.20.3-linux-x86_64/bin/cmake -Bbuild -H. - cmake-3.20.3-linux-x86_64/bin/cmake --build build - ./autogen.sh From 950b73cf3669069b384571abe2f893e10e62b8ab Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 20:47:44 +0200 Subject: [PATCH 12/26] Use CMake 3.16 in CI, fix OSX CI --- .gitlab-ci.yml | 8 ++++---- .travis.yml | 13 +++++++++---- Brewfile | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d699246..46e6d00 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,10 +22,10 @@ cmake: apt-get install -y libopus-dev libogg-dev libssl-dev doxygen script: - - wget https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-linux-x86_64.tar.gz - - tar xzf cmake-3.20.3-linux-x86_64.tar.gz - - cmake-3.20.3-linux-x86_64/bin/cmake -Bbuild -H. - - cmake-3.20.3-linux-x86_64/bin/cmake --build build + - wget https://cmake.org/files/v3.16/cmake-3.16.9-Linux-x86_64.tar.gz + - tar xzf cmake-3.16.9-Linux-x86_64.tar.gz + - cmake-3.16.9-Linux-x86_64/bin/cmake -Bbuild -H. + - cmake-3.16.9-Linux-x86_64/bin/cmake --build build tags: - docker diff --git a/.travis.yml b/.travis.yml index 5ff931f..2a2daf5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,11 +23,16 @@ addons: env: PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/openssl/lib/pkgconfig +before_script: + - if [ "$TRAVIS_OS_NAME" = "linux" ]; then + wget https://cmake.org/files/v3.16/cmake-3.16.9-Linux-x86_64.tar.gz + tar xzf cmake-3.16.9-Linux-x86_64.tar.gz + export PATH=/cmake-3.16.9-Linux-x86_64/bin:${PATH} + fi + script: - - wget https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-linux-x86_64.tar.gz - - tar xzf cmake-3.20.3-linux-x86_64.tar.gz - - cmake-3.20.3-linux-x86_64/bin/cmake -Bbuild -H. - - cmake-3.20.3-linux-x86_64/bin/cmake --build build + - cmake -Bbuild -H. + - cmake --build build - ./autogen.sh - ./configure - make diff --git a/Brewfile b/Brewfile index c5f3a82..bac1bf5 100644 --- a/Brewfile +++ b/Brewfile @@ -5,3 +5,4 @@ brew 'autoconf' brew 'automake' brew 'libtool' brew 'pkg-config' +brew 'cmake@3.16' From 499b65a288480363fd20fad209e5943d2eb20875 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 20:49:55 +0200 Subject: [PATCH 13/26] Add semicoli --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2a2daf5..d07863b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,9 +25,9 @@ env: PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/openssl/lib/pkgconfig before_script: - if [ "$TRAVIS_OS_NAME" = "linux" ]; then - wget https://cmake.org/files/v3.16/cmake-3.16.9-Linux-x86_64.tar.gz - tar xzf cmake-3.16.9-Linux-x86_64.tar.gz - export PATH=/cmake-3.16.9-Linux-x86_64/bin:${PATH} + wget https://cmake.org/files/v3.16/cmake-3.16.9-Linux-x86_64.tar.gz; + tar xzf cmake-3.16.9-Linux-x86_64.tar.gz; + export PATH=/cmake-3.16.9-Linux-x86_64/bin:${PATH}; fi script: From 4d5e04c23286adc9c85d309ca90cee18962a0f42 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 20:56:22 +0200 Subject: [PATCH 14/26] Export current directory in PATH --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d07863b..b8648a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,10 +27,11 @@ before_script: - if [ "$TRAVIS_OS_NAME" = "linux" ]; then wget https://cmake.org/files/v3.16/cmake-3.16.9-Linux-x86_64.tar.gz; tar xzf cmake-3.16.9-Linux-x86_64.tar.gz; - export PATH=/cmake-3.16.9-Linux-x86_64/bin:${PATH}; + export PATH="${PWD}/cmake-3.16.9-Linux-x86_64/bin:${PATH}"; fi script: + - echo ${PATH} - cmake -Bbuild -H. - cmake --build build - ./autogen.sh From 2847e2055c43c55f1965ef6f9cd8c2e7bdd7df45 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 21:01:14 +0200 Subject: [PATCH 15/26] Make imported pkgconfig targets global --- .travis.yml | 1 - cmake/FindOgg.cmake | 1 + cmake/FindOpus.cmake | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b8648a6..4386861 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,6 @@ before_script: fi script: - - echo ${PATH} - cmake -Bbuild -H. - cmake --build build - ./autogen.sh diff --git a/cmake/FindOgg.cmake b/cmake/FindOgg.cmake index 2bff939..f18da82 100644 --- a/cmake/FindOgg.cmake +++ b/cmake/FindOgg.cmake @@ -2,5 +2,6 @@ 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() diff --git a/cmake/FindOpus.cmake b/cmake/FindOpus.cmake index b570a86..f27c26f 100644 --- a/cmake/FindOpus.cmake +++ b/cmake/FindOpus.cmake @@ -2,5 +2,6 @@ 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() From beab6504613789683255dac9f613f39fe3e56632 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 21:05:52 +0200 Subject: [PATCH 16/26] Install doxygen in Brewfile --- Brewfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Brewfile b/Brewfile index bac1bf5..344718b 100644 --- a/Brewfile +++ b/Brewfile @@ -6,3 +6,4 @@ brew 'automake' brew 'libtool' brew 'pkg-config' brew 'cmake@3.16' +brew 'doxygen' From 2d317b46dc9056d8b2e38627c9ababc27ef5610c Mon Sep 17 00:00:00 2001 From: Hendrik Date: Mon, 31 May 2021 22:07:26 +0200 Subject: [PATCH 17/26] Add SOVERSION, fix target name --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8bba98..bcae9a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,9 @@ 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} @@ -44,6 +47,8 @@ add_library(opusfile 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 @@ -134,8 +139,10 @@ if(NOT OP_DISABLE_HTTP) "${CMAKE_CURRENT_SOURCE_DIR}/src/winerrno.h" ) endif() - set_target_properties(opusfile PROPERTIES + 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 From 3a10e8141c7ca871763a38b95d5eb38e4aa66c9e Mon Sep 17 00:00:00 2001 From: Hendrik Date: Thu, 3 Jun 2021 12:03:48 +0200 Subject: [PATCH 18/26] Make pkgconfig targets globally imported targets --- opusfileConfig.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/opusfileConfig.cmake b/opusfileConfig.cmake index b56a704..cb604c3 100644 --- a/opusfileConfig.cmake +++ b/opusfileConfig.cmake @@ -12,6 +12,7 @@ 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() @@ -25,6 +26,7 @@ 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() From b0903d712307a295555aa0ae73c864add714bbc7 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Fri, 4 Jun 2021 20:33:02 +0200 Subject: [PATCH 19/26] Use curl -O instead of wget --- .gitlab-ci.yml | 2 +- .travis.yml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 46e6d00..306272c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ cmake: apt-get install -y libopus-dev libogg-dev libssl-dev doxygen script: - - wget https://cmake.org/files/v3.16/cmake-3.16.9-Linux-x86_64.tar.gz + - curl -O https://cmake.org/files/v3.16/cmake-3.16.9-Linux-x86_64.tar.gz - tar xzf cmake-3.16.9-Linux-x86_64.tar.gz - cmake-3.16.9-Linux-x86_64/bin/cmake -Bbuild -H. - cmake-3.16.9-Linux-x86_64/bin/cmake --build build diff --git a/.travis.yml b/.travis.yml index 4386861..90d94ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,6 @@ addons: - libogg-dev - libopus-dev - libssl-dev - - wget homebrew: brewfile: true @@ -25,7 +24,7 @@ env: PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/openssl/lib/pkgconfig before_script: - if [ "$TRAVIS_OS_NAME" = "linux" ]; then - wget https://cmake.org/files/v3.16/cmake-3.16.9-Linux-x86_64.tar.gz; + curl -O https://cmake.org/files/v3.16/cmake-3.16.9-Linux-x86_64.tar.gz; tar xzf cmake-3.16.9-Linux-x86_64.tar.gz; export PATH="${PWD}/cmake-3.16.9-Linux-x86_64/bin:${PATH}"; fi From 6cceb8928af9c64175fc925493f631467b70b88c Mon Sep 17 00:00:00 2001 From: Hendrik Date: Fri, 4 Jun 2021 20:33:52 +0200 Subject: [PATCH 20/26] Fix BOOL generator expression --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcae9a9..d19cf21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ target_link_libraries(opusfile PUBLIC Ogg::ogg Opus::opus - $<$:m> + $<$:m> ) target_compile_options(opusfile PRIVATE @@ -167,7 +167,7 @@ if(NOT OP_DISABLE_HTTP) OpenSSL::SSL $<$:ws2_32> $<$:crypt32> - $<$:m> + $<$:m> ) target_compile_options(opusurl PRIVATE From b94ce6ae60945eee07bb7ac626ed6f024213d484 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sat, 5 Jun 2021 11:54:04 +0200 Subject: [PATCH 21/26] Do not check for winsock2.h --- CMakeLists.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d19cf21..ffb6e3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,12 +98,7 @@ if(NOT OP_DISABLE_HTTP) include(CheckIncludeFile) include(CheckCSourceCompiles) cmake_push_check_state(RESET) - if(WIN32) - check_include_file("winsock2.h" OP_HAVE_WINSOCK2_H) - if(NOT OP_HAVE_WINSOCK2_H) - message(FATAL_ERROR "HTTP support requires a Winsock socket library") - endif() - else() + 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") From d1b2ee8e21c13c2d63f2512506788d100df69b99 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sun, 6 Jun 2021 08:31:42 +0200 Subject: [PATCH 22/26] Generate config file --- CMakeLists.txt | 8 +++++++- opusfileConfig.cmake => opusfileConfig.cmake.in | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) rename opusfileConfig.cmake => opusfileConfig.cmake.in (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffb6e3e..490f04f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,6 +282,12 @@ install(EXPORT opusfileTargets NAMESPACE opusfile:: ) include(CMakePackageConfigHelpers) +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/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}" @@ -289,7 +295,7 @@ write_basic_package_version_file( ) install( FILES - "${CMAKE_CURRENT_SOURCE_DIR}/opusfileConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/opusfileConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/opusfileConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/opusfile" diff --git a/opusfileConfig.cmake b/opusfileConfig.cmake.in similarity index 96% rename from opusfileConfig.cmake rename to opusfileConfig.cmake.in index cb604c3..a4b01be 100644 --- a/opusfileConfig.cmake +++ b/opusfileConfig.cmake.in @@ -1,3 +1,5 @@ +@PACKAGE_INIT@ + # Ported from CMakeFindDependencyMacro.cmake (finding configs and using pkgconfig as fallback) set(cmake_quiet_arg) if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) @@ -41,3 +43,5 @@ set(cmake_fd_quiet_arg) # Including targets of opusfile include("${CMAKE_CURRENT_LIST_DIR}/opusfileTargets.cmake") + +check_required_components(opusfile) From 7b09bf531b1099be7e3477055a6096c6d4bc6e85 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sun, 6 Jun 2021 10:35:22 +0200 Subject: [PATCH 23/26] Move opusfileConfig.cmake.in --- CMakeLists.txt | 2 +- opusfileConfig.cmake.in => cmake/opusfileConfig.cmake.in | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename opusfileConfig.cmake.in => cmake/opusfileConfig.cmake.in (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 490f04f..b06b3eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -283,7 +283,7 @@ install(EXPORT opusfileTargets ) include(CMakePackageConfigHelpers) configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/opusfileConfig.cmake.in" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/opusfileConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/opusfileConfig.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/opusfile" diff --git a/opusfileConfig.cmake.in b/cmake/opusfileConfig.cmake.in similarity index 100% rename from opusfileConfig.cmake.in rename to cmake/opusfileConfig.cmake.in From 996f5ae284b7d49962a4162aeccd591ce5e5a239 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sun, 6 Jun 2021 10:38:20 +0200 Subject: [PATCH 24/26] Add find_dependency(OpenSSL) to config script --- cmake/opusfileConfig.cmake.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/opusfileConfig.cmake.in b/cmake/opusfileConfig.cmake.in index a4b01be..afdcee3 100644 --- a/cmake/opusfileConfig.cmake.in +++ b/cmake/opusfileConfig.cmake.in @@ -41,6 +41,11 @@ 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") From 30c375f73b91d0b627a0d4ba0ddf13c8a2fa8706 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sun, 6 Jun 2021 10:50:20 +0200 Subject: [PATCH 25/26] Change case of namespace --- CMakeLists.txt | 30 +++++++++---------- ...onfig.cmake.in => OpusFileConfig.cmake.in} | 0 ...ion.cmake => OpusFilePackageVersion.cmake} | 0 3 files changed, 15 insertions(+), 15 deletions(-) rename cmake/{opusfileConfig.cmake.in => OpusFileConfig.cmake.in} (100%) rename cmake/{opusfilePackageVersion.cmake => OpusFilePackageVersion.cmake} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b06b3eb..fe99d12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.16) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") -include(opusfilePackageVersion) +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 +project(OpusFile VERSION ${PROJECT_VERSION} LANGUAGES C ) @@ -44,7 +44,7 @@ add_library(opusfile "${CMAKE_CURRENT_SOURCE_DIR}/src/opusfile.c" "${CMAKE_CURRENT_SOURCE_DIR}/src/stream.c" ) -add_library(opusfile::opusfile ALIAS opusfile) +add_library(OpusFile::opusfile ALIAS opusfile) set_target_properties(opusfile PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/opusfile.h" VERSION ${PROJECT_VERSION} @@ -84,7 +84,7 @@ target_compile_definitions(opusfile $<$:OP_HAVE_LRINTF> ) install(TARGETS opusfile - EXPORT opusfileTargets + EXPORT OpusFileTargets RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" @@ -127,7 +127,7 @@ if(NOT OP_DISABLE_HTTP) "${CMAKE_CURRENT_SOURCE_DIR}/src/internal.c" "${CMAKE_CURRENT_SOURCE_DIR}/src/internal.h" ) - add_library(opusfile::opusurl ALIAS opusurl) + add_library(OpusFile::opusurl ALIAS opusurl) if(WIN32) target_sources(opusurl PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/wincerts.c" @@ -178,7 +178,7 @@ if(NOT OP_DISABLE_HTTP) $<$:-fvisibility=hidden> ) install(TARGETS opusurl - EXPORT opusfileTargets + EXPORT OpusFileTargets RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" @@ -191,7 +191,7 @@ 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) + add_executable(OpusFile::opusfile_example ALIAS opusfile_example) if(WIN32) target_sources(opusfile_example PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/examples/win32utf8.c" @@ -224,7 +224,7 @@ if(NOT OP_DISABLE_EXAMPLES) add_executable(seeking_example "${CMAKE_CURRENT_SOURCE_DIR}/examples/seeking_example.c" ) - add_executable(opusfile::seeking_example ALIAS seeking_example) + add_executable(OpusFile::seeking_example ALIAS seeking_example) if(WIN32) target_sources(seeking_example PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/examples/win32utf8.c" @@ -277,26 +277,26 @@ if(NOT OP_DISABLE_DOCS) doxygen_add_docs(doxygen "${CMAKE_CURRENT_SOURCE_DIR}/include/opusfile.h" ALL USE_STAMP_FILE) endif() -install(EXPORT opusfileTargets +install(EXPORT OpusFileTargets DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/opusfile" - NAMESPACE opusfile:: + NAMESPACE OpusFile:: ) include(CMakePackageConfigHelpers) configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/opusfileConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/opusfileConfig.cmake" + "${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" + "OpusFileConfigVersion.cmake" VERSION "${PACKAGE_VERSION}" COMPATIBILITY AnyNewerVersion ) install( FILES - "${CMAKE_CURRENT_BINARY_DIR}/opusfileConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/opusfileConfigVersion.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/OpusFileConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/OpusFileConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/opusfile" ) diff --git a/cmake/opusfileConfig.cmake.in b/cmake/OpusFileConfig.cmake.in similarity index 100% rename from cmake/opusfileConfig.cmake.in rename to cmake/OpusFileConfig.cmake.in diff --git a/cmake/opusfilePackageVersion.cmake b/cmake/OpusFilePackageVersion.cmake similarity index 100% rename from cmake/opusfilePackageVersion.cmake rename to cmake/OpusFilePackageVersion.cmake From 85b5a29830ae0c6c53c14667989cef00b3f84752 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Fri, 2 Jul 2021 11:58:15 +0200 Subject: [PATCH 26/26] Put opusfile.h into subdirectory --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe99d12..ee37291 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,7 @@ target_include_directories(opusfile "${CMAKE_CURRENT_SOURCE_DIR}/include" INTERFACE $ - $ + $ ) target_link_libraries(opusfile PUBLIC @@ -88,8 +88,8 @@ install(TARGETS opusfile RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus" + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus" ) if(NOT OP_DISABLE_HTTP) @@ -144,7 +144,7 @@ if(NOT OP_DISABLE_HTTP) "${CMAKE_CURRENT_SOURCE_DIR}/include" INTERFACE $ - $ + $ ) target_compile_definitions(opusurl PRIVATE @@ -182,8 +182,8 @@ if(NOT OP_DISABLE_HTTP) RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" - INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus" + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus" ) endif()