summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn van Beurden <mvanb1@gmail.com>2022-04-27 19:53:13 +0200
committerGitHub <noreply@github.com>2022-04-27 19:53:13 +0200
commit0caf685360f1c06173f5bfd084b8679d517389f9 (patch)
treef989191aa495168398c98c7d4abb28d9c146fd21
parent1793632ee6988deb933ff7551fee92134622b558 (diff)
downloadflac-0caf685360f1c06173f5bfd084b8679d517389f9.tar.gz
[CMake] Enable building ogg together with flac (#325)
This reverts the part of commit 2013738 that searched for a local ogg build
-rw-r--r--.github/workflows/action.yml10
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt13
-rw-r--r--README75
-rw-r--r--cmake/FindOgg.cmake8
5 files changed, 66 insertions, 41 deletions
diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml
index 9b79ecf1..a6dd600b 100644
--- a/.github/workflows/action.yml
+++ b/.github/workflows/action.yml
@@ -72,7 +72,7 @@ jobs:
- name: windows-latest-cmake
os: windows-latest
build-system: cmake
- configure-opts: '-DWITH_OGG=OFF'
+ configure-opts: ''
- name: ubuntu-latest-gcc-autotools-64-bit-words
os: ubuntu-latest
@@ -121,8 +121,14 @@ jobs:
steps:
- uses: actions/checkout@v2
+ - uses: actions/checkout@v2
+ if: startsWith(matrix.build-system,'cmake')
+ with:
+ repository: xiph/ogg
+ path: ./ogg
+
- name: Install MacOS dependencies
- if: startsWith(matrix.os,'macos')
+ if: startsWith(matrix.os,'macos') && !startsWith(matrix.build-system,'cmake')
run: |
brew update
brew install automake pkg-config libogg
diff --git a/.gitignore b/.gitignore
index 36355d60..6a60d527 100644
--- a/.gitignore
+++ b/.gitignore
@@ -75,6 +75,7 @@ test/picture.diff
test/picture.log
.dirstamp
microbench/benchmark_residual
+/ogg/
oss-fuzz/fuzzer_decoder
oss-fuzz/fuzzer_encoder
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6163a254..7e6ae233 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,8 +34,17 @@ if(NOT UNIX)
endif()
if(WITH_OGG)
- find_package(Ogg REQUIRED)
- set(OGG_PACKAGE "ogg")
+ if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ogg")
+ add_subdirectory("ogg")
+ set(OGG_FOUND 1 CACHE INTERNAL "ogg has been added as subdirectory")
+ set_target_properties(ogg PROPERTIES FOLDER Libraries)
+ if(BUILD_TESTING)
+ set_target_properties(test_bitwise test_framing PROPERTIES FOLDER Tests)
+ endif()
+ else()
+ find_package(Ogg REQUIRED)
+ set(OGG_PACKAGE "ogg")
+ endif()
endif()
find_program (HAVE_GIT git)
diff --git a/README b/README
index bd2b0689..235d7c81 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
/* FLAC - Free Lossless Audio Codec
* Copyright (C) 2001-2009 Josh Coalson
- * Copyright (C) 2011-2016 Xiph.Org Foundation
+ * Copyright (C) 2011-2022 Xiph.Org Foundation
*
* This file is part the FLAC project. FLAC is comprised of several
* components distributed under different licenses. The codec libraries
@@ -19,7 +19,8 @@
FLAC is an Open Source lossless audio codec developed by Josh Coalson from 2001
-to 2009. From 2012 to 2021 it was maintained by Erik de Castro Lopo. It continues to be maintained by various volunteers under the auspices of the Xiph.org Foundation.
+to 2009. From 2012 to 2021 it was maintained by Erik de Castro Lopo. It continues
+to be maintained by various volunteers under the auspices of the Xiph.org Foundation.
FLAC is comprised of
* `libFLAC', a library which implements reference encoders and
@@ -264,74 +265,86 @@ CMake is a cross-platform build system. FLAC can be built on Windows, Linux, Mac
OS X using CMake.
You can use either CMake's CLI or GUI. We recommend you to have a separate build
-folder outside the repository in order to not spoil it with generated files.
+folder outside the repository in order to not spoil it with generated files. It is
+possible however to do a so-called in-tree build, in that case /path/to/flac-build
+in the following examples is equal to /path/to/flac-source.
CLI
---
Go to your build folder and run something like this:
- /path/to/flac/build$ cmake /path/to/flac/source
+ /path/to/flac-build$ cmake /path/to/flac-source
or e.g. in Windows shell
- C:\path\to\flac\build> cmake \path\to\flac\source
+ C:\path\to\flac-build> cmake \path\to\flac-source
(provided that cmake is in your %PATH% variable)
That will generate build scripts for the default build system (e.g. Makefiles
for UNIX). After that you start build with a command like this:
- /path/to/flac/build$ make
+ /path/to/flac-build$ make
And afterwards you can run tests or install the built libraries and headers
- /path/to/flac/build$ make test
- /path/to/flac/build$ make install
+ /path/to/flac-build$ make test
+ /path/to/flac-build$ make install
If you want use a build system other than default add -G flag to cmake, e.g.:
- /path/to/flac/build$ cmake /path/to/flac/source -GNinja
- /path/to/flac/build$ ninja
+ /path/to/flac-build$ cmake /path/to/flac-source -GNinja
+ /path/to/flac-build$ ninja
or:
- /path/to/flac/build$ cmake /path/to/flac/source -GXcode
+ /path/to/flac-build$ cmake /path/to/flac-source -GXcode
Use cmake --help to see the list of available generators.
- If you have OGG on your system you can tell CMake to use it:
+ By default CMake will search for OGG. If CMake fails to find it you can help
+ CMake by specifying the exact path:
- /path/to/flac/build$ cmake /path/to/flac/source -DWITH_OGG=ON
+ /path/to/flac-build$ cmake /path/to/flac-source -DOGG_ROOT=/path/to/ogg
+
+ If you would like CMake to build OGG alongside FLAC, you can place the ogg
+ sources directly in the flac source directory as a subdirectory with the name
+ ogg, for example
+
+ /path/to/flac-source/ogg
- If CMake fails to find it you can help CMake by specifying the exact path:
+ If you don't want to build flac with OGG support you can tell CMake not to
+ look for OGG:
- /path/to/flac/build$ cmake /path/to/flac/source -DWITH_OGG=ON -DOGG_ROOT=/path/to/ogg
-
- CMake will search for OGG by default so if you don't have it you can tell
- cmake to not do so:
-
- /path/to/flac/build$ cmake /path/to/flac/source -DWITH_OGG=OFF
+ /path/to/flac-build$ cmake /path/to/flac-source -DWITH_OGG=OFF
Other FLAC's options (e.g. building C++ lib or docs) can also be put to cmake
through -D flag.
GUI
---
- It is likely that you would prefer to use it on Windows building for Visual
- Studio. It's in essence the same process as building using CLI.
+ It is likely that you would prefer to use the CMake GUI if you use Visual
+ Studio to build FLAC. It's in essence the same process as building using CLI.
Open cmake-gui. In the window select a source directory (the repository's
root), a build directory (some other directory outside the repository). Then
press button "Configure". CMake will ask you which build system you prefer.
Choose that version of Visual Studio which you have on your system, choose
- whether you want to build for x86 or amd64. Press OK. After CMake finishes
- press "Generate" button, and after that "Open Project". In response CMake
- will launch Visual Studio and open the generated solution. You can use it as
- usual but remember that it was generated by CMake. That means that your
- changes (e.g. some addidional compile flags) will be lost when you run CMake
- next time.
-
- Again, if you have OGG on your system set WITH_OGG flag in the list of
- variables in cmake-gui window before you press "Configure".
+ whether you want to build for Win32 or x64. Press OK. After CMake finishes
+ you can change the configuration to your liking and if you change anything,
+ run Configure again. With the "Generate" button, CMake creates Visual Studio
+ files, which can be opened from Visual Studio. With the button "Open Project"
+ CMake will launch Visual Studio and open the generated solution. You can use
+ the project files as usual but remember that they were generated by CMake.
+ That means that your changes (e.g. some additional compile flags) will be
+ lost when you run CMake next time.
+
+ CMake searches by default for OGG on your system and returns an error if it
+ cannot find it. If you want to build OGG alongside FLAC, you can download the
+ OGG sources and extract them in a subdirectory of the FLAC source directory
+ with the name ogg (i.e. /path/to/flac-source/ogg) before running CMake. If
+ you don't want to build FLAC with OGG support, untick the box following
+ WITH_OGG flag in the list of variables in cmake-gui window and run
+ "Configure" again.
If CMake fails to find MSVC compiler then running cmake-gui from MS Developer
comand prompt should help.
diff --git a/cmake/FindOgg.cmake b/cmake/FindOgg.cmake
index 34407fd4..b60c3526 100644
--- a/cmake/FindOgg.cmake
+++ b/cmake/FindOgg.cmake
@@ -1,17 +1,13 @@
find_package(PkgConfig)
pkg_check_modules(_OGG QUIET ogg)
-file(GLOB _OGG_DIR ../libogg-*)
-
find_path(OGG_INCLUDE_DIR
NAMES "ogg/ogg.h"
- PATHS ${_OGG_INCLUDE_DIRS}
- HINTS "${_OGG_DIR}/include")
+ PATHS ${_OGG_INCLUDE_DIRS})
find_library(OGG_LIBRARY
NAMES ogg libogg
- HINTS ${_OGG_LIBRARY_DIRS}
- HINTS "${_OGG_DIR}/Release")
+ HINTS ${_OGG_LIBRARY_DIRS})
mark_as_advanced(
OGG_INCLUDE_DIR