Improve Nix support (#5777)
* Fix FindOpusFile NixOS bug * better documentation
This commit is contained in:
@@ -6,9 +6,16 @@
|
|||||||
# OPUSFILE_LIBRARY - Path to the opusfile library
|
# OPUSFILE_LIBRARY - Path to the opusfile library
|
||||||
# OPUSFILE_LIBRARIES - Full list of libraries to link (opusfile, opus, ogg)
|
# OPUSFILE_LIBRARIES - Full list of libraries to link (opusfile, opus, ogg)
|
||||||
|
|
||||||
|
# Use pkg-config to find opusfile if available
|
||||||
|
find_package(PkgConf)
|
||||||
|
if(PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(PC_OPUSFILE QUIET opusfile)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Search for the OpusFile header
|
# Search for the OpusFile header
|
||||||
find_path(OPUSFILE_INCLUDE_DIR
|
find_path(OPUSFILE_INCLUDE_DIR
|
||||||
NAMES opusfile.h
|
NAMES opusfile.h
|
||||||
|
HINTS ${PC_OPUSFILE_INCLUDE_DIRS}
|
||||||
PATHS /usr/include/opus /usr/local/include/opus /opt/local/include/opus /opt/homebrew/include/opus
|
PATHS /usr/include/opus /usr/local/include/opus /opt/local/include/opus /opt/homebrew/include/opus
|
||||||
DOC "Directory where opusfile.h is located"
|
DOC "Directory where opusfile.h is located"
|
||||||
)
|
)
|
||||||
@@ -16,6 +23,7 @@ find_path(OPUSFILE_INCLUDE_DIR
|
|||||||
# Search for the OpusFile library
|
# Search for the OpusFile library
|
||||||
find_library(OPUSFILE_LIBRARY
|
find_library(OPUSFILE_LIBRARY
|
||||||
NAMES opusfile
|
NAMES opusfile
|
||||||
|
HINTS ${PC_OPUSFILE_LIBRARY_DIRS}
|
||||||
DOC "Path to the libopusfile library"
|
DOC "Path to the libopusfile library"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,72 @@ zypper in gcc gcc-c++ git cmake ninja SDL2-devel libpng16-devel libzip-devel lib
|
|||||||
# or using clang
|
# or using clang
|
||||||
zypper in clang libstdc++-devel git cmake ninja SDL2-devel libpng16-devel libzip-devel libzip-tools nlohmann_json-devel tinyxml2-devel spdlog-devel
|
zypper in clang libstdc++-devel git cmake ninja SDL2-devel libpng16-devel libzip-devel libzip-tools nlohmann_json-devel tinyxml2-devel spdlog-devel
|
||||||
```
|
```
|
||||||
|
#### Nix
|
||||||
|
You can use a `flake.nix` file to instantly setup a development environment using [Nix](https://nixos.org/). Write this `flake.nix` file in the root directory:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
description = "Shipwright development environment";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, flake-utils }:
|
||||||
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
# Build tools
|
||||||
|
clang
|
||||||
|
git
|
||||||
|
cmake
|
||||||
|
ninja
|
||||||
|
lsb-release
|
||||||
|
pkg-config
|
||||||
|
|
||||||
|
# SDL2 libraries
|
||||||
|
SDL2
|
||||||
|
SDL2.dev
|
||||||
|
SDL2_net
|
||||||
|
|
||||||
|
# Other libraries
|
||||||
|
libpng
|
||||||
|
libzip
|
||||||
|
nlohmann_json
|
||||||
|
tinyxml-2
|
||||||
|
spdlog
|
||||||
|
libGL
|
||||||
|
libGL.dev
|
||||||
|
bzip2
|
||||||
|
|
||||||
|
# X11 libraries
|
||||||
|
xorg.libX11
|
||||||
|
|
||||||
|
# Audio libraries
|
||||||
|
libogg
|
||||||
|
libogg.dev
|
||||||
|
libvorbis
|
||||||
|
libvorbis.dev
|
||||||
|
libopus
|
||||||
|
libopus.dev
|
||||||
|
opusfile
|
||||||
|
opusfile.dev
|
||||||
|
];
|
||||||
|
shellHook = ''
|
||||||
|
echo "Shipwright development environment loaded"
|
||||||
|
echo "Available tools: clang, git, cmake, ninja"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Now type `nix develop` and you will be dropped into a shell with all dependencies, ensuring that all build commands work.
|
||||||
|
|
||||||
### Build
|
### Build
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user