improve toxcore cmake and add flake

This commit is contained in:
Green Sky 2023-12-01 00:24:18 +01:00
parent c3a3904524
commit 7f939b6b60
No known key found for this signature in database
5 changed files with 137 additions and 4 deletions

View File

@ -166,22 +166,22 @@ if (NOT TARGET toxcore)
# TODO: add the others # TODO: add the others
configure_file( configure_file(
${TOX_DIR}toxcore/tox.h ${TOX_DIR}toxcore/tox.h
${TOX_DIR}tox/tox.h ${toxcore_BINARY_DIR}/include/tox/tox.h
@ONLY @ONLY
) )
configure_file( configure_file(
${TOX_DIR}toxcore/tox_events.h ${TOX_DIR}toxcore/tox_events.h
${TOX_DIR}tox/tox_events.h ${toxcore_BINARY_DIR}/include/tox/tox_events.h
@ONLY @ONLY
) )
configure_file( configure_file(
${TOX_DIR}toxcore/tox_private.h ${TOX_DIR}toxcore/tox_private.h
${TOX_DIR}tox/tox_private.h ${toxcore_BINARY_DIR}/include/tox/tox_private.h
@ONLY @ONLY
) )
target_include_directories(toxcore PRIVATE "${TOX_DIR}toxcore") target_include_directories(toxcore PRIVATE "${TOX_DIR}toxcore")
target_include_directories(toxcore PUBLIC "${TOX_DIR}") target_include_directories(toxcore PUBLIC "${toxcore_BINARY_DIR}/include/")
target_compile_definitions(toxcore PUBLIC USE_IPV6=1) target_compile_definitions(toxcore PUBLIC USE_IPV6=1)
#target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_DEBUG) #target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_DEBUG)

61
flake.lock generated Normal file
View File

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1694553957,
"narHash": "sha256-8o15HEax53lBJjjcr5VHMpuuT6vBcrzSNB6y2iGlPaU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e7fe745d22df5fa282b321e577fe18d4f62e0f0b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "release-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

58
flake.nix Normal file
View File

@ -0,0 +1,58 @@
{
description = "totato flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-23.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
toxcore-src = pkgs.fetchFromGitHub {
owner = "Green-Sky";
repo = "c-toxcore";
fetchSubmodules = true;
rev = "d4b06edc2a35bad51b0f0950d74f61c8c70630ab"; # ngc_events
hash = "sha256-P7wTojRQRtvTx+h9+QcFdO381hniWWpAy5Yv63KWWZA=";
};
in {
packages.default = pkgs.stdenv.mkDerivation {
pname = "totato";
version = "0.0.0-dev";
src = ./.;
nativeBuildInputs = with pkgs; [
cmake
ninja
pkg-config
git # cmake FetchContent
];
cmakeFlags = [
#"-DFETCHCONTENT_SOURCE_DIR_TOXCORE=${pkgs.libtoxcore.src}"
"-DFETCHCONTENT_SOURCE_DIR_TOXCORE=${toxcore-src}"
];
buildInputs = with pkgs; [
#(libsodium.override { stdenv = pkgs.pkgsStatic.stdenv; })
#pkgsStatic.libsodium
libsodium
];
# TODO: replace with install command
installPhase = ''
mkdir -p $out/bin
mv bin/totato $out/bin
'';
};
#apps.default = {
#type = "app";
#program = "${self.packages.${system}.default}/bin/tomato";
#};
}
);
}

View File

@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
add_executable(totato
./main.cpp
)
target_compile_features(totato PUBLIC cxx_std_17)
target_link_libraries(totato PUBLIC
toxcore
)

3
src/main.cpp Normal file
View File

@ -0,0 +1,3 @@
int main(void) {
return 0;
}